Annotation of doc/install/redhat7.3/install.pl, revision 1.13
1.1 matthew 1: #!/usr/bin/perl -w
2: # The LearningOnline Network
3: # Red Hat 7.3 installation script
4: #
1.13 ! matthew 5: # $Id: install.pl,v 1.12 2002/12/12 20:55:23 matthew Exp $
1.1 matthew 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # http://www.lon-capa.org/
26: #
1.2 matthew 27:
1.1 matthew 28: ##
29: ## Obvious flaws of this program:
30: ## Dieing on every error may be a little extreme. On the other hand,
31: ## how the heck am I supposed to know what absurd things the user
32: ## has done with their system before inflicting LON-CAPA on it?
33: ## The links to /etc/init.d for httpd and mysqld do not seem to work :(
34: ## The user is never informed of the log file (/tmp/loncapa_install.log).
35: ## It does not test the system at the end. Again, there are limits to
36: ## what nonsense we can put up with. Of course, we will have to
37: ## explain that to people at some point...
38: ## There is probably an overuse of elipses (...) in the comments.
1.2 matthew 39: ## It might be nice to check that all the files we need are here.
40: ## Appletalk is installed but does not work and gives errors on
41: ## boot up. I have not been able to find a clean way to get the
42: ## appletalk support working but the powers that be insist on it.
1.1 matthew 43: ##
1.2 matthew 44:
45: #
46: # Needed files:
47: #
48: # The following files are assumed to be present in the current
49: # directory:
50: # RPMS:
1.3 matthew 51: # ImageMagick-5.4.3.11-1.i386.rpm
52: # ImageMagick-devel-5.4.3.11-1.i386.rpm
53: # ImageMagick-perl-5.4.3.11-1.i386.rpm
1.2 matthew 54: # gnuplot-3.7.1-5.i386.rpm
55: # libgd-1.3-4.i386.rpm
56: # libungif-progs-4.1.0-9.i386.rpm
57: # ncurses4-5.0-5.i386.rpm
58: # readline-2.2.1-6.i386.rpm
59: # readline-4.2a-4.i386.rpm
60: # perl-DBD-MySQL-1.2216-4.i386.rpm
61: # perl-DBI-1.21-1.i386.rpm
62: # mod_perl-1.26-5.i386.rpm
63: # perl-suidperl-5.6.1-34.99.6.i386.rpm
1.12 matthew 64: # LONCAPA-0.6.0-1.i386.rpm
1.2 matthew 65: # mysql-3.23.49-3.i386.rpm
66: # mysqlclient9-3.23.22-6.i386.rpm
67: # mysql-server-3.23.49-3.i386.rpm
68: # hwcrypto-1.0-3.i386.rpm
69: # m2crypto-0.05_snap4-2.i386.rpm
1.12 matthew 70: # netpbm-9.24-3.i386.rpm
71: # netpbm-progs-9.24-3.i386.rpm
72: # krb5-libs-1.2.4-3.i386.rpm
1.2 matthew 73: # Other files:
74: # httpd.conf
75: # mod_auth_external-2.1.13.tar.gz
76: #
77: # The contingency plan for a 7.2 install tells the user to install these
78: # from the current directory.
79: # perl-5.6.1-34.99.6.i386.rpm
80: # perl-CGI-2.752-34.99.6.i386.rpm
81: #
82:
1.1 matthew 83: use strict;
84: use File::Copy;
85:
86: my $result;
87: my $test;
88:
89: # note: The filehandle LOG is global.
90: open LOG,">/tmp/loncapa_install.log" || die "Unable to open log file.\n";
91:
92: # Some friendly subroutines
93: sub die_if_nonempty {
94: my ($string,$error)=@_;
95: return if (! defined($error));
96: chomp($string);chomp($error);
97: if ($string ne '') {
98: print_and_log("$error\nHalting.\n");
99: die;
100: }
101: }
102:
103: sub make_link_or_die {
104: my ($source,$dest)=@_;
105: &die_if_nonempty
106: (`ln -fs $source $dest`,"Unable to link $source to $dest.");
107: print LOG "Link from $source to $dest made successfully\n";
108: }
109:
110: sub writelog {
111: while ($_ = shift) {
112: chomp;
113: print LOG "$_\n";
114: }
115: }
116:
117: sub print_and_log {
118: while ($_=shift) {
119: chomp;
120: print "$_\n";
121: print LOG "$_\n";
122: }
123: }
124:
125: ##
126: ## First, make sure it's a red hat system.
127: ##
128: if (! -e "/etc/redhat-release") {
129: print_and_log(<<"END");
130: *********************************************************************
131:
132: This does not a appear to be a Red-Hat system. More than likely the
133: installation will not be successful! Press control-c to abort now,
134: otherwise press enter to forge ahead and damn the torpedos.
135:
136: *********************************************************************
137: END
138: undef = <STDIN>;
139: }
140:
141:
142:
143: #
144: # The installation work begins now...
145: #
146:
147: print <<"END";
148: ********************************************************************
149:
1.12 matthew 150: Welcome to LON-CAPA 0.6.0
1.1 matthew 151:
152: This script will install the base software that LON-CAPA needs to
153: run properly.
154:
155: ********************************************************************
156: END
157:
158: ##
159: ## Install needed RPMS
160: ##
161: my $instdir = `pwd`;
162: chomp($instdir);
163: #
164: # This list of rpms needs to be pared down to some extent.
165: #
166:
1.4 matthew 167: my @apache_rpms = (
168: "$instdir/apache-1.3.23-14.i386.rpm"
169: );
170:
171: my @openssh_rpms = (
172: "$instdir/openssh-3.1p1-6.i386.rpm",
173: "$instdir/openssh-askpass-3.1p1-6.i386.rpm",
174: "$instdir/openssh-clients-3.1p1-6.i386.rpm",
175: "$instdir/openssh-server-3.1p1-6.i386.rpm"
176: );
177: # Check for gnome-askpass installation.
178: if (-e "/etc/profile.d/gnome-ssh-askpass.sh") {
179: push @openssh_rpms,"$instdir/openssh-askpass-gnome-3.1p1-6.i386.rpm";
180: }
181:
1.3 matthew 182: my @ImageMagick_rpms = (
183: "$instdir/ImageMagick-5.4.3.11-1.i386.rpm",
184: "$instdir/ImageMagick-devel-5.4.3.11-1.i386.rpm",
185: "$instdir/ImageMagick-perl-5.4.3.11-1.i386.rpm",
186: );
187:
1.1 matthew 188: my @gnuplot_rpms = (
189: "$instdir/gnuplot-3.7.1-5.i386.rpm",
190: "$instdir/libgd-1.3-4.i386.rpm",
191: "$instdir/libungif-progs-4.1.0-9.i386.rpm",
192: "$instdir/ncurses4-5.0-5.i386.rpm",
193: "$instdir/readline-2.2.1-6.i386.rpm",
194: "$instdir/readline-4.2a-4.i386.rpm"
195: );
196: my @perl_rpms = (
197: "$instdir/perl-DBD-MySQL-1.2216-4.i386.rpm",
198: "$instdir/perl-DBI-1.21-1.i386.rpm",
199: "$instdir/mod_perl-1.26-5.i386.rpm",
200: "$instdir/perl-suidperl-5.6.1-34.99.6.i386.rpm",
201: );
202: my @loncapa_perl_rpms = (
1.12 matthew 203: "$instdir/LONCAPA-0.6.0-1.i386.rpm",
204: "$instdir/netpbm-9.24-3.i386.rpm",
205: "$instdir/netpbm-progs-9.24-3.i386.rpm",
206: "$instdir/krb5-libs-1.2.4-3.i386.rpm",
1.13 ! matthew 207: "$instdir/krb5-devel-1.2.4-3.i386.rpm",
1.12 matthew 208: "$instdir/LON-CAPA-krb4-3.1-1.i386.rpm",
1.1 matthew 209: );
210: my @mysql_rpms = (
211: "$instdir/mysql-3.23.49-3.i386.rpm", # okay w/o f,nd
212: "$instdir/mysqlclient9-3.23.22-6.i386.rpm", # okay w/o f,nd
213: "$instdir/mysql-server-3.23.49-3.i386.rpm", # okay w/o f,nd
214: );
215: my @misc_rpms = (
216: "$instdir/hwcrypto-1.0-3.i386.rpm", # already installed
217: "$instdir/m2crypto-0.05_snap4-2.i386.rpm", # okay w/o f,nd
1.9 matthew 218: "$instdir/tetex-dvips-1.0.7-47.i386.rpm"
1.1 matthew 219: );
220: ##
221: ## Okay, I have tried being nice about this and not doing '--force --nodeps',
222: ## but it is an exercise in frustration. It would be nice to be kind, but
223: ## frankly I do not want to spend the time to figure this out.
224: ##
1.4 matthew 225:
226: print_and_log("Installing Apache packages.\n");
227: writelog (`rpm -Uvh @apache_rpms`);
228: print_and_log("Installing openssh packages.\n");
229: writelog (`rpm -Uvh @openssh_rpms`);
230: system("/etc/init.d/sshd start");
1.3 matthew 231: print_and_log("Installing ImageMagick packages.\n");
232: writelog (`rpm -ivh --force --nodeps @ImageMagick_rpms`);
1.1 matthew 233: print_and_log("Installing mysql packages.\n");
234: writelog (`rpm -ivh --force --nodeps @mysql_rpms`);
235: print_and_log("Installing gnuplot packages.\n");
236: writelog (`rpm -ivh --force --nodeps @gnuplot_rpms`);
237: print_and_log("Installing LON-CAPA Perl packages.\n");
238: writelog (`rpm -ivh --force --nodeps @loncapa_perl_rpms`);
239: print_and_log("Installing Perl packages.\n");
240: writelog (`rpm -ivh --force --nodeps @perl_rpms`);
241: print_and_log("Installing misc packages.\n");
242: writelog (`rpm -ivh --force --nodeps @misc_rpms`);
243: print_and_log("\n");
244:
245: ##
246: ## Fix that stupid little sendmail bug
247: ##
248: print_and_log("changing permissions on root directory.\n");
249: $result = `chmod g-w,u+w /`;
250: if ($result eq '') {
251: $result = "successful\n";
252: } else {
253: die "Unable to change permissions on root directory. Halting.\n";
254: }
255: writelog ($result);
256: print_and_log("\n");
257:
258: ##
259: ## Set up www and authentication
260: ##
261: print_and_log("Creating user 'www'\n");
262: $result = `/usr/sbin/useradd www`;
263: if (! (($result eq '') || ($result =~ /user www exists/))) {
264: die "Unable to add user www. Halting.\n";
265: }
266: writelog ($result);
267: my $num = `grep ^www /etc/passwd | cut -d':' -f3`;
268: chomp $num;
269: if (int($num) == $num) {
270: writelog ("uid of www = $num\n");
271: } else {
272: die "Unable to determine UID of user www\n Halting.\n";
273: }
274: print_and_log("\n");
275:
276: ##
277: ## Patch mod_auth_external
278: ##
279: print_and_log("Setting up authentication for 'www'\n");
280: my $patch = <<"ENDPATCH";
281: 148c148
282: < #define SERVER_UIDS 99 /* user "nobody" */
283: ---
284: > #define SERVER_UIDS $num /* user "www" */
285: ENDPATCH
286:
287: if (! -e "/usr/bin/patch") {
288: print_and_log("You must install the software development tools package ".
289: "when installing RedHat.\n");
290: die;
291: }
292: &die_if_nonempty(`cd /tmp; tar zxf $instdir/mod_auth_external-2.1.13.tar.gz`,
293: "Unable to extract mod_auth_external\n");
294: my $dir = "/tmp/mod_auth_external-2.1.13/pwauth";
295: open PATCH, "| patch $dir/config.h" ||
296: die "Unable to start patch for mod_auth_external. Halting\n";
297: print PATCH $patch;
298: close PATCH;
299: print_and_log("\n");
300:
301: ##
302: ## Compile patched pwauth
303: ##
304: print_and_log("Compiling pwauth\n");
305: $result = `cd $dir/; make`;
306: my $expected = <<"END";
307: gcc -g -c -o pwauth.o pwauth.c
308: gcc -o pwauth -g pwauth.o -lcrypt
309: END
310:
311: if ($result ne $expected) {
312: die "Unable to compile patched pwauth. Halting.\n";
313: }
314: print_and_log( $result );
315:
316: ##
317: ## Install patched pwauth
318: ##
319: print_and_log("Copying pwauth to /usr/local/sbin\n");
320: if (! copy "$dir/pwauth","/usr/local/sbin/pwauth") {
321: die "Unable to copy $dir/pwauth to /usr/local/sbin/pwauth.\n$!\nHalting\n";
322: }
323: if (! chmod (06755, "/usr/local/sbin/pwauth")) {
324: die "Unable to set permissions on /usr/local/sbin/pwauth.\n";
325: }
326: print_and_log("\n");
327:
328: ##
329: ## Set up mysql
330: ##
331: print_and_log("Setting mysqld to start on boot up.\n");
332:
333: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc0.d/K90mysqld");
334: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc1.d/K90mysqld");
335: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc2.d/S90mysqld");
336: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc3.d/S90mysqld");
337: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc4.d/S90mysqld");
338: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc5.d/S90mysqld");
339: make_link_or_die("/etc/rc.d/init.d/mysqld","/etc/rc.d/rc6.d/K90mysqld");
340:
341: writelog("mysql links created successfully\n");
342: writelog(`/etc/rc.d/init.d/mysqld start`);
343: print_and_log("Waiting for mysql daemon to start.\n");
344: sleep 5;
1.4 matthew 345: my $status = system("/etc/rc.d/init.d/mysqld status");
346: if ($status != 0) {
1.1 matthew 347: die "Unable to start mysql daemon\nHalting\n";
1.4 matthew 348: } else {
349: print_and_log("Mysql daemon is running.\n");
1.1 matthew 350: }
351: print_and_log("\n");
352:
353: ##
354: ## Get root password for mysql client
355: ##
356: print <<END;
357: Please enter a root password for the mysql database.
358: It does not have to match your root account password, but you will need
359: to remember it.
360: END
361: my $rootpass = <>;
362: chomp $rootpass;
363: print_and_log("\n");
364:
365: ##
366: ## Run the damn thing (mysql, not LON-CAPA)
367: ##
368: print_and_log("Starting mysql client.\n");
369: open MYSQL, "|mysql -u root mysql" || die "Unable to start mysql\n";
370: print MYSQL <<"ENDMYSQL";
371: CREATE DATABASE loncapa;
372: INSERT INTO user (Host, User, Password)
373: VALUES ('localhost','www',password('localhostkey'));
1.11 harris41 374: INSERT INTO db VALUES ('localhost','loncapa','www',
375: 'Y','Y','Y','Y','Y','Y','N','Y','Y','Y');
1.1 matthew 376: SET PASSWORD FOR root\@localhost=PASSWORD('$rootpass');
377: DELETE FROM user WHERE host<>'localhost';
378: FLUSH PRIVILEGES;
379: USE loncapa;
380: CREATE TABLE IF NOT EXISTS metadata (title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, creationdate DATETIME, lastrevisiondate DATETIME, owner TEXT, copyright TEXT, FULLTEXT idx_title (title), FULLTEXT idx_author (author), FULLTEXT idx_subject (subject), FULLTEXT idx_url (url), FULLTEXT idx_keywords (keywords), FULLTEXT idx_version (version), FULLTEXT idx_notes (notes), FULLTEXT idx_abstract (abstract), FULLTEXT idx_mime (mime), FULLTEXT idx_language (language), FULLTEXT idx_owner (owner), FULLTEXT idx_copyright (copyright)) TYPE=MYISAM;
381: EXIT
382: ENDMYSQL
383:
384: close MYSQL;
385: print_and_log("\n");
386:
387: ##
388: ## Kill the firewall, if it exists
389: ##
390: #
391: # A better method would be to modify the firewall rules to make
392: # the lond port open. Someday.
393: #
394: if (-e "/etc/init.d/iptables" || -e "/etc/init.d/ipchans") {
395: print_and_log("Stopping and removing your firewall\n");
396: my @tokill = ("/etc/rc.d/rc2.d/S08ipchains",
397: "/etc/rc.d/rc2.d/S08iptables",
398: "/etc/rc.d/rc3.d/S08ipchains",
399: "/etc/rc.d/rc3.d/S08iptables",
400: "/etc/rc.d/rc4.d/S08ipchains",
401: "/etc/rc.d/rc4.d/S08iptables",
402: "/etc/rc.d/rc5.d/S08ipchains",
403: "/etc/rc.d/rc5.d/S08iptables" );
404: foreach (@tokill) {
405: unlink $_ if (-e $_ );
406: }
407: writelog(`/etc/init.d/ipchains stop`);
408: writelog(`/etc/init.d/ipchains stop`);
409: print_and_log("\n");
410: }
411:
412: ##
413: ## Set up httpd
414: ##
415: print_and_log("Setting httpd to start on boot up.\n");
416:
417: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc0.d/K15httpd");
418: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc1.d/K15httpd");
419: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc2.d/K15httpd");
420: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc3.d/S85httpd");
421: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc4.d/K15httpd");
422: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc5.d/K15httpd");
423: make_link_or_die("/etc/rc.d/init.d/httpd","/etc/rc.d/rc6.d/K15httpd");
424:
425: ##
426: ## Copy our (probably lousy) httpd.conf to its rightful place
427: ##
428: print_and_log("Copying our httpd.conf to /etc/httpd/conf/httpd.conf\n");
429: copy "$instdir/httpd.conf","/etc/httpd/conf/httpd.conf";
430: chmod 0444,"/etc/httpd/conf/httpd.conf";
431: print_and_log("\n");
432:
433: ##
434: ## Retrieve loncapa.tar.gz
435: ##
1.5 harris41 436: if (! -e "$instdir/loncapa-current.tar.gz") {
1.1 matthew 437: print_and_log("Retrieving LON-CAPA source files from install.loncapa.org\n");
1.5 harris41 438: system("wget http://install.loncapa.org/versions/loncapa-current.tar.gz 2>/dev/null 1>/dev/null");
439: if (! -e "./loncapa-current.tar.gz") {
1.1 matthew 440: die("Unable to retrieve LON-CAPA source files from\n".
1.5 harris41 441: "http://install.loncapa.org/versions/loncapa-current.tar.gz\n");
1.1 matthew 442: }
443: print_and_log("\n");
444: } else {
445: print_and_log(<<"END");
446: ------------------------------------------------------------------------
447:
1.5 harris41 448: You seem to have a version of loncapa-current.tar.gz in $instdir.
1.1 matthew 449: This copy will be used and a new version will NOT be downloaded.
450: If you wish, you may download a new version by executing:
451:
1.5 harris41 452: wget http://install.loncapa.org/versions/loncapa-current.tar.gz
1.1 matthew 453:
454: ------------------------------------------------------------------------
455: END
456: }
457:
458: ##
459: ## untar loncapa.tar.gz
460: ##
461: print_and_log("Extracting LON-CAPA source files\n");
1.5 harris41 462: writelog(`cd ~root; tar zxf $instdir/loncapa-current.tar.gz`);
1.1 matthew 463: print_and_log("\n");
464:
465: my $version = `cat /etc/redhat-release`;
466: if ($version =~ /7\.2/) {
467: print_and_log(<<"END");
468: This appears to be a Red Hat 7.2 system. You need to execute the following
469: commands now:
470: rpm -Uvh perl-5.6.1-34.99.6.i386.rpm
471: rpm -Uvh perl-CGI-2.752-34.99.6.i386.rpm
472:
1.7 harris41 473: cd /root/loncapa-N.N (N.N should correspond to a version number like '0.4')
1.1 matthew 474: ./UPDATE
475:
476: END
477: } else {
478: ##
479: ## Assure them that everything worked okay....
480: ##
481: print <<"ENDMSG";
482: All of the extra files seem to have been installed correctly. It remains for
483: you to execute the following commands:
484:
1.7 harris41 485: cd /root/loncapa-N.N (N.N should correspond to a version number like '0.4')
1.1 matthew 486: ./UPDATE
487:
1.5 harris41 488: If you have any trouble, please see http://install.loncapa.org/ and
489: http://help.loncapa.org/.
1.1 matthew 490: ENDMSG
491: }
492:
493: close LOG;
1.4 matthew 494:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>