Annotation of doc/install/linux/install.pl, revision 1.5
1.1 raeburn 1: #!/usr/bin/perl
2: # The LearningOnline Network
3: # Pre-installation script for LON-CAPA
4: #
5: # Copyright Michigan State University Board of Trustees
6: #
7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8: #
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # http://www.lon-capa.org/
24: #
25:
26: use strict;
27: use File::Copy;
28: use Term::ReadKey;
29: use DBI;
30: use LCLocalization::localize;
31:
32: # ========================================================= The language handle
33:
34: my %languages = (
35: ar => 'Arabic',
36: de => 'German',
37: en => 'English',
38: es => 'Spanish (Castellan)',
39: fa => 'Persian',
40: fr => 'French',
41: he => 'Hebrew',
42: ja => 'Japanese',
43: pt => 'Portuguese',
44: ru => 'Russian',
45: tr => 'Turkish',
46: zh => 'Chinese Simplified'
47: );
48:
49: use vars qw($lh $lang);
50: $lang = 'en';
51: if (@ARGV > 0) {
52: foreach my $poss (keys(%languages)) {
53: if ($ARGV[0] eq $poss) {
54: $lang = $ARGV[0];
55: }
56: }
57: }
58:
59: &get_language_handle($lang);
60:
61: # Check user has root privs
62: if (0 != $<) {
63: print &mt('This script must be run as root.')."\n".
64: &mt('Stopping execution.')."\n";
65: exit;
66: }
67:
68:
69: # Globals: filehandle LOG is global.
70: if (!open(LOG,">>loncapa_install.log")) {
71: print &mt('Unable to open log file.')."\n".
72: &mt('Stopping execution.')."\n";
73: exit;
74: } else {
1.5 ! raeburn 75: print LOG '$Id: install.pl,v 1.4 2011/03/21 13:32:44 raeburn Exp $'."\n";
1.1 raeburn 76: }
77:
78: #
1.2 raeburn 79: # Helper routines and routines to establish recommended actions
1.1 raeburn 80: #
81:
82: sub get_language_handle {
83: my @languages = @_;
84: $lh=LCLocalization::localize->get_handle(@languages);
85: }
86:
87: sub mt (@) {
88: if ($lh) {
89: if ($_[0] eq '') {
90: if (wantarray) {
91: return @_;
92: } else {
93: return $_[0];
94: }
95: } else {
96: return $lh->maketext(@_);
97: }
98: } else {
99: if (wantarray) {
100: return @_;
101: } else {
102: return $_[0];
103: }
104: }
105: }
106:
107: sub texthash {
108: my (%hash) = @_;
109: foreach (keys(%hash)) {
110: $hash{$_}=&mt($hash{$_});
111: }
112: return %hash;
113: }
114:
115:
116: sub skip_if_nonempty {
117: my ($string,$error)=@_;
118: return if (! defined($error));
119: chomp($string);chomp($error);
120: if ($string ne '') {
121: print_and_log("$error\n".&mt('Stopping execution.')."\n");
122: return 1;
123: }
124: return;
125: }
126:
127: sub writelog {
128: while ($_ = shift) {
129: chomp();
130: print LOG "$_\n";
131: }
132: }
133:
134: sub print_and_log {
135: while ($_=shift) {
136: chomp();
137: print "$_\n";
138: print LOG "$_\n";
139: }
140: }
141:
142: sub get_user_selection {
143: my ($defaultrun) = @_;
144: my $do_action = 0;
145: my $choice = <STDIN>;
146: chomp($choice);
147: $choice =~ s/(^\s+|\s+$)//g;
148: my $yes = &mt('y');
149: if ($defaultrun) {
150: if (($choice eq '') || ($choice =~ /^\Q$yes\E/i)) {
151: $do_action = 1;
152: }
153: } else {
154: if ($choice =~ /^\Q$yes\E/i) {
155: $do_action = 1;
156: }
157: }
158: return $do_action;
159: }
160:
161: sub get_distro {
162: my ($distro,$gotprereqs,$updatecmd,$packagecmd,$installnow);
163: $packagecmd = '/bin/rpm -q LONCAPA-prerequisites ';
164: if (-e '/etc/redhat-release') {
165: open(IN,'</etc/redhat-release');
166: my $versionstring=<IN>;
167: chomp($versionstring);
168: close(IN);
169: if ($versionstring =~ /^Red Hat Linux release ([\d\.]+) /) {
170: my $version = $1;
171: if ($version=~/^7\./) {
172: $distro='redhat7';
173: } elsif ($version=~/^8\./) {
174: $distro='redhat8';
175: } elsif ($version=~/^9/) {
176: $distro='redhat9';
177: }
178: } elsif ($versionstring =~ /Fedora( Core)? release ([\d\.]+) /) {
179: my $version=$2;
180: if ($version - int($version) > .9) {
181: $distro = 'fedora'.(int($version)+1);
182: } else {
183: $distro = 'fedora'.int($version);
184: }
185: $updatecmd = 'yum install LONCAPA-prerequisites';
186: $installnow = 'yum -y install LONCAPA-prerequisites';
187: } elsif ($versionstring =~ /Red Hat Enterprise Linux [AE]S release ([\d\.]+) /) {
188: $distro = 'rhes'.$1;
189: $updatecmd = 'up2date -i LONCAPA-prerequisites';
190: } elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) {
191: $distro = 'rhes'.$1;
192: $updatecmd = 'yum install LONCAPA-prerequisites';
193: $installnow = 'yum -y install LONCAPA-prerequisites';
194: } elsif ($versionstring =~ /CentOS release (\d+)/) {
195: $distro = 'centos'.$1;
196: $updatecmd = 'yum install LONCAPA-prerequisites';
197: $installnow = 'yum -y install LONCAPA-prerequisites';
198: } elsif ($versionstring =~ /Scientific Linux SL release ([\d.]+) /) {
199: my $ver = $1;
200: $ver =~ s/\.\d+$//;
201: $distro = 'scientific'.$ver;
202: $updatecmd = 'yum install LONCAPA-prerequisites';
203: $installnow = 'yum -y install LONCAPA-prerequisites';
204: } else {
205: print &mt('Unable to interpret [_1] to determine system type.',
206: '/etc/redhat-release')."\n";
207: }
208: } elsif (-e '/etc/SuSE-release') {
209: open(IN,'</etc/SuSE-release');
210: my $versionstring=<IN>;
211: chomp($versionstring);
212: close(IN);
213: if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /i) {
214: $distro='sles'.$1;
215: if ($1 >= 10) {
216: $updatecmd = 'zypper install LONCAPA-prerequisites';
217: } else {
218: $updatecmd = 'yast -i LONCAPA-prerequisites';
219: }
220: } elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) {
221: $distro = 'suse'.$1;
222: $updatecmd = 'yast -i LONCAPA-preprequisites';
223: } elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) {
224: $distro = 'suse'.$1;
225: if ($1 >= 10.3 ) {
226: $updatecmd = 'zypper install LONCAPA-prerequisites';
227: } else {
228: $updatecmd = 'yast -i LONCAPA-prerequisites';
229: }
230: } else {
231: print &mt('Unable to interpret [_1] to determine system type.',
232: '/etc/SuSE-release')."\n";
233: }
234: } elsif (-e '/etc/issue') {
235: open(IN,'</etc/issue');
236: my $versionstring=<IN>;
237: chomp($versionstring);
238: close(IN);
239: $packagecmd = '/usr/bin/dpkg -l loncapa-prerequisites ';
240: $updatecmd = 'apt-get install loncapa-prerequisites';
241: if ($versionstring =~ /^Ubuntu (\d+)\.\d+/i) {
242: $distro = 'ubuntu'.$1;
243: $updatecmd = 'sudo apt-get install loncapa-prerequisites';
244: } elsif ($versionstring =~ /^Debian\s+GNU\/Linux\s+(\d+)\.\d+/i) {
245: $distro = 'debian'.$1;
246: } elsif (-e '/etc/debian_version') {
247: open(IN,'</etc/debian_version');
248: my $version=<IN>;
249: chomp($version);
250: close(IN);
251: if ($version =~ /^(\d+)\.\d+\.?\d*/) {
252: $distro='debian'.$1;
253: } else {
254: print &mt('Unable to interpret [_1] to determine system type.',
255: '/etc/debian_version')."\n";
256: }
257: } else {
258: print &mt('Unable to interpret [_1] to determine system type.',
259: '/etc/issue')."\n";
260: }
261: } elsif (-e '/etc/debian_version') {
262: open(IN,'</etc/debian_version');
263: my $version=<IN>;
264: chomp($version);
265: close(IN);
266: if ($version =~ /^(\d+)\.\d+\.?\d*/) {
267: $distro='debian'.$1;
268: $packagecmd = '/usr/bin/dpkg -l loncapa-prerequisites ';
269: $updatecmd = 'apt-get install loncapa-prerequisites';
270: } else {
271: print &mt('Unable to interpret [_1] to determine system type.',
272: '/etc/debian_version')."\n";
273: }
274: } else {
275: print &mt('Unknown installation: expecting a debian, ubuntu, suse, sles, redhat, fedora or scientific linux system.')."\n";
276: }
277: return ($distro,$packagecmd,$updatecmd,$installnow);
278: }
279:
280: sub check_prerequisites {
281: my ($packagecmd,$distro) = @_;
282: my $gotprereqs;
283: if ($packagecmd ne '') {
284: if (open(PIPE,"$packagecmd|")) {
285: if ($distro =~ /^(debian|ubuntu)/) {
286: my @lines = <PIPE>;
287: chomp(@lines);
288: foreach my $line (@lines) {
289: if ($line =~ /^ii\s+loncapa-prerequisites\s+([\w\.]+)/) {
290: $gotprereqs = $1;
291: }
292: }
293: } else {
294: my $line = <PIPE>;
295: chomp($line);
296: if ($line =~ /^LONCAPA-prerequisites\-([\d\-]+)\.(\w+)$/) {
297: $gotprereqs = $1;
298: }
299: }
300: close(PIPE);
301: } else {
302: print &mt('Error: could not determine if LONCAPA-prerequisites package is installed')."\n";
303: }
304: }
305: return $gotprereqs;
306: }
307:
308: sub check_required {
309: my ($instdir,$dsn) = @_;
310: my ($distro,$packagecmd,$updatecmd,$installnow) = &get_distro();
311: if ($distro eq '') {
312: return;
313: }
314: my $gotprereqs = &check_prerequisites($packagecmd,$distro);
315: if ($gotprereqs eq '') {
316: return ($distro,$gotprereqs,$packagecmd,$updatecmd,$installnow);
317: }
318: my ($mysqlon,$mysqlsetup,$dbh,$has_pass,$has_lcdb,%recommended,$downloadstatus,
1.5 ! raeburn 319: $filetouse,$production,$testing,$apachefw,$tostop);
1.1 raeburn 320: my $wwwuid = &uid_of_www();
321: my $wwwgid = getgrnam('www');
322: if (($wwwuid eq '') || ($wwwgid eq '')) {
323: $recommended{'wwwuser'} = 1;
324: }
325: unless( -e "/usr/local/sbin/pwauth") {
326: $recommended{'pwauth'} = 1;
327: }
328: $mysqlon = &check_mysql_running($distro);
329: if ($mysqlon) {
330: my $mysql_has_wwwuser = &check_mysql_wwwuser();
331: ($mysqlsetup,$has_pass,$dbh) =
332: &check_mysql_setup($instdir,$dsn);
333: if ($mysqlsetup eq 'noroot') {
334: $recommended{'mysqlperms'} = 1;
335: } else {
336: unless ($mysql_has_wwwuser) {
337: $recommended{'mysqlperms'} = 1;
338: }
339: }
340: if ($dbh) {
341: $has_lcdb = &check_loncapa_mysqldb($dbh);
342: }
343: unless ($has_lcdb) {
344: $recommended{'mysql'} = 1;
345: }
346: }
1.5 ! raeburn 347: ($recommended{'firewall'},$apachefw) = &chkfirewall($distro);
1.1 raeburn 348: ($recommended{'runlevels'},$tostop) = &chkconfig($distro);
349: $recommended{'apache'} = &chkapache($distro,$instdir);
350: $recommended{'stopsrvcs'} = &chksrvcs($distro,$tostop);
351: ($recommended{'download'},$downloadstatus,$filetouse,$production,$testing)
352: = &need_download();
353: return ($distro,$gotprereqs,$packagecmd,$updatecmd,$installnow,
354: \%recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,
1.5 ! raeburn 355: $filetouse,$production,$testing,$apachefw);
1.1 raeburn 356: }
357:
358: sub check_mysql_running {
359: my ($distro) = @_;
360: my $mysqldaemon ='mysqld';
361: if ($distro =~ /^(suse|sles|debian|ubuntu)/) {
362: $mysqldaemon = 'mysql';
363: }
1.4 raeburn 364: if (open(PIPE,"ps -ef |grep mysqld_safe |grep -v grep 2>&1 |")) {
1.1 raeburn 365: my $status = <PIPE>;
366: close(PIPE);
367: chomp($status);
1.4 raeburn 368: if ($status =~ /^root\s+\d+\s+/) {
1.1 raeburn 369: print_and_log(&mt('MySQL is running.')."\n");
370: return 1;
371: } else {
372: system("/etc/rc.d/init.d/$mysqldaemon start");
373: print_and_log(&mt('Waiting for MySQL to start.')."\n");
374: sleep 5;
375: if (open (PIPE, "/etc/init.d/$mysqldaemon 2>&1 |")) {
376: my $status = <PIPE>;
377: close(PIPE);
378: chomp($status);
379: if ($status =~ /\(pid\s+\d\)/) {
380: print_and_log(&mt('MySQL is running.')."\n");
381: return 1;
382: } else {
383: print_and_log(&mt('Unable to start MySQL.')."\n");
384: }
385: } else {
386: print_and_log(&mt('Unable to start MySQL.')."\n");
387: }
388: }
389: } else {
390: print &mt('Could not determine if MySQL is running.')."\n";
391: }
392: return;
393: }
394:
395: sub chkconfig {
396: my ($distro) = @_;
397: my (%needfix,%tostop);
398: my $checker_bin = '/sbin/chkconfig';
399: my $mysqldaemon ='mysqld';
400: my $webserver = 'httpd';
401: my $cupsdaemon = 'cups';
1.5 ! raeburn 402: my $ntpdaemon = 'ntpd';
1.1 raeburn 403: my @runlevels = qw/3 4 5/;
404: my @norunlevels = qw/0 1 6/;
405: if ($distro =~ /^(suse|sles)/) {
406: @runlevels = qw/3 5/;
407: @norunlevels = qw/0 2 1 6/;
408: $mysqldaemon = 'mysql';
409: $webserver = 'apache2';
410: if ($distro =~ /^(suse|sles)9/) {
411: $webserver = 'apache';
412: }
413: } elsif ($distro =~ /^(debian|ubuntu)/) {
414: @runlevels = qw/2 3 4 5/;
415: @norunlevels = qw/0 1 6/;
416: $checker_bin = '/usr/sbin/sysv-rc-conf';
417: $mysqldaemon = 'mysql';
418: $webserver = 'apache2';
1.5 ! raeburn 419: $ntpdaemon = 'ntp';
1.1 raeburn 420: }
421: if (! -x $checker_bin) {
422: print &mt('Could not check runlevel status for MySQL or Apache.')."\n";
423: return;
424: }
425: my $rlstr = join('',@runlevels);
426: my $nrlstr = join('',@norunlevels);
1.5 ! raeburn 427: foreach my $type ('apache','mysql','ntp','cups') {
1.1 raeburn 428: my $service;
429: if ($type eq 'apache') {
430: $service = $webserver;
431: } elsif ($type eq 'mysql') {
432: $service = $mysqldaemon;
433: } elsif ($type eq 'cups') {
434: $service = $cupsdaemon;
1.5 ! raeburn 435: } elsif ($type eq 'ntp') {
! 436: $service = $ntpdaemon;
1.1 raeburn 437: }
438: my $command = $checker_bin.' --list '.$service;
439: my $results = `$command`;
440: my $tofix;
441: if ($results eq '') {
442: if (($type eq 'apache') || ($type eq 'mysql')) {
443: if ($distro =~ /^(debian|ubuntu)/) {
444: $tofix = "$checker_bin --level $nrlstr $service off\n";
445: } else {
446: $tofix = "$checker_bin --add $service\n";
447: }
448: }
449: } else {
450: my %curr_runlevels;
451: for (my $rl=0; $rl<=6; $rl++) {
452: if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; }
453: }
1.5 ! raeburn 454: if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
1.1 raeburn 455: my $warning;
456: foreach my $rl (@runlevels) {
457: if (!exists($curr_runlevels{$rl})) {
458: $warning = 1;
459: }
460: }
461: if ($warning) {
462: $tofix = "$checker_bin --level $rlstr $service on\n";
463: }
464: } elsif (keys(%curr_runlevels) > 0) {
465: $tostop{$type} = 1;
466: }
467: }
468: if ($tofix) {
469: $needfix{$type} = $tofix;
1.5 ! raeburn 470: }
1.1 raeburn 471: }
472: if ($distro =~ /^(suse|sles)([\d\.]+)$/) {
473: my $name = $1;
474: my $version = $2;
475: my ($major,$minor);
476: if ($name eq 'suse') {
477: ($major,$minor) = split(/\./,$version);
478: } else {
479: $major = $version;
480: }
481: if ($major > 10) {
482: $needfix{'insserv'} = &check_SuSEfirewall2_setup();
483: }
484: }
485: return (\%needfix,\%tostop);
486: }
487:
488: sub chkfirewall {
1.5 ! raeburn 489: my ($distro) = @_;
1.1 raeburn 490: my $configfirewall = 1;
491: my %ports = (
492: http => 80,
493: https => 443,
494: );
1.5 ! raeburn 495: my %activefw;
1.1 raeburn 496: if (&firewall_is_active()) {
497: my $iptables = &get_pathto_iptables();
498: if ($iptables eq '') {
499: print &mt('Firewall not checked as path to iptables not determined.')."\n";
500: } else {
1.5 ! raeburn 501: my @fwchains = &get_fw_chains($iptables,$distro);
1.1 raeburn 502: if (@fwchains) {
503: foreach my $service ('http','https') {
504: foreach my $fwchain (@fwchains) {
505: if (&firewall_is_port_open($iptables,$fwchain,$ports{$service})) {
506: $activefw{$service} = 1;
507: last;
508: }
509: }
510: }
511: if ($activefw{'http'}) {
512: $configfirewall = 0;
513: }
514: } else {
515: print &mt('Firewall not checked as iptables Chains not identified.')."\n";
516: }
517: }
518: } else {
519: print &mt('Firewall not enabled.')."\n";
520: }
1.5 ! raeburn 521: return ($configfirewall,\%activefw);
1.1 raeburn 522: }
523:
524: sub chkapache {
525: my ($distro,$instdir) = @_;
526: my $fixapache = 1;
527: if ($distro =~ /^(debian|ubuntu)/) {
528: if (!-e "$instdir/apache2.conf") {
529: $fixapache = 0;
530: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
531: } elsif ((-e "/etc/apache2/sites-available/loncapa") && (-e "$instdir/apache2.conf")) {
532: if (open(PIPE, "diff --brief $instdir/apache2.conf /etc/apache2/sites-available/loncapa |")) {
533: my $diffres = <PIPE>;
534: close(PIPE);
535: chomp($diffres);
536: unless ($diffres) {
537: $fixapache = 0;
538: }
539: }
540: }
541: } elsif ($distro =~ /^(?:suse|sles)([\d\.]+)$/) {
542: my $apache = 'apache';
543: if ($1 >= 10) {
544: my $apache = 'apache2';
545: }
546: if (!-e "$instdir/default-server.conf") {
547: $fixapache = 0;
548: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
549: } elsif ((-e "/etc/$apache/default-server.conf") && (-e "$instdir/default-server.conf")) {
550: if (open(PIPE, "diff --brief $instdir/default-server.conf /etc/$apache/default-server.conf |")) {
551: my $diffres = <PIPE>;
552: close(PIPE);
553: chomp($diffres);
554: unless ($diffres) {
555: $fixapache = 0;
556: }
557: }
558: }
559: } else {
560: if (!-e "$instdir/httpd.conf") {
561: $fixapache = 0;
562: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
563: } elsif ((-e "/etc/httpd/conf/httpd.conf") && (-e "$instdir/httpd.conf")) {
564: if (open(PIPE, "diff --brief $instdir/httpd.conf /etc/httpd/conf/httpd.conf |")) {
565: my $diffres = <PIPE>;
566: close(PIPE);
567: chomp($diffres);
568: unless ($diffres) {
569: $fixapache = 0;
570: }
571: }
572: }
573: }
574: return $fixapache;
575: }
576:
577: sub chksrvcs {
578: my ($distro,$tostop) = @_;
579: my %stopsrvcs;
580: if (ref($tostop) eq 'HASH') {
581: %stopsrvcs = %{$tostop};
582: }
583: foreach my $service ('cups') {
584: next if (exists($stopsrvcs{$service}));
585: my $daemon = $service;
586: if ($service eq 'cups') {
587: $daemon = 'cupsd';
588: }
589: my $cmd = "ps -ef |grep '$daemon' |grep -v grep";
590: if (open(PIPE,'-|',$cmd)) {
591: my $daemonrunning = <PIPE>;
592: chomp($daemonrunning);
593: close(PIPE);
594: if ($daemonrunning) {
595: $stopsrvcs{$service} = 1;
596: }
597: }
598: }
599: return \%stopsrvcs;
600: }
601:
602: sub need_download {
603: my $needs_download = 1;
604: my ($production,$testing,$stdsizes) = &download_versionslist();
605: my ($rootdir,$localcurrent,$localtesting,%tarball,%localsize,%bymodtime,
606: %bysize,$filetouse,$downloadstatus);
607: $rootdir = '/root';
608: if (opendir(my $dir,"$rootdir")) {
609: my (@lcdownloads,$version);
610: foreach my $file (readdir($dir)) {
611: if ($file =~ /^loncapa\-([\w\-.]+)\.tar\.gz$/) {
612: $version = $1;
613: } else {
614: next;
615: }
616: if (ref($stdsizes) eq 'HASH') {
617: if ($version eq 'current') {
618: my @stats = stat("$rootdir/$file");
619: $localcurrent = $stats[7];
1.4 raeburn 620: if ($localcurrent == $stdsizes->{$production}) {
1.1 raeburn 621: $needs_download = 0;
622: $filetouse = $file;
623: }
624: } elsif ($version eq 'testing') {
625: my @stats = stat("$rootdir/$file");
626: $localtesting = $stats[7];
1.4 raeburn 627: if ($localtesting == $stdsizes->{$testing}) {
1.1 raeburn 628: $needs_download = 0;
629: $filetouse = $file;
630: }
631: }
632: }
633: $tarball{$version} = $file;
634: push(@lcdownloads,$version);
635: }
636: if ($needs_download) {
637: if (@lcdownloads > 0) {
638: foreach my $version (@lcdownloads) {
639: my @stats = stat("$rootdir/$tarball{$version}");
640: my $mtime = $stats[9];
641: $localsize{$version} = $stats[7];
642: if ($mtime) {
643: push(@{$bymodtime{$mtime}},$version);
644: }
645: if ($localsize{$version}) {
646: push(@{$bysize{$localsize{$version}}},$version);
647: }
648: }
649: if ($testing) {
650: if (exists($localsize{$testing})) {
651: if ($stdsizes->{$testing} == $localsize{$testing}) {
652: $needs_download = 0;
653: $filetouse = 'loncapa-'.$testing.'.tar.gz';
654: }
655: }
656: }
657: if ($needs_download) {
658: if ($production) {
659: if (exists($localsize{$production})) {
660: if ($stdsizes->{$production} == $localsize{$production}) {
661: $needs_download = 0;
662: $filetouse = 'loncapa-'.$production.'.tar.gz';
663: }
664: }
665: }
666: }
667: if ($needs_download) {
668: my @sorted = sort { $b <=> $a } keys(%bymodtime);
669: my $newest = $sorted[0];
670: if (ref($bymodtime{$newest}) eq 'ARRAY') {
671: $downloadstatus =
672: "Latest LON-CAPA source download in $rootdir is: ".
673: join(',',@{$bymodtime{$newest}})." (downloaded ".
674: localtime($newest).")\n";
675: }
676: } else {
677: $downloadstatus =
678: "The $rootdir directory already contains the latest LON-CAPA version:".
679: "\n".$filetouse."\n"."which can be used for installation.\n";
680: }
681: } else {
682: $downloadstatus = "The $rootdir directory does not appear to contain any downloaded LON-CAPA source code files which can be used for installation.\n";
683: }
684: }
685: } else {
686: $downloadstatus = "Could not open $rootdir directory to look for existing downloads of LON-CAPA source code.\n";
687: }
688: return ($needs_download,$downloadstatus,$filetouse,$production,$testing);
689: }
690:
691: sub check_mysql_setup {
692: my ($instdir,$dsn) = @_;
693: my ($mysqlsetup,$has_pass);
694: my $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0});
695: if ($dbh) {
696: $mysqlsetup = 'noroot';
697: } elsif ($DBI::err =~ /1045/) {
698: $has_pass = 1;
699: }
700: if ($has_pass) {
701: print &mt('You have already set a root password for the MySQL database.')."\n";
702: my $currpass = &get_mysql_password(&mt('Please enter the password now'));
703: $dbh = DBI->connect($dsn,'root',$currpass,{'PrintError'=>0});
704: if ($dbh) {
705: $mysqlsetup = 'rootok';
706: print_and_log(&mt('Password accepted.')."\n");
707: } else {
708: $mysqlsetup = 'rootfail';
709: print_and_log(&mt('Problem accessing MySQL.')."\n");
710: if ($DBI::err =~ /1045/) {
711: print_and_log(&mt('Perhaps the password was incorrect?')."\n");
712: print &mt('Try again?').' ';
713: $currpass = &get_mysql_password(&mt('Re-enter password now'));
714: $dbh = DBI->connect($dsn,'root',$currpass,{'PrintError'=>0});
715: if ($dbh) {
716: $mysqlsetup = 'rootok';
717: print_and_log(&mt('Password accepted.')."\n");
718: } else {
719: if ($DBI::err =~ /1045/) {
720: print_and_log(&mt('Incorrect password.')."\n");
721: }
722: }
723: }
724: }
725: } elsif ($mysqlsetup ne 'noroot') {
726: print_and_log(&mt('Problem accessing MySQL.')."\n");
727: $mysqlsetup = 'rootfail';
728: }
729: return ($mysqlsetup,$has_pass,$dbh);
730: }
731:
732: sub check_mysql_wwwuser {
733: my $mysql_wwwuser;
734: my $dbhn = DBI->connect("DBI:mysql:database=information_schema",'www','localhostkey');
735: if ($dbhn) {
736: $mysql_wwwuser = 1;
737: $dbhn->disconnect;
738: }
739: return $mysql_wwwuser;
740: }
741:
742: sub check_loncapa_mysqldb {
743: my ($dbh) = @_;
744: my $has_lcdb;
745: if (ref($dbh)) {
746: my $sth = $dbh->prepare("SHOW DATABASES");
747: $sth->execute();
748: while (my $dbname = $sth->fetchrow_array) {
749: if ($dbname eq 'loncapa') {
750: $has_lcdb = 1;
751: last;
752: }
753: }
754: $sth->finish();
755: }
756: return $has_lcdb;
757: }
758:
759: sub get_pathto_iptables {
760: my $iptables;
761: if (-e '/sbin/iptables') {
762: $iptables = '/sbin/iptables';
763: } elsif (-e '/usr/sbin/iptables') {
764: $iptables = '/usr/sbin/iptables';
765: } else {
766: print &mt('Unable to find iptables command.')."\n";
767: }
768: return $iptables;
769: }
770:
771: sub firewall_is_active {
772: if (-e '/proc/net/ip_tables_names') {
773: return 1;
774: } else {
775: return 0;
776: }
777: }
778:
779: sub get_fw_chains {
1.5 ! raeburn 780: my ($iptables,$distro) = @_;
1.1 raeburn 781: my @fw_chains;
782: my $suse_config = "/etc/sysconfig/SuSEfirewall2";
783: my $ubuntu_config = "/etc/ufw/ufw.conf";
784: if (-e $suse_config) {
785: push(@fw_chains,'input_ext');
786: } else {
787: my @posschains;
788: if (-e $ubuntu_config) {
789: @posschains = ('ufw-user-input','INPUT');
1.5 ! raeburn 790: } elsif ($distro =~ /^debian5/) {
! 791: @posschains = ('INPUT');
1.1 raeburn 792: } else {
793: @posschains = ('RH-Firewall-1-INPUT','INPUT');
794: if (!-e '/etc/sysconfig/iptables') {
795: if (!-e '/var/lib/iptables') {
796: print &mt('Unable to find iptables file containing static definitions.')."\n";
797: }
798: push(@fw_chains,'RH-Firewall-1-INPUT');
799: }
800: }
801: if ($iptables eq '') {
802: $iptables = &get_pathto_iptables();
803: }
804: my %counts;
805: if (open(PIPE,"$iptables -L -n |")) {
806: while(<PIPE>) {
807: foreach my $chain (@posschains) {
808: if (/(\Q$chain\E)/) {
809: $counts{$1} ++;
810: }
811: }
812: }
813: close(PIPE);
814: }
815: foreach my $fw_chain (@posschains) {
816: if ($counts{$fw_chain}) {
817: unless(grep(/^\Q$fw_chain\E$/,@fw_chains)) {
818: push(@fw_chains,$fw_chain);
819: }
820: }
821: }
822: }
823: return @fw_chains;
824: }
825:
826: sub firewall_is_port_open {
827: my ($iptables,$fw_chain,$port) = @_;
828: # returns 1 if the firewall port is open, 0 if not.
829: #
830: # check if firewall is active or installed
831: return if (! &firewall_is_active());
832: my $count = 0;
833: if (open(PIPE,"$iptables -L $fw_chain -n |")) {
834: while(<PIPE>) {
835: if (/tcp dpt\:\Q$port\E/) {
836: $count ++;
837: last;
838: }
839: }
840: close(PIPE);
841: } else {
842: print &mt('Firewall status not checked: unable to run [_1].','iptables -L')."\n";
843: }
844: return $count;
845: }
846:
847: sub get_mysql_password {
848: my ($prompt) = @_;
849: local $| = 1;
850: print $prompt.': ';
851: my $newpasswd = '';
852: ReadMode 'raw';
853: my $key;
854: while(ord($key = ReadKey(0)) != 10) {
855: if(ord($key) == 127 || ord($key) == 8) {
856: chop($newpasswd);
857: print "\b \b";
858: } elsif(!ord($key) < 32) {
859: $newpasswd .= $key;
860: print '*';
861: }
862: }
863: ReadMode 'normal';
864: print "\n";
865: return $newpasswd;
866: }
867:
868: sub check_SuSEfirewall2_setup {
869: my ($instdir) = @_;
870: my $need_override = 1;
871: if ((-e "/etc/insserv/overrides/SuSEfirewall2_setup") && (-e "$instdir/SuSEfirewall2_setup")) {
872: if (open(PIPE, "diff --brief $instdir/SuSEfirewall2_setup /etc/insserv/overrides/SuSEfirewall2_setup |")) {
873: my $diffres = <PIPE>;
874: close(PIPE);
875: chomp($diffres);
876: unless ($diffres) {
877: $need_override = 0;
878: }
879: }
880: }
881: return $need_override;
882: }
883:
884: sub download_versionslist {
885: my ($production,$testing,%sizes);
886: if (-e "latest.txt") {
887: unlink("latest.txt");
888: }
889: my $rtncode = system("wget http://install.loncapa.org/versions/latest.txt ".
890: "> /dev/null 2>&1");
891: if (!$rtncode) {
892: if (open(my $fh,"<latest.txt")) {
893: my @info = <$fh>;
894: close($fh);
895: foreach my $line (@info) {
896: chomp();
897: if ($line =~ /^\QLATEST-IS: \E([\w\-.]+):(\d+)$/) {
898: $production = $1;
899: $sizes{$1} = $2;
900: } elsif ($line =~ /^LATEST-TESTING-IS: \E([\w\-.]+):(\d+)$/) {
901: $testing = $1;
902: $sizes{$1} = $2;
903: }
904: }
905: }
906: }
907: return ($production,$testing,\%sizes);
908: }
909:
910: #
911: # End helper routines.
912: # Main script starts here
913: #
914:
915: print "
916: ********************************************************************
917:
918: ".&mt('Welcome to LON-CAPA')."
919:
920: ".&mt('This script will configure your system for installation of LON-CAPA.')."
921:
922: ********************************************************************
923:
924: ".&mt('The following actions are available:')."
925:
1.4 raeburn 926: ".&mt('1.')." ".&mt('Create the www user/group.')."
1.1 raeburn 927: ".&mt('This is the user/group ownership under which Apache child processes run.')."
928: ".&mt('It also owns most directories within the /home/httpd directory.')."
929: ".&mt('This directory is where most LON-CAPA files and directories are stored.')."
1.4 raeburn 930: ".&mt('2.')." ".&mt('Install the package LON-CAPA uses to authenticate users.')."
931: ".&mt('3.')." ".&mt('Set-up the MySQL database.')."
932: ".&mt('4.')." ".&mt('Set-up MySQL permissions.')."
933: ".&mt('5.')." ".&mt('Configure Apache web server.')."
934: ".&mt('6.')." ".&mt('Configure start-up of services.')."
935: ".&mt('7.')." ".&mt('Check firewall settings.')."
936: ".&mt('8.')." ".&mt('Stop services not used by LON-CAPA,')."
1.1 raeburn 937: ".&mt('i.e., services for a print server: [_1] daemon.',"'cups'")."
1.4 raeburn 938: ".&mt('9.')." ".&mt('Download LON-CAPA source code in readiness for installation.')."
1.1 raeburn 939:
940: ".&mt('Typically, you will run this script only once, when you first install LON-CAPA.')."
941:
942: ".&mt('The script will analyze your system to determine which actions are recommended.')."
943: ".&mt('The script will then prompt you to choose the actions you would like taken.')."
944:
945: ".&mt('For each the recommended action will be selected if you hit Enter/Return.')."
946: ".&mt('To override the default, type the lower case option from the two options listed.')."
947: ".&mt('So, if the default is "yes", ~[Y/n~] will be shown -- type n to override.')."
948: ".&mt('Whereas if the default is "no", ~[y/N~] will be shown -- type y to override.')."
949:
950: ".&mt('To accept the default, simply hit Enter/Return on your keyboard.')."
951: ".&mt('Otherwise type: y or n then hit the Enter/Return key.')."
952:
953: ".&mt('Once a choice has been entered for all nine actions, required changes will be made.')."
954: ".&mt('Feedback will be displayed on screen, and also stored in: [_1].','loncapa_install.log')."
955:
956: ".&mt('Continue? ~[Y/n~] ');
957:
958: my $go_on = &get_user_selection(1);
959: if (!$go_on) {
960: exit;
961: }
962:
963: my $instdir = `pwd`;
964: chomp($instdir);
965:
966: my %callsub;
967: my @actions = ('wwwuser','pwauth','mysql','mysqlperms','apache',
968: 'runlevels','firewall','stopsrvcs','download');
969: my %prompts = &texthash(
970: wwwuser => "Create the 'www' user?",
971: pwauth => 'Install the package LON-CAPA uses to authenticate users?',
972: mysql => 'Set-up the MySQL database?',
973: mysqlperms => 'Set-up MySQL permissions?',
974: apache => 'Configure Apache web server?',
975: runlevels => 'Set overrides for start-up order of services?',
976: firewall => 'Configure firewall settings for Apache',
977: stopsrvcs => 'Stop extra services not required on a LON-CAPA server?',
978: download => 'Download LON-CAPA source code in readiness for installation?',
979: );
980:
981: print "\n".&mt('Checking system status ...')."\n";
982:
983: my $dsn = "DBI:mysql:database=mysql";
984: my ($distro,$gotprereqs,$packagecmd,$updatecmd,$installnow,$recommended,
985: $dbh,$has_pass,$has_lcdb,$downloadstatus,$filetouse,$production,
1.5 ! raeburn 986: $testing,$apachefw) = &check_required($instdir,$dsn);
1.1 raeburn 987: if ($distro eq '') {
988: print "\n".&mt('Linux distribution could not be verified as a supported distribution.')."\n".
989: &mt('The following are supported: [_1].',
990: 'CentOS, RedHat Enterprise, Fedora, Scientific Linux, '.
991: 'openSuSE, SLES, Ubuntu LTS, Debian')."\n\n".
992: &mt('Stopping execution.')."\n";
993: exit;
994: }
995: if (!$gotprereqs) {
996: print "\n".&mt('The LONCAPA-prequisites package is not installed.')."\n".
997: &mt('The following command can be used to install the package (and dependencies):')."\n\n".
998: $updatecmd."\n\n";
999: if ($installnow eq '') {
1000: print &mt('Stopping execution.')."\n";
1001: exit;
1002: } else {
1003: print &mt('Run command? ~[Y/n~]');
1004: my $install_prereq = &get_user_selection(1);
1005: if ($install_prereq) {
1006: if (open(PIPE,'|-',$installnow)) {
1007: close(PIPE);
1008: $gotprereqs = &check_prerequisites($packagecmd,$distro);
1009: if (!$gotprereqs) {
1010: print &mt('The LONCAPA-prequisites package is not installed.')."\n".
1011: &mt('Stopping execution.')."\n";
1012: exit;
1013: } else {
1014: ($distro,$gotprereqs,$packagecmd,$updatecmd,$installnow,
1015: $recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,
1.5 ! raeburn 1016: $filetouse,$production,$testing,$apachefw) =
! 1017: &check_required($instdir,$dsn);
1.1 raeburn 1018: }
1019: } else {
1020: print &mt('Failed to run command to install LONCAPA-prequisites')."\n";
1021: exit;
1022: }
1023: } else {
1024: print &mt('Stopping execution.')."\n";
1025: exit;
1026: }
1027: }
1028: }
1029: unless (ref($recommended) eq 'HASH') {
1030: print "\n".&mt('An error occurred determining which actions are recommended.')."\n\n".
1031: &mt('Stopping execution.')."\n";
1032: exit;
1033: }
1034:
1035: print "\n";
1036: my $num = 0;
1037: foreach my $action (@actions) {
1038: $num ++;
1039: my ($yesno,$defaultrun);
1040: if (ref($recommended) eq 'HASH') {
1.4 raeburn 1041: if (($action eq 'runlevels') || ($action eq 'stopsrvcs')) {
1.1 raeburn 1042: $yesno = '[y/N]';
1043: if (ref($recommended->{$action}) eq 'HASH') {
1044: if (keys(%{$recommended->{$action}}) > 0) {
1045: $yesno = &mt('~[Y/n~]');
1046: $defaultrun = 1;
1047: }
1048: }
1049: } else {
1050: if ($action eq 'download') {
1051: if ($downloadstatus) {
1052: print "\n$downloadstatus\n";
1053: }
1054: }
1055: if ($recommended->{$action}) {
1056: $yesno = mt('~[Y/n~]');
1057: $defaultrun = 1;
1058: } else {
1059: $yesno = &mt('~[y/N~]');
1060: }
1061: }
1062: print $num.'. '.$prompts{$action}." $yesno ";
1063: $callsub{$action} = &get_user_selection($defaultrun);
1064: }
1065: }
1066:
1067: my $lctarball = 'loncapa-current.tar.gz';
1068: my $sourcetarball = $lctarball;
1069: if ($callsub{'download'}) {
1070: my ($production,$testing,$sizes) = &download_versionslist();
1071: if ($production && $testing) {
1072: if ($production ne $testing) {
1073: print &mt('Two recent LON-CAPA releases are available: ')."\n".
1.3 raeburn 1074: &mt('1.').' '.&mt('A production release - version: [_1].',$production)."\n".
1075: &mt('2.').' '.&mt('A testing release - version: [_1].',$testing)."\n\n".
1.1 raeburn 1076: &mt('Download the production release? ~[Y/n~]');
1077: if (&get_user_selection(1)) {
1.4 raeburn 1078: $sourcetarball = 'loncapa-'.$production.'.tar.gz';
1.1 raeburn 1079: } else {
1080: print "\n".&mt('Download the testing release? ~[Y/n~]');
1081: if (&get_user_selection(1)) {
1.4 raeburn 1082: $sourcetarball = 'loncapa-'.$testing.'.tar.gz';
1.1 raeburn 1083: }
1084: }
1085: }
1086: } elsif ($production) {
1087: print &mt('The most recent LON-CAPA release is version: [_1].',$production)."\n".
1088: &mt('Download the production release? ~[Y/n~]');
1089: if (&get_user_selection(1)) {
1090: $sourcetarball = $production.'tar.gz';
1091: }
1092: }
1093: } elsif ($filetouse ne '') {
1094: $sourcetarball = $filetouse;
1095: }
1096:
1097: print_and_log("\n");
1098:
1099: # Each action: report if skipping, or perform action and provide feedback.
1100: if ($callsub{'wwwuser'}) {
1101: &setup_www();
1102: } else {
1103: &print_and_log(&mt('Skipping creation of user [_1].',"'www'")."\n");
1104: }
1105:
1106: if ($callsub{'pwauth'}) {
1.4 raeburn 1107: &build_and_install_mod_auth_external($instdir);
1.1 raeburn 1108: } else {
1109: &print_and_log(&mt('Skipping [_1] installation.',"'pwauth'")."\n");
1110: }
1111:
1112: if ($callsub{'mysql'}) {
1113: if ($dbh) {
1114: &setup_mysql($callsub{'mysqlperms'},$distro,$dbh,$has_pass,$has_lcdb);
1115: } else {
1116: print &mt('Unable to configure MySQL because access is denied.')."\n";
1117: }
1118: } else {
1119: &print_and_log(&mt('Skipping configuration of MySQL.')."\n");
1120: if ($callsub{'mysqlperms'}) {
1121: if ($dbh) {
1122: &setup_mysql_permissions($dbh,$has_pass);
1123: } else {
1124: print &mt('Unable to configure MySQL because access is denied.')."\n";
1125: }
1126: } else {
1127: &print_and_log(&mt('Skipping MySQL permissions setup.')."\n");
1128: }
1129: }
1130:
1131: if ($dbh) {
1132: if (!$dbh->disconnect) {
1133: &print_and_log(&mt('Failed to disconnect from MySQL:')."\n".
1134: $dbh->errstr);
1135: }
1136: }
1137:
1138: if ($callsub{'apache'}) {
1139: if ($distro =~ /^(suse|sles)/) {
1140: ©_apache2_suseconf($instdir);
1141: } elsif ($distro =~ /^(debian|ubuntu)/) {
1142: ©_apache2_debconf($instdir);
1143: } else {
1144: ©_httpd_conf($instdir);
1145: }
1146: } else {
1147: print_and_log(&mt('Skipping configuration of Apache web server.')."\n");
1148: }
1149:
1150: if ($callsub{'runlevels'}) {
1151: my $count = 0;
1152: if (ref($recommended) eq 'HASH') {
1153: if (ref($recommended->{'runlevels'}) eq 'HASH') {
1154: foreach my $type (keys(%{$recommended->{'runlevels'}})) {
1155: next if ($type eq 'insserv');
1156: $count ++;
1157: my $command = $recommended->{'runlevels'}{$type};
1158: if ($command ne '') {
1159: print_and_log(&mt('Runlevel update command run: [_1].',$command)."\n");
1160: system($command);
1161: }
1162: }
1163: if (!$count) {
1164: print_and_log(&mt('No runlevel updates required.')."\n");
1165: }
1166: }
1167: }
1168: &update_SuSEfirewall2_setup($instdir);
1169: } else {
1170: &print_and_log(&mt('Skipping setting override for start-up order of services.')."\n");
1171: }
1172:
1173: if ($callsub{'firewall'}) {
1174: if ($distro =~ /^(suse|sles)/) {
1.5 ! raeburn 1175: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
! 1176: 'yast -- Security and Users -> Firewall -> Interfaces',
! 1177: 'ssh, http, https')."\n";
! 1178: } elsif ($distro =~ /^(debian|ubuntu)(\d+)/) {
! 1179: if (($1 eq 'ubuntu') || ($2 > 5)) {
! 1180: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
! 1181: 'ufw','ssh, http, https')."\n";
! 1182: } else {
! 1183: my $fwadded = &get_iptables_rules($distro,$instdir,$apachefw);
! 1184: if ($fwadded) {
! 1185: print &mt('Enable firewall? ~[Y/n~]');
! 1186: my $enable_iptables = &get_user_selection(1);
! 1187: if ($enable_iptables) {
! 1188: system('/etc/network/if-pre-up.d/iptables');
! 1189: print &mt('Firewall enabled using rules defined in [_1].',
! 1190: '/etc/iptables.loncapa.rules');
! 1191: }
! 1192: }
! 1193: }
1.1 raeburn 1194: } else {
1.5 ! raeburn 1195: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
! 1196: 'setup -- Firewall confiuration -> Customize',
! 1197: 'ssh, http, https')."\n";
1.1 raeburn 1198: }
1199: } else {
1.5 ! raeburn 1200: &print_and_log(&mt('Skipping Firewall configuration.')."\n");
1.1 raeburn 1201: }
1202:
1203: if ($callsub{'stopsrvcs'}) {
1204: &kill_extra_services($distro,$recommended->{'stopsrvcs'});
1205: } else {
1.5 ! raeburn 1206: &print_and_log(&mt('Skipping stopping unnecessary service ([_1] daemon).',"'cups'")."\n");
1.1 raeburn 1207: }
1208:
1209: my ($have_tarball,$updateshown);
1210: if ($callsub{'download'}) {
1211: ($have_tarball,$updateshown) = &download_loncapa($instdir,$sourcetarball);
1212: } else {
1213: print_and_log(&mt('Skipping download of LON-CAPA tar file.')."\n\n");
1214: print &mt('LON-CAPA is available for download from: [_1]',
1215: 'http://install.loncapa.org/')."\n";
1216: if (!-e '/etc/loncapa-release') {
1217: &print_and_log(&mt('LON-CAPA is not yet installed on your system.').
1218: "\n\n".
1219: &mt('You may retrieve the source for LON-CAPA by executing:')."\n".
1220: "wget http://install.loncapa.org/versions/$lctarball\n");
1221: } else {
1222: my $currentversion;
1223: if (open(my $fh,"</etc/loncapa-release")) {
1224: my $version = <$fh>;
1225: chomp($version);
1226: if ($version =~ /^\QLON-CAPA release \E([\w\-.]+)$/) {
1227: $currentversion = $1;
1228: }
1229: }
1230: if ($currentversion ne '') {
1231: print &mt('Version of LON-CAPA currently installed on this server is: [_1].',
1232: $currentversion),"\n";
1233: if ($production) {
1234: print &mt('The latest production release of LON-CAPA is [_1].',$production)."\n";
1235: }
1236: if ($testing) {
1237: print &mt('The latest testing release of LON-CAPA is [_1].',$testing)."\n";
1238: }
1239: }
1240: }
1241: if ($filetouse ne '') {
1242: $have_tarball = 1;
1243: }
1244: }
1245:
1246: print "\n".&mt('Requested configuration complete.')."\n\n";
1247: my $apachename;
1248: if ($have_tarball && !$updateshown) {
1249: my ($lcdir) = ($sourcetarball =~ /^([\w.\-]+)\.tar.gz$/);
1250: if (!-e '/etc/loncapa-release') {
1251: print &mt('If you are now ready to install LON-CAPA, enter the following commands:')."\n\n";
1252: } else {
1253: print &mt('If you are now ready to update LON-CAPA, enter the following commands:')."\n\n".
1254: "/etc/init.d/loncontrol stop\n";
1255: if ($distro =~ /^(suse|sles|debian|ubuntu)([\d.]+)/) {
1256: if (($1 eq 'suse') && ($2 < 10)) {
1257: $apachename = 'apache';
1258: } else {
1259: $apachename = 'apache2';
1260: }
1261: } else {
1262: $apachename = 'httpd';
1263: }
1264: print "/etc/init.d/$apachename stop\n";
1265: }
1266: print "cd /root\n".
1267: "tar zxf $sourcetarball\n".
1268: "cd $lcdir\n".
1269: "./UPDATE\n";
1270: if (-e '/etc/loncapa-release') {
1271: print "/etc/init.d/loncontrol start\n";
1272: print "/etc/init.d/$apachename start\n";
1273: }
1274: }
1275: exit;
1276:
1277: #
1278: # End main script
1279: #
1280:
1281: #
1282: # Routines for the actions
1283: #
1284:
1285: sub setup_www {
1286: ##
1287: ## Set up www
1288: ##
1289: print_and_log(&mt('Creating user [_1]',"'www'")."\n");
1290: # -- Add group
1291:
1292: my $status = `/usr/sbin/groupadd www`;
1293: if ($status =~ /\QGroup `www' already exists.\E/) {
1294: print &mt('Group [_1] already exists.',"'www'")."\n";
1295: } elsif ($status ne '') {
1296: print &mt('Unable to add group [_1].',"'www'")."\n";
1297: }
1298:
1299: my $gid = getgrnam('www');
1300:
1301: if (open (PIPE, "/usr/sbin/useradd -c LONCAPA -g $gid www 2>&1 |")) {
1302: $status = <PIPE>;
1303: close(PIPE);
1304: chomp($status);
1305: if ($status =~ /\QAccount `www' already exists.\E/) {
1306: print &mt('Account [_1] already exists.',"'www'")."\n";
1307: } elsif ($status ne '') {
1308: print &mt('Unable to add user [_1].',"'www'")."\n";
1309: }
1310: } else {
1311: print &mt('Unable to run command to add user [_1].',"'www'")."\n";
1312: }
1313:
1314: my $uid = &uid_of_www();
1315: if (($gid ne '') && ($uid ne '')) {
1316: if (!-e '/home/www') {
1317: mkdir('/home/www',0755);
1318: system('chown www:www /home/www');
1319: }
1320: }
1321: writelog ($status);
1322: }
1323:
1324: sub uid_of_www {
1325: my ($num) = (getpwnam('www'))[2];
1326: return $num;
1327: }
1328:
1329: sub build_and_install_mod_auth_external {
1330: my ($instdir) = @_;
1331: my $num = &uid_of_www();
1332: # Patch pwauth
1333: print_and_log(&mt('Building authentication system for LON-CAPA users.')."\n");
1334: my $patch = <<"ENDPATCH";
1335: 148c148
1336: < #define SERVER_UIDS 99 /* user "nobody" */
1337: ---
1338: > #define SERVER_UIDS $num /* user "www" */
1339: ENDPATCH
1340:
1341: if (! -e "/usr/bin/patch") {
1342: print_and_log(&mt('You must install the software development tools package: [_1], when installing Linux.',"'patch'")."\n");
1343: print_and_log(&mt('Authentication installation not completed.')."\n");
1344: return;
1345: }
1346: if (&skip_if_nonempty(`cd /tmp; tar zxf $instdir/pwauth-2.2.8.tar.gz`,
1347: &mt('Unable to extract pwauth')."\n")) {
1348: return;
1349: }
1350: my $dir = "/tmp/pwauth-2.2.8";
1351: if (open(PATCH,"| patch $dir/config.h")) {
1352: print PATCH $patch;
1353: close(PATCH);
1354: print_and_log("\n");
1355: ##
1356: ## Compile patched pwauth
1357: ##
1358: print_and_log(&mt('Compiling pwauth')."\n");
1359: my $result = `cd $dir/; make`;
1360: my $expected = <<"END";
1361: gcc -g -c -o pwauth.o pwauth.c
1362: gcc -o pwauth -g pwauth.o -lcrypt
1363: END
1364: if ($result eq $expected) {
1365: print_and_log(&mt('Apparent success compiling pwauth:').
1366: "\n".$result );
1367: # Install patched pwauth
1368: print_and_log(&mt('Copying pwauth to [_1]',' /usr/local/sbin')."\n");
1369: if (copy "$dir/pwauth","/usr/local/sbin/pwauth") {
1.5 ! raeburn 1370: if (chmod(06755, "/usr/local/sbin/pwauth")) {
1.1 raeburn 1371: print_and_log(&mt('[_1] copied successfully',"'pwauth'").
1372: "\n");
1373: } else {
1374: print &mt('Unable to set permissions on [_1].'.
1375: "/usr/local/sbin/pwauth")."\n";
1376: }
1377: } else {
1378: print &mt('Unable to copy [_1] to [_2]',
1379: "'$dir/pwauth'","/usr/local/sbin/pwauth")."\n$!\n";
1380: }
1381: } else {
1382: print &mt('Unable to compile patched [_1].'."'pwauth'")."\n";
1383: }
1384: } else {
1385: print &mt('Unable to start patch for [_1]',"'pwauth'")."\n";
1386: }
1387: print_and_log("\n");
1388: }
1389:
1390: sub kill_extra_services {
1391: my ($distro,$stopsrvcs) = @_;
1392: if (ref($stopsrvcs) eq 'HASH') {
1393: my @stopping = sort(keys(%{$stopsrvcs}));
1394: if (@stopping) {
1395: my $kill_list = join("',' ",@stopping);
1396: if ($kill_list) {
1397: $kill_list = "'".$kill_list."'";
1398: &print_and_log("\n".&mt('Killing unneccessary services ([_1] daemon(s)).',$kill_list)."\n");
1399: foreach my $daemon (@stopping) {
1400: my $service = $daemon;
1401: &print_and_log(`/etc/init.d/$service stop`);
1402: &print_and_log(&mt('Removing [_1] from startup.',$service)."\n");
1403: if ($daemon eq 'cupsd') {
1404: $service = 'cups';
1405: }
1.4 raeburn 1406: if ($distro =~ /^(debian|ubuntu)/) {
1.1 raeburn 1407: &print_and_log(`/usr/sbin/sysv-rc-conf $service off`);
1408: } else {
1409: &print_and_log(`chkconfig --del $service`);
1410: }
1411: }
1412: }
1413: }
1414: }
1415: return;
1416: }
1417:
1418: sub setup_mysql {
1419: my ($setup_mysql_permissions,$distro,$dbh,$has_pass,$has_lcdb) = @_;
1.4 raeburn 1420: my @mysql_lc_commands;
1.1 raeburn 1421: unless ($has_lcdb) {
1.4 raeburn 1422: push(@mysql_lc_commands,"CREATE DATABASE loncapa");
1.1 raeburn 1423: }
1.4 raeburn 1424: push(@mysql_lc_commands,"USE loncapa");
1425: push(@mysql_lc_commands,qq{
1426: 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
1427: });
1.1 raeburn 1428: if ($setup_mysql_permissions) {
1.4 raeburn 1429: &setup_mysql_permissions($dbh,$has_pass,@mysql_lc_commands);
1.1 raeburn 1430: } else {
1431: print_and_log(&mt('Skipping MySQL permissions setup.')."\n");
1432: if ($dbh) {
1.4 raeburn 1433: if (@mysql_lc_commands) {
1434: foreach my $lccmd (@mysql_lc_commands) {
1435: $dbh->do($lccmd) || print $dbh->errstr."\n";
1436: }
1437: }
1.1 raeburn 1438: print_and_log(&mt('MySQL database set up complete.')."\n");
1439: } else {
1440: print_and_log(&mt('Problem accessing MySQL.')."\n");
1441: }
1442: }
1443: }
1444:
1445: sub setup_mysql_permissions {
1.4 raeburn 1446: my ($dbh,$has_pass,@mysql_lc_commands) = @_;
1.1 raeburn 1447: my $mysqlversion = &get_mysql_version();
1.4 raeburn 1448: my @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));");
1.1 raeburn 1449: if ($mysqlversion < 4) {
1.4 raeburn 1450: push (@mysql_commands,"
1451: INSERT db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES('localhost','loncapa','www','Y','Y','Y','Y','Y','Y','N','Y','Y','Y')");
1452: } else {
1453: push (@mysql_commands,"
1454: INSERT db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Create_tmp_table_priv,Lock_tables_priv) VALUES('localhost','loncapa','www','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y')");
1.1 raeburn 1455: }
1.4 raeburn 1456: push(@mysql_commands,"DELETE FROM user WHERE host<>'localhost'");
1.1 raeburn 1457: if ($has_pass) {
1458: if ($dbh) {
1.4 raeburn 1459: push(@mysql_commands,"FLUSH PRIVILEGES");
1460: if (@mysql_commands) {
1461: foreach my $cmd (@mysql_commands) {
1462: $dbh->do($cmd) || print $dbh->errstr."\n";
1463: }
1464: }
1465: if (@mysql_lc_commands) {
1466: foreach my $lccmd (@mysql_lc_commands) {
1467: $dbh->do($lccmd) || print $dbh->errstr."\n";
1468: }
1469: }
1.1 raeburn 1470: print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1]',"'www'")."\n");
1471: } else {
1472: print_and_log(&mt('Problem accessing MySQL.')."\n".
1473: &mt('Permissions not set.')."\n");
1474: }
1475: } else {
1476: my ($firstpass,$secondpass,$got_passwd,$newmysqlpass);
1477: print &mt('Please enter a root password for the mysql database.')."\n".
1478: &mt('It does not have to match your root account password, but you will need to remember it.')."\n";
1479: my $maxtries = 10;
1480: my $trial = 0;
1481: while ((!$got_passwd) && ($trial < $maxtries)) {
1482: $firstpass = &get_mysql_password(&mt('Enter password'));
1483: if (length($firstpass) > 5) {
1484: $secondpass = &get_mysql_password(&mt('Enter password a second time'));
1485: if ($firstpass eq $secondpass) {
1486: $got_passwd = 1;
1487: $newmysqlpass = $firstpass;
1488: } else {
1489: print(&mt('Passwords did not match. Please try again.')."\n");
1490: }
1491: $trial ++;
1492: } else {
1493: print(&mt('Password too short.')."\n".
1494: &mt('Please choose a password with at least six characters.')."\n");
1495: }
1496: }
1497: if ($got_passwd) {
1.4 raeburn 1498: my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass);
1499: push(@mysql_commands,@newpass_cmds);
1.1 raeburn 1500: } else {
1501: print_and_log(&mt('Failed to get MySQL root password from user input.')."\n");
1502: }
1503: if ($dbh) {
1.4 raeburn 1504: if (@mysql_commands) {
1505: foreach my $cmd (@mysql_commands) {
1506: $dbh->do($cmd) || print $dbh->errstr."\n";
1507:
1508: }
1509: }
1510: if (@mysql_lc_commands) {
1511: foreach my $lccmd (@mysql_lc_commands) {
1512: $dbh->do($lccmd) || print $dbh->errstr."\n";
1513: }
1514: }
1.1 raeburn 1515: if ($got_passwd) {
1516: print_and_log(&mt('MySQL root password stored.')."\n".
1517: &mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n");
1518: } else {
1519: print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n");
1520: }
1521: } else {
1522: print_and_log(&mt('Problem accessing MySQL.')."\n".
1523: &mt('Permissions not set.')."\n");
1524: }
1525: }
1526: }
1527:
1528: sub new_mysql_rootpasswd {
1529: my ($currmysqlpass) = @_;
1.4 raeburn 1530: return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')",
1531: "FLUSH PRIVILEGES;");
1.1 raeburn 1532: }
1533:
1534: sub get_mysql_version {
1535: my $version;
1536: if (open(PIPE," mysql -V |")) {
1537: my $info = <PIPE>;
1538: chomp($info);
1539: close(PIPE);
1540: ($version) = ($info =~ /(\d+\.\d+)\.\d+,/);
1541: } else {
1542: print &mt('Could not determine which version of MySQL is installed.').
1543: "\n";
1544: }
1545: return $version;
1546: }
1547:
1548: ###########################################################
1549: ##
1550: ## RHEL/CentOS/Fedora/Scientific Linux
1551: ## Copy LON-CAPA httpd.conf to /etc/httpd/conf
1552: ##
1553: ###########################################################
1554:
1555: sub copy_httpd_conf {
1556: my ($instdir) = @_;
1557: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'httpd.conf'",
1558: "'/etc/httpd/conf/httpd.conf'")."\n");
1559: copy "/etc/httpd/conf/httpd.conf","/etc/httpd/conf/httpd.conf.original";
1560: copy "$instdir/httpd.conf","/etc/httpd/conf/httpd.conf";
1.5 ! raeburn 1561: chmod(0444,"/etc/httpd/conf/httpd.conf");
1.1 raeburn 1562: print_and_log("\n");
1563: }
1564:
1565: #########################################################
1566: ##
1567: ## Ubuntu/Debian -- copy our apache2 configuration file to
1568: ## sites-available and set the symlink from sites-enabled.
1569: ##
1570: #########################################################
1571:
1572: sub copy_apache2_debconf {
1573: my ($instdir) = @_;
1.4 raeburn 1574: print_and_log(&mt('Copying loncapa [_1] config file to [_2] and pointing [_3] to it from sites-enabled.',"'apache2'","'/etc/apache2/sites-available'","'000-default symlink'")."\n");
1.1 raeburn 1575: my $apache2_enabled_dir = '/etc/apache2/sites-enabled';
1576: my $apache2_available_dir = '/etc/apache2/sites-available';
1577: if (-l "$apache2_enabled_dir/000-default") {
1578: unlink("$apache2_enabled_dir/000-default");
1579: }
1580: if (-e "$apache2_available_dir/loncapa") {
1581: copy("$apache2_available_dir/loncapa","$apache2_available_dir/loncapa.original");
1582: }
1583: copy("$instdir/apache2.conf","$apache2_available_dir/loncapa");
1584: chmod(0444,"$apache2_available_dir/loncapa");
1585: symlink("$apache2_available_dir/loncapa","$apache2_enabled_dir/000-default");
1586: print_and_log("\n");
1587: }
1588:
1589: ###########################################################
1590: ##
1591: ## openSuSE/SLES Copy apache2 config files:
1592: ## default-server.conf, uid.conf, /etc/sysconfig/apache2
1593: ## and create symlink from /srv/www/conf to /etc/apache2
1594: ##
1595: ###########################################################
1596:
1597: sub copy_apache2_suseconf {
1598: my ($instdir) = @_;
1599: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',
1600: "'default-server.conf'",
1601: "'/etc/apache2/default-server.conf'")."\n");
1602: if (!-e "/etc/apache2/default-server.conf.original") {
1603: copy "/etc/apache2/default-server.conf","/etc/apache2/default-server.conf.original";
1604: }
1605: copy "$instdir/default-server.conf","/etc/apache2/default-server.conf";
1.5 ! raeburn 1606: chmod(0444,"/etc/apache2/default-server.conf");
1.1 raeburn 1607: # Make symlink for conf directory (included in loncapa_apache.conf)
1608: my $can_symlink = (eval { symlink('/etc/apache2','/srv/www/conf'); }, $@ eq '');
1609: if ($can_symlink) {
1610: &print_and_log(&mt('Symlink created for [_1] to [_2].',
1611: "'/srv/www/conf'","'/etc/apache2'")."\n");
1612: } else {
1613: &print_and_log(&mt('Symlink creation failed for [_1] to [_2]. You will need to perform this action from the command line.',"'/srv/www/conf'","'/etc/apache2'")."\n");
1614: }
1615: ©_apache2_conf_files($instdir);
1616: ©_sysconfig_apache2_file($instdir);
1617: print_and_log("\n");
1618: }
1619:
1620: ###############################################
1621: ##
1622: ## Modify uid.conf
1623: ##
1624: ###############################################
1625: sub copy_apache2_conf_files {
1626: my ($instdir) = @_;
1627: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',
1628: "'uid.conf'","'/etc/apache2/uid.conf'")."\n");
1629: if (!-e "/etc/apache2/uid.conf.original") {
1630: copy "/etc/apache2/uid.conf","/etc/apache2/uid.conf.original";
1631: }
1632: copy "$instdir/uid.conf","/etc/apache2/uid.conf";
1.5 ! raeburn 1633: chmod(0444,"/etc/apache2/uid.conf");
1.1 raeburn 1634: }
1635:
1636: ###############################################
1637: ##
1638: ## Modify /etc/sysconfig/apache2
1639: ##
1640: ###############################################
1641: sub copy_sysconfig_apache2_file {
1642: my ($instdir) = @_;
1643: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'sysconfig/apache2'","'/etc/sysconfig/apache2'")."\n");
1644: if (!-e "/etc/sysconfig/apache2.original") {
1645: copy "/etc/sysconfig/apache2","/etc/sysconfig/apache2.original";
1646: }
1647: copy "$instdir/sysconfig_apache2","/etc/sysconfig/apache2";
1.5 ! raeburn 1648: chmod(0444,"/etc/sysconfig/apache2");
1.1 raeburn 1649: }
1650:
1651: ###############################################
1652: ##
1653: ## Add/Modify /etc/insserv/overrides
1654: ##
1655: ###############################################
1656:
1657: sub update_SuSEfirewall2_setup {
1658: my ($instdir) = @_;
1659: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'SuSEfirewall2_setup'","'/etc/insserv/overrides/SuSEfirewall2_setup'")."\n");
1660: if (!-e "/etc/insserv/overrides/SuSEfirewall2_setup") {
1661: if (!-d "/etc/insserv") {
1662: mkdir("/etc/insserv",0755);
1663: }
1664: if (!-d "/etc/insserv/overrides") {
1665: mkdir("/etc/insserv/overrides",0755);
1666: }
1667: } elsif (!-e "/etc/insserv/overrides/SuSEfirewall2_setup.original") {
1668: copy "/etc/insserv/overrides/SuSEfirewall2_setup","/etc/insserv/overrides/SuSEfirewall2_setup.original"
1669: }
1670: copy "$instdir/SuSEfirewall2_setup","/etc/insserv/overrides/SuSEfirewall2_setup";
1.5 ! raeburn 1671: chmod(0444,"/etc/insserv/overrides/SuSEfirewall2_setup");
! 1672: }
! 1673:
! 1674: sub get_iptables_rules {
! 1675: my ($distro,$instdir,$apachefw) = @_;
! 1676: my (@fwchains,@ports);
! 1677: if (&firewall_is_active()) {
! 1678: my $iptables = &get_pathto_iptables();
! 1679: if ($iptables ne '') {
! 1680: @fwchains = &get_fw_chains($iptables,$distro);
! 1681: }
! 1682: }
! 1683: if (ref($apachefw) eq 'HASH') {
! 1684: foreach my $service ('http','https') {
! 1685: unless ($apachefw->{$service}) {
! 1686: push (@ports,$service);
! 1687: }
! 1688: }
! 1689: } else {
! 1690: @ports = ('http','https');
! 1691: }
! 1692: if (@ports == 0) {
! 1693: return;
! 1694: }
! 1695: my $ask_to_enable;
! 1696: if (-e "/etc/iptables.loncapa.rules") {
! 1697: if (open(PIPE, "diff --brief $instdir/debian/iptables.loncapa.rules /etc/iptables.loncapa.rules |")) {
! 1698: my $diffres = <PIPE>;
! 1699: close(PIPE);
! 1700: chomp($diffres);
! 1701: if ($diffres) {
! 1702: print &mt('Warning: [_1] exists but differs from LON-CAPA supplied file.','/etc/iptables.loncapa.rules')."\n";
! 1703: }
! 1704: } else {
! 1705: print &mt('Error: unable to open [_1] to compare contents with LON-CAPA supplied file.','/etc/iptables.loncapa.rules')."\n";
! 1706: }
! 1707: } else {
! 1708: if (-e "$instdir/debian/iptables.loncapa.rules") {
! 1709: copy "$instdir/debian/iptables.loncapa.rules","/etc/iptables.loncapa.rules";
! 1710: chmod(0600,"/etc/iptables.loncapa.rules");
! 1711: }
! 1712: }
! 1713: if (-e "/etc/iptables.loncapa.rules") {
! 1714: if (-e "/etc/network/if-pre-up.d/iptables") {
! 1715: if (open(PIPE, "diff --brief $instdir/debian/iptables /etc/network/if-pre-up/iptables |")) {
! 1716: my $diffres = <PIPE>;
! 1717: close(PIPE);
! 1718: chomp($diffres);
! 1719: if ($diffres) {
! 1720: print &mt('Warning: [_1] exists but differs from LON-CAPA supplied file.','/etc/network/if-pre-up.d/iptables')."\n";
! 1721: }
! 1722: } else {
! 1723: print &mt('Error: unable to open [_1] to compare contents with LON-CAPA supplied file.','/etc/network/if-pre-up.d/iptables')."\n";
! 1724: }
! 1725: } else {
! 1726: copy "$instdir/debian/iptables","/etc/network/if-pre-up.d/iptables";
! 1727: chmod(0755,"/etc/network/if-pre-up.d/iptables");
! 1728: print_and_log(&mt('Installed script "[_1]" to add iptables rules to block all ports except 22, 80, and 443 when network is enabled during boot.','/etc/network/if-pre-up.d/iptables'));
! 1729: $ask_to_enable = 1;
! 1730: }
! 1731: }
! 1732: return $ask_to_enable;
1.1 raeburn 1733: }
1734:
1735: sub download_loncapa {
1736: my ($instdir,$lctarball) = @_;
1737: my ($have_tarball,$updateshown);
1738: if (! -e "$instdir/$lctarball") {
1739: print_and_log(&mt('Retrieving LON-CAPA source files from: [_1]',
1740: 'http://install.loncapa.org')."\n");
1741: system("wget http://install.loncapa.org/versions/$lctarball ".
1742: "2>/dev/null 1>/dev/null");
1743: if (! -e "./$lctarball") {
1744: print &mt('Unable to retrieve LON-CAPA source files from: [_1].',
1745: "http://install.loncapa.org/versions/$lctarball")."\n";
1746: } else {
1747: $have_tarball = 1;
1748: }
1749: print_and_log("\n");
1750: } else {
1751: $have_tarball = 1;
1752: print_and_log("
1753: ------------------------------------------------------------------------
1754:
1755: ".&mt('You seem to have a version of loncapa-current.tar.gz in [_1]',$instdir)."\n".
1756: &mt('This copy will be used and a new version will NOT be downloaded.')."\n".
1757: &mt('If you wish, you may download a new version by executing:')."
1758:
1.2 raeburn 1759: wget http://install.loncapa.org/versions/loncapa-current.tar.gz
1.1 raeburn 1760:
1761: ------------------------------------------------------------------------
1762: ");
1763: }
1764:
1765: ##
1766: ## untar loncapa.tar.gz
1767: ##
1768: if ($have_tarball) {
1769: print_and_log(&mt('Extracting LON-CAPA source files')."\n");
1770: writelog(`cd ~root; tar zxf $instdir/$lctarball`);
1771: print_and_log("\n");
1772: print &mt('LON-CAPA source files extracted.')."\n".
1773: &mt('It remains for you to execute the following commands:')."
1774:
1775: cd /root/loncapa-N.N (N.N should correspond to a version number like '0.4')
1776: ./UPDATE
1777:
1778: ".&mt('If you have any trouble, please see [_1] and [_2]',
1779: 'http://install.loncapa.org/','http://help.loncapa.org/')."\n";
1780: $updateshown = 1;
1781: }
1782: return ($have_tarball,$updateshown);
1783: }
1784:
1785: close LOG;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>