Annotation of doc/install/linux/install.pl, revision 1.40
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.40 ! raeburn 75: print LOG '$Id: install.pl,v 1.39 2016/08/28 16:15:53 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';
1.21 raeburn 194: } elsif ($versionstring =~ /CentOS(?:| Linux) release (\d+)/) {
1.1 raeburn 195: $distro = 'centos'.$1;
196: $updatecmd = 'yum install LONCAPA-prerequisites';
197: $installnow = 'yum -y install LONCAPA-prerequisites';
1.22 raeburn 198: } elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) {
1.1 raeburn 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;
1.12 raeburn 222: $updatecmd = 'yast -i LONCAPA-prerequisites';
1.1 raeburn 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);
1.8 raeburn 296: if ($line =~ /^LONCAPA\-prerequisites\-([\d\-]+)\.(?:[.\w]+)$/) {
1.1 raeburn 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:
1.6 raeburn 308: sub check_locale {
309: my ($distro) = @_;
1.8 raeburn 310: my ($fh,$langvar,$command);
311: $langvar = 'LANG';
1.6 raeburn 312: if ($distro =~ /^(ubuntu|debian)/) {
313: if (!open($fh,"</etc/default/locale")) {
314: print &mt('Failed to open: [_1], default locale not checked.',
315: '/etc/default/locale');
316: }
1.8 raeburn 317: } elsif ($distro =~ /^(suse|sles)/) {
318: if (!open($fh,"</etc/sysconfig/language")) {
319: print &mt('Failed to open: [_1], default locale not checked.',
320: '/etc/sysconfig/language');
321: }
322: $langvar = 'RC_LANG';
1.24 raeburn 323: } elsif ($distro =~ /^fedora(\d+)/) {
324: if ($1 >= 18) {
325: if (!open($fh,"</etc/locale.conf")) {
326: print &mt('Failed to open: [_1], default locale not checked.',
327: '/etc/locale.conf');
328: }
329: } elsif (!open($fh,"</etc/sysconfig/i18n")) {
330: print &mt('Failed to open: [_1], default locale not checked.',
331: '/etc/sysconfig/i18n');
332: }
1.29 raeburn 333: } elsif ($distro =~ /^(?:rhes|centos|scientific)(\d+)/) {
334: if ($1 >= 7) {
335: if (!open($fh,"</etc/locale.conf")) {
336: print &mt('Failed to open: [_1], default locale not checked.',
337: '/etc/locale.conf');
338: }
339: } elsif (!open($fh,"</etc/sysconfig/i18n")) {
340: print &mt('Failed to open: [_1], default locale not checked.',
341: '/etc/sysconfig/i18n');
342: }
1.6 raeburn 343: } else {
344: if (!open($fh,"</etc/sysconfig/i18n")) {
345: print &mt('Failed to open: [_1], default locale not checked.',
346: '/etc/sysconfig/i18n');
347: }
348: }
349: my @data = <$fh>;
350: chomp(@data);
351: foreach my $item (@data) {
1.25 raeburn 352: if ($item =~ /^\Q$langvar\E=\"?([^\"]*)\"?/) {
1.6 raeburn 353: my $default = $1;
354: if ($default ne 'en_US.UTF-8') {
355: if ($distro =~ /^debian/) {
1.25 raeburn 356: $command = 'locale-gen en_US.UTF-8'."\n".
357: 'update-locale LANG=en_US.UTF-8';
1.6 raeburn 358: } elsif ($distro =~ /^ubuntu/) {
1.25 raeburn 359: $command = 'sudo locale-gen en_US.UTF-8'."\n".
360: 'sudo update-locale LANG=en_US.UTF-8';
1.7 raeburn 361: } elsif ($distro =~ /^(suse|sles)/) {
362: $command = 'yast language';
1.6 raeburn 363: } else {
364: $command = 'system-config-language';
365: }
366: }
367: last;
368: }
369: }
370: close($fh);
371: return $command;
372: }
373:
1.1 raeburn 374: sub check_required {
375: my ($instdir,$dsn) = @_;
376: my ($distro,$packagecmd,$updatecmd,$installnow) = &get_distro();
377: if ($distro eq '') {
378: return;
379: }
380: my $gotprereqs = &check_prerequisites($packagecmd,$distro);
381: if ($gotprereqs eq '') {
1.22 raeburn 382: return ($distro,$gotprereqs,'',$packagecmd,$updatecmd);
1.6 raeburn 383: }
384: my $localecmd = &check_locale($distro);
385: unless ($localecmd eq '') {
386: return ($distro,$gotprereqs,$localecmd);
1.1 raeburn 387: }
1.34 raeburn 388: my ($mysqlon,$mysqlsetup,$mysqlrestart,$dbh,$has_pass,$has_lcdb,%recommended,
1.35 raeburn 389: $downloadstatus,$filetouse,$production,$testing,$apachefw,$tostop,$uses_systemctl);
1.1 raeburn 390: my $wwwuid = &uid_of_www();
391: my $wwwgid = getgrnam('www');
392: if (($wwwuid eq '') || ($wwwgid eq '')) {
393: $recommended{'wwwuser'} = 1;
394: }
395: unless( -e "/usr/local/sbin/pwauth") {
396: $recommended{'pwauth'} = 1;
397: }
398: $mysqlon = &check_mysql_running($distro);
399: if ($mysqlon) {
400: my $mysql_has_wwwuser = &check_mysql_wwwuser();
1.34 raeburn 401: ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser) =
402: &check_mysql_setup($instdir,$dsn,$distro,$mysql_has_wwwuser);
403: if ($mysqlsetup eq 'needsrestart') {
404: $mysqlrestart = '';
405: if ($distro eq 'ubuntu') {
406: $mysqlrestart = 'sudo ';
407: }
408: $mysqlrestart .= 'service mysql restart';
409: return ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,$mysqlrestart);
1.1 raeburn 410: } else {
1.34 raeburn 411: if ($mysqlsetup eq 'noroot') {
1.1 raeburn 412: $recommended{'mysqlperms'} = 1;
1.34 raeburn 413: } else {
414: unless ($mysql_has_wwwuser) {
415: $recommended{'mysqlperms'} = 1;
416: }
417: }
418: if ($dbh) {
419: $has_lcdb = &check_loncapa_mysqldb($dbh);
420: }
421: unless ($has_lcdb) {
422: $recommended{'mysql'} = 1;
1.1 raeburn 423: }
424: }
425: }
1.5 raeburn 426: ($recommended{'firewall'},$apachefw) = &chkfirewall($distro);
1.35 raeburn 427: ($recommended{'runlevels'},$tostop,$uses_systemctl) = &chkconfig($distro,$instdir);
1.1 raeburn 428: $recommended{'apache'} = &chkapache($distro,$instdir);
429: $recommended{'stopsrvcs'} = &chksrvcs($distro,$tostop);
430: ($recommended{'download'},$downloadstatus,$filetouse,$production,$testing)
431: = &need_download();
1.6 raeburn 432: return ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,
1.34 raeburn 433: $mysqlrestart,\%recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,
1.35 raeburn 434: $filetouse,$production,$testing,$apachefw,$uses_systemctl);
1.1 raeburn 435: }
436:
437: sub check_mysql_running {
438: my ($distro) = @_;
1.23 raeburn 439: my $use_systemctl;
1.1 raeburn 440: my $mysqldaemon ='mysqld';
441: if ($distro =~ /^(suse|sles|debian|ubuntu)/) {
442: $mysqldaemon = 'mysql';
443: }
1.6 raeburn 444: my $process = 'mysqld_safe';
445: my $proc_owner = 'root';
446: if ($distro =~ /^ubuntu(\w+)/) {
447: if ($1 >= 10) {
448: $process = 'mysqld';
449: $proc_owner = 'mysql';
450: }
1.35 raeburn 451: } elsif ($distro =~ /^fedora(\d+)/) {
1.23 raeburn 452: if ($1 >= 16) {
1.40 ! raeburn 453: if ($1 >= 19) {
! 454: $mysqldaemon ='mariadb';
! 455: }
1.23 raeburn 456: $process = 'mysqld';
457: $proc_owner = 'mysql';
458: $use_systemctl = 1;
459: }
1.39 raeburn 460: if ($1 >= 19) {
1.37 raeburn 461: $mysqldaemon ='mariadb';
462: }
1.35 raeburn 463: } elsif ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) {
1.29 raeburn 464: if ($1 >= 7) {
465: $mysqldaemon ='mariadb';
466: $process = 'mysqld';
467: $proc_owner = 'mysql';
468: $use_systemctl = 1;
469: }
1.35 raeburn 470: } elsif ($distro =~ /^sles(\d+)/) {
471: if ($1 >= 12) {
472: $use_systemctl = 1;
473: }
474: } elsif ($distro =~ /^suse(\d+)/) {
475: if ($1 >= 13) {
476: $use_systemctl = 1;
477: }
1.29 raeburn 478: }
1.35 raeburn 479: if (open(PIPE,"ps -ef |grep $process |grep ^$proc_owner |grep -v grep 2>&1 |")) {
1.1 raeburn 480: my $status = <PIPE>;
481: close(PIPE);
482: chomp($status);
1.6 raeburn 483: if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) {
1.1 raeburn 484: print_and_log(&mt('MySQL is running.')."\n");
485: return 1;
486: } else {
1.23 raeburn 487: if ($use_systemctl) {
488: system("/bin/systemctl start $mysqldaemon.service >/dev/null 2>&1 ");
489: } else {
490: system("/etc/init.d/$mysqldaemon start >/dev/null 2>&1 ");
491: }
1.1 raeburn 492: print_and_log(&mt('Waiting for MySQL to start.')."\n");
493: sleep 5;
1.12 raeburn 494: if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) {
495: $status = <PIPE>;
1.1 raeburn 496: close(PIPE);
497: chomp($status);
1.12 raeburn 498: if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) {
1.1 raeburn 499: print_and_log(&mt('MySQL is running.')."\n");
500: return 1;
501: } else {
1.12 raeburn 502: print_and_log(&mt('Still waiting for MySQL to start.')."\n");
503: sleep 5;
504: if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) {
505: $status = <PIPE>;
506: close(PIPE);
507: chomp($status);
508: if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) {
509: print_and_log(&mt('MySQL is running.')."\n");
510: return 1;
511: } else {
512: print_and_log(&mt('Given up waiting for MySQL to start.')."\n");
513: }
514: }
1.1 raeburn 515: }
516: }
517: }
518: } else {
519: print &mt('Could not determine if MySQL is running.')."\n";
520: }
521: return;
522: }
523:
524: sub chkconfig {
1.8 raeburn 525: my ($distro,$instdir) = @_;
1.23 raeburn 526: my (%needfix,%tostop,%uses_systemctl);
1.1 raeburn 527: my $checker_bin = '/sbin/chkconfig';
1.23 raeburn 528: my $sysctl_bin = '/bin/systemctl';
1.6 raeburn 529: my %daemon = (
530: mysql => 'mysqld',
531: apache => 'httpd',
532: cups => 'cups',
533: ntp => 'ntpd',
534: memcached => 'memcached',
535: );
1.1 raeburn 536: my @runlevels = qw/3 4 5/;
537: my @norunlevels = qw/0 1 6/;
538: if ($distro =~ /^(suse|sles)/) {
539: @runlevels = qw/3 5/;
540: @norunlevels = qw/0 2 1 6/;
1.6 raeburn 541: $daemon{'mysql'} = 'mysql';
542: $daemon{'apache'} = 'apache2';
1.8 raeburn 543: $daemon{'ntp'} = 'ntp';
1.1 raeburn 544: if ($distro =~ /^(suse|sles)9/) {
1.6 raeburn 545: $daemon{'apache'} = 'apache';
1.1 raeburn 546: }
1.35 raeburn 547: if ($distro =~ /^(suse|sles)([\d\.]+)/) {
548: my $name = $1;
549: my $num = $2;
550: if ($num > 11) {
1.26 raeburn 551: $uses_systemctl{'apache'} = 1;
1.35 raeburn 552: if (($name eq 'sles') || ($name eq 'suse' && $num >= 13.2)) {
553: $uses_systemctl{'mysql'} = 1;
554: $uses_systemctl{'ntp'} = 1;
555: $uses_systemctl{'cups'} = 1;
556: $uses_systemctl{'memcached'} = 1;
557: $daemon{'ntp'} = 'ntpd';
558: }
1.26 raeburn 559: }
560: }
1.6 raeburn 561: } elsif ($distro =~ /^(?:debian|ubuntu)(\d+)/) {
562: my $version = $1;
1.1 raeburn 563: @runlevels = qw/2 3 4 5/;
564: @norunlevels = qw/0 1 6/;
565: $checker_bin = '/usr/sbin/sysv-rc-conf';
1.6 raeburn 566: $daemon{'mysql'} = 'mysql';
567: $daemon{'apache'} = 'apache2';
568: $daemon{'ntp'} = 'ntp';
569: if (($distro =~ /^ubuntu/) && ($version <= 8)) {
570: $daemon{'cups'} = 'cupsys';
571: }
1.26 raeburn 572: } elsif ($distro =~ /^fedora(\d+)/) {
1.23 raeburn 573: my $version = $1;
574: if ($version >= 15) {
575: $uses_systemctl{'ntp'} = 1;
576: }
577: if ($version >= 16) {
578: $uses_systemctl{'mysql'} = 1;
579: $uses_systemctl{'apache'} = 1;
1.35 raeburn 580: $uses_systemctl{'memcached'} = 1;
581: $uses_systemctl{'cups'} = 1;
1.23 raeburn 582: }
1.39 raeburn 583: if ($version >= 19) {
1.37 raeburn 584: $daemon{'mysql'} = 'mariadb';
585: }
1.29 raeburn 586: } elsif ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) {
587: my $version = $1;
588: if ($version >= 7) {
589: $uses_systemctl{'ntp'} = 1;
590: $uses_systemctl{'mysql'} = 1;
591: $uses_systemctl{'apache'} = 1;
1.35 raeburn 592: $uses_systemctl{'memcached'} = 1;
593: $uses_systemctl{'cups'} = 1;
1.30 raeburn 594: $daemon{'mysql'} = 'mariadb';
1.29 raeburn 595: }
1.1 raeburn 596: }
1.23 raeburn 597: my $nocheck;
1.1 raeburn 598: if (! -x $checker_bin) {
1.23 raeburn 599: if ($uses_systemctl{'mysql'} && $uses_systemctl{'apache'}) {
600: if (! -x $sysctl_bin) {
601: $nocheck = 1;
602: }
603: } else {
604: $nocheck = 1;
605: }
606: }
607: if ($nocheck) {
1.6 raeburn 608: print &mt('Could not check runlevel status for MySQL or Apache')."\n";
1.1 raeburn 609: return;
610: }
611: my $rlstr = join('',@runlevels);
612: my $nrlstr = join('',@norunlevels);
1.23 raeburn 613:
1.6 raeburn 614: foreach my $type ('apache','mysql','ntp','cups','memcached') {
615: my $service = $daemon{$type};
1.23 raeburn 616: if ($uses_systemctl{$type}) {
1.35 raeburn 617: if (($type eq 'memcached') || ($type eq 'cups')) {
618: if (-l "/etc/systemd/system/multi-user.target.wants/$service.service") {
619: $tostop{$type} = 1;
620: }
621: } else {
622: if (!-l "/etc/systemd/system/multi-user.target.wants/$service.service") {
623: $needfix{$type} = "systemctl enable $service.service";
624: }
1.23 raeburn 625: }
626: } else {
627: my $command = $checker_bin.' --list '.$service.' 2>/dev/null';
1.35 raeburn 628: if ($type eq 'cups') {
1.23 raeburn 629: if ($distro =~ /^(?:debian|ubuntu)(\d+)/) {
630: my $version = $1;
631: if (($distro =~ /^ubuntu/) && ($version <= 8)) {
632: $command = $checker_bin.' --list cupsys 2>/dev/null';
1.19 raeburn 633: }
634: }
635: }
1.23 raeburn 636: my $results = `$command`;
637: my $tofix;
638: if ($results eq '') {
639: if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
640: if ($distro =~ /^(debian|ubuntu)/) {
641: $tofix = "update-rc.d $type defaults";
642: } else {
643: $tofix = "$checker_bin --add $service\n";
644: }
1.6 raeburn 645: }
1.23 raeburn 646: } else {
647: my %curr_runlevels;
648: for (my $rl=0; $rl<=6; $rl++) {
649: if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; }
650: }
651: if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) {
652: my $warning;
653: foreach my $rl (@runlevels) {
654: if (!exists($curr_runlevels{$rl})) {
655: $warning = 1;
656: }
657: }
658: if ($warning) {
659: $tofix = "$checker_bin --level $rlstr $service on\n";
660: }
661: } elsif (keys(%curr_runlevels) > 0) {
662: $tostop{$type} = 1;
1.1 raeburn 663: }
664: }
1.23 raeburn 665: if ($tofix) {
666: $needfix{$type} = $tofix;
1.1 raeburn 667: }
1.5 raeburn 668: }
1.1 raeburn 669: }
670: if ($distro =~ /^(suse|sles)([\d\.]+)$/) {
671: my $name = $1;
672: my $version = $2;
673: my ($major,$minor);
674: if ($name eq 'suse') {
675: ($major,$minor) = split(/\./,$version);
676: } else {
677: $major = $version;
678: }
679: if ($major > 10) {
1.8 raeburn 680: if (&check_SuSEfirewall2_setup($instdir)) {
681: $needfix{'insserv'} = 1;
682: }
1.1 raeburn 683: }
684: }
1.35 raeburn 685: return (\%needfix,\%tostop,\%uses_systemctl);
1.1 raeburn 686: }
687:
688: sub chkfirewall {
1.5 raeburn 689: my ($distro) = @_;
1.1 raeburn 690: my $configfirewall = 1;
691: my %ports = (
692: http => 80,
693: https => 443,
694: );
1.5 raeburn 695: my %activefw;
1.1 raeburn 696: if (&firewall_is_active()) {
697: my $iptables = &get_pathto_iptables();
698: if ($iptables eq '') {
699: print &mt('Firewall not checked as path to iptables not determined.')."\n";
700: } else {
1.5 raeburn 701: my @fwchains = &get_fw_chains($iptables,$distro);
1.1 raeburn 702: if (@fwchains) {
703: foreach my $service ('http','https') {
704: foreach my $fwchain (@fwchains) {
705: if (&firewall_is_port_open($iptables,$fwchain,$ports{$service})) {
706: $activefw{$service} = 1;
707: last;
708: }
709: }
710: }
711: if ($activefw{'http'}) {
712: $configfirewall = 0;
713: }
714: } else {
715: print &mt('Firewall not checked as iptables Chains not identified.')."\n";
716: }
717: }
718: } else {
719: print &mt('Firewall not enabled.')."\n";
720: }
1.5 raeburn 721: return ($configfirewall,\%activefw);
1.1 raeburn 722: }
723:
724: sub chkapache {
725: my ($distro,$instdir) = @_;
726: my $fixapache = 1;
1.28 raeburn 727: if ($distro =~ /^(debian|ubuntu)(\d+)$/) {
728: my $distname = $1;
729: my $version = $2;
1.33 raeburn 730: my ($stdconf,$stdsite);
731: if (($distname eq 'ubuntu') && ($version > 12)) {
732: $stdconf = "$instdir/debian-ubuntu/ubuntu14/loncapa_conf";
733: $stdsite = "$instdir/debian-ubuntu/ubuntu14/loncapa_sites";
734: } else {
735: $stdconf = "$instdir/debian-ubuntu/loncapa";
736: }
737: if (!-e $stdconf) {
1.1 raeburn 738: $fixapache = 0;
739: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
1.28 raeburn 740: } else {
1.33 raeburn 741: my ($configfile,$sitefile);
1.28 raeburn 742: if (($distname eq 'ubuntu') && ($version > 12)) {
1.33 raeburn 743: $sitefile = '/etc/apache2/sites-available/loncapa';
1.28 raeburn 744: $configfile = "/etc/apache2/conf-available/loncapa";
1.33 raeburn 745: } else {
746: $configfile = "/etc/apache2/sites-available/loncapa";
1.28 raeburn 747: }
1.33 raeburn 748: if (($configfile ne '') && (-e $configfile) && (-e $stdconf)) {
749: if (open(PIPE, "diff --brief $stdconf $configfile |")) {
1.28 raeburn 750: my $diffres = <PIPE>;
751: close(PIPE);
752: chomp($diffres);
753: unless ($diffres) {
754: $fixapache = 0;
755: }
1.1 raeburn 756: }
757: }
1.33 raeburn 758: if ((!$fixapache) && ($distname eq 'ubuntu') && ($version > 12)) {
759: if (($sitefile ne '') && (-e $sitefile) && (-e $stdsite)) {
760: if (open(PIPE, "diff --brief $stdsite $sitefile |")) {
761: my $diffres = <PIPE>;
762: close(PIPE);
763: chomp($diffres);
764: unless ($diffres) {
765: $fixapache = 0;
766: }
767: }
768: }
769: }
1.1 raeburn 770: }
1.6 raeburn 771: if (!$fixapache) {
772: foreach my $module ('headers.load','expires.load') {
773: unless (-l "/etc/apache2/mods-enabled/$module") {
774: $fixapache = 1;
775: }
776: }
777: }
1.1 raeburn 778: } elsif ($distro =~ /^(?:suse|sles)([\d\.]+)$/) {
779: my $apache = 'apache';
780: if ($1 >= 10) {
1.8 raeburn 781: $apache = 'apache2';
1.1 raeburn 782: }
1.9 raeburn 783: if (!-e "$instdir/sles-suse/default-server.conf") {
1.1 raeburn 784: $fixapache = 0;
785: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
1.9 raeburn 786: } elsif ((-e "/etc/$apache/default-server.conf") && (-e "$instdir/sles-suse/default-server.conf")) {
787: if (open(PIPE, "diff --brief $instdir/sles-suse/default-server.conf /etc/$apache/default-server.conf |")) {
788: my $diffres = <PIPE>;
789: close(PIPE);
790: chomp($diffres);
791: unless ($diffres) {
792: $fixapache = 0;
793: }
794: }
795: }
796: } elsif ($distro eq 'rhes4') {
797: if (!-e "$instdir/rhes4/httpd.conf") {
798: $fixapache = 0;
799: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
800: } elsif ((-e "/etc/httpd/conf/httpd.conf") && (-e "$instdir/rhes4/httpd.conf")) {
801: if (open(PIPE, "diff --brief $instdir/rhes4/httpd.conf /etc/httpd/conf/httpd.conf |")) {
1.1 raeburn 802: my $diffres = <PIPE>;
803: close(PIPE);
804: chomp($diffres);
805: unless ($diffres) {
806: $fixapache = 0;
807: }
808: }
809: }
810: } else {
1.14 raeburn 811: my $configfile = 'httpd.conf';
812: if ($distro =~ /^(?:centos|rhes|scientific)(\d+)$/) {
1.29 raeburn 813: if ($1 >= 7) {
814: $configfile = 'apache2.4/httpd.conf';
815: } elsif ($1 > 5) {
1.14 raeburn 816: $configfile = 'new/httpd.conf';
817: }
818: } elsif ($distro =~ /^fedora(\d+)$/) {
1.29 raeburn 819: if ($1 > 17) {
820: $configfile = 'apache2.4/httpd.conf';
821: } elsif ($1 > 10) {
1.15 raeburn 822: $configfile = 'new/httpd.conf';
1.14 raeburn 823: }
824: }
825: if (!-e "$instdir/centos-rhes-fedora-sl/$configfile") {
1.1 raeburn 826: $fixapache = 0;
827: print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n";
1.14 raeburn 828: } elsif ((-e "/etc/httpd/conf/httpd.conf") && (-e "$instdir/centos-rhes-fedora-sl/$configfile")) {
829: if (open(PIPE, "diff --brief $instdir/centos-rhes-fedora-sl/$configfile /etc/httpd/conf/httpd.conf |")) {
1.1 raeburn 830: my $diffres = <PIPE>;
831: close(PIPE);
832: chomp($diffres);
833: unless ($diffres) {
834: $fixapache = 0;
835: }
836: }
837: }
838: }
839: return $fixapache;
840: }
841:
842: sub chksrvcs {
843: my ($distro,$tostop) = @_;
844: my %stopsrvcs;
845: if (ref($tostop) eq 'HASH') {
846: %stopsrvcs = %{$tostop};
847: }
1.6 raeburn 848: foreach my $service ('cups','memcached') {
1.1 raeburn 849: next if (exists($stopsrvcs{$service}));
850: my $daemon = $service;
851: if ($service eq 'cups') {
852: $daemon = 'cupsd';
853: }
854: my $cmd = "ps -ef |grep '$daemon' |grep -v grep";
855: if (open(PIPE,'-|',$cmd)) {
856: my $daemonrunning = <PIPE>;
857: chomp($daemonrunning);
858: close(PIPE);
859: if ($daemonrunning) {
1.12 raeburn 860: if ($service eq 'memcached') {
1.16 raeburn 861: my $cmd = '/usr/bin/memcached';
862: if ($distro =~ /^(suse|sles)/) {
863: $cmd = '/usr/sbin/memcached';
864: }
1.12 raeburn 865: unless ($daemonrunning =~ m{^www[^/]+\Q$cmd -m 400 -v\E$}) {
1.10 raeburn 866: $stopsrvcs{$service} = 1;
867: }
868: } else {
869: $stopsrvcs{$service} = 1;
870: }
1.1 raeburn 871: }
872: }
1.10 raeburn 873: }
1.1 raeburn 874: return \%stopsrvcs;
875: }
876:
877: sub need_download {
878: my $needs_download = 1;
879: my ($production,$testing,$stdsizes) = &download_versionslist();
880: my ($rootdir,$localcurrent,$localtesting,%tarball,%localsize,%bymodtime,
881: %bysize,$filetouse,$downloadstatus);
882: $rootdir = '/root';
883: if (opendir(my $dir,"$rootdir")) {
884: my (@lcdownloads,$version);
885: foreach my $file (readdir($dir)) {
886: if ($file =~ /^loncapa\-([\w\-.]+)\.tar\.gz$/) {
887: $version = $1;
888: } else {
889: next;
890: }
891: if (ref($stdsizes) eq 'HASH') {
892: if ($version eq 'current') {
893: my @stats = stat("$rootdir/$file");
894: $localcurrent = $stats[7];
1.4 raeburn 895: if ($localcurrent == $stdsizes->{$production}) {
1.1 raeburn 896: $needs_download = 0;
897: $filetouse = $file;
898: }
899: } elsif ($version eq 'testing') {
900: my @stats = stat("$rootdir/$file");
901: $localtesting = $stats[7];
1.4 raeburn 902: if ($localtesting == $stdsizes->{$testing}) {
1.1 raeburn 903: $needs_download = 0;
904: $filetouse = $file;
905: }
906: }
907: }
908: $tarball{$version} = $file;
909: push(@lcdownloads,$version);
910: }
911: if ($needs_download) {
912: if (@lcdownloads > 0) {
913: foreach my $version (@lcdownloads) {
914: my @stats = stat("$rootdir/$tarball{$version}");
915: my $mtime = $stats[9];
916: $localsize{$version} = $stats[7];
917: if ($mtime) {
918: push(@{$bymodtime{$mtime}},$version);
919: }
920: if ($localsize{$version}) {
921: push(@{$bysize{$localsize{$version}}},$version);
922: }
923: }
924: if ($testing) {
925: if (exists($localsize{$testing})) {
926: if ($stdsizes->{$testing} == $localsize{$testing}) {
927: $needs_download = 0;
928: $filetouse = 'loncapa-'.$testing.'.tar.gz';
929: }
930: }
931: }
932: if ($needs_download) {
933: if ($production) {
934: if (exists($localsize{$production})) {
935: if ($stdsizes->{$production} == $localsize{$production}) {
936: $needs_download = 0;
937: $filetouse = 'loncapa-'.$production.'.tar.gz';
938: }
939: }
940: }
941: }
942: if ($needs_download) {
943: my @sorted = sort { $b <=> $a } keys(%bymodtime);
944: my $newest = $sorted[0];
945: if (ref($bymodtime{$newest}) eq 'ARRAY') {
946: $downloadstatus =
947: "Latest LON-CAPA source download in $rootdir is: ".
948: join(',',@{$bymodtime{$newest}})." (downloaded ".
949: localtime($newest).")\n";
950: }
951: } else {
952: $downloadstatus =
953: "The $rootdir directory already contains the latest LON-CAPA version:".
954: "\n".$filetouse."\n"."which can be used for installation.\n";
955: }
956: } else {
957: $downloadstatus = "The $rootdir directory does not appear to contain any downloaded LON-CAPA source code files which can be used for installation.\n";
958: }
959: }
960: } else {
961: $downloadstatus = "Could not open $rootdir directory to look for existing downloads of LON-CAPA source code.\n";
962: }
963: return ($needs_download,$downloadstatus,$filetouse,$production,$testing);
964: }
965:
966: sub check_mysql_setup {
1.34 raeburn 967: my ($instdir,$dsn,$distro,$mysql_has_wwwuser) = @_;
1.1 raeburn 968: my ($mysqlsetup,$has_pass);
969: my $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0});
970: if ($dbh) {
971: $mysqlsetup = 'noroot';
972: } elsif ($DBI::err =~ /1045/) {
973: $has_pass = 1;
1.34 raeburn 974: } elsif ($distro =~ /^ubuntu(\d+)$/) {
975: my $version = $1;
976: if ($1 > 12) {
977: print_and_log(&mt('Restarting mysql, please be patient')."\n");
978: if (open (PIPE, "service mysql restart 2>&1 |")) {
979: while (<PIPE>) {
980: print $_;
981: }
982: close(PIPE);
983: }
984: unless ($mysql_has_wwwuser) {
985: $mysql_has_wwwuser = &check_mysql_wwwuser();
986: }
987: $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0});
988: if ($dbh) {
989: $mysqlsetup = 'noroot';
990: } elsif ($DBI::err =~ /1045/) {
991: $has_pass = 1;
992: } else {
993: $mysqlsetup = 'needsrestart';
994: return ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser);
995: }
996: }
1.1 raeburn 997: }
998: if ($has_pass) {
999: print &mt('You have already set a root password for the MySQL database.')."\n";
1000: my $currpass = &get_mysql_password(&mt('Please enter the password now'));
1001: $dbh = DBI->connect($dsn,'root',$currpass,{'PrintError'=>0});
1002: if ($dbh) {
1003: $mysqlsetup = 'rootok';
1004: print_and_log(&mt('Password accepted.')."\n");
1005: } else {
1006: $mysqlsetup = 'rootfail';
1007: print_and_log(&mt('Problem accessing MySQL.')."\n");
1008: if ($DBI::err =~ /1045/) {
1009: print_and_log(&mt('Perhaps the password was incorrect?')."\n");
1010: print &mt('Try again?').' ';
1011: $currpass = &get_mysql_password(&mt('Re-enter password now'));
1012: $dbh = DBI->connect($dsn,'root',$currpass,{'PrintError'=>0});
1013: if ($dbh) {
1014: $mysqlsetup = 'rootok';
1015: print_and_log(&mt('Password accepted.')."\n");
1016: } else {
1017: if ($DBI::err =~ /1045/) {
1018: print_and_log(&mt('Incorrect password.')."\n");
1019: }
1020: }
1021: }
1022: }
1.34 raeburn 1023: } elsif ($mysqlsetup ne 'noroot') {
1.1 raeburn 1024: print_and_log(&mt('Problem accessing MySQL.')."\n");
1025: $mysqlsetup = 'rootfail';
1026: }
1.34 raeburn 1027: return ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser);
1.1 raeburn 1028: }
1029:
1030: sub check_mysql_wwwuser {
1031: my $mysql_wwwuser;
1.12 raeburn 1032: my $dbhn = DBI->connect("DBI:mysql:database=information_schema",'www','localhostkey',
1033: {PrintError => +0}) || return;
1.1 raeburn 1034: if ($dbhn) {
1035: $mysql_wwwuser = 1;
1036: $dbhn->disconnect;
1037: }
1038: return $mysql_wwwuser;
1039: }
1040:
1041: sub check_loncapa_mysqldb {
1042: my ($dbh) = @_;
1043: my $has_lcdb;
1044: if (ref($dbh)) {
1045: my $sth = $dbh->prepare("SHOW DATABASES");
1046: $sth->execute();
1047: while (my $dbname = $sth->fetchrow_array) {
1048: if ($dbname eq 'loncapa') {
1049: $has_lcdb = 1;
1050: last;
1051: }
1052: }
1053: $sth->finish();
1054: }
1055: return $has_lcdb;
1056: }
1057:
1058: sub get_pathto_iptables {
1059: my $iptables;
1060: if (-e '/sbin/iptables') {
1061: $iptables = '/sbin/iptables';
1062: } elsif (-e '/usr/sbin/iptables') {
1063: $iptables = '/usr/sbin/iptables';
1064: } else {
1065: print &mt('Unable to find iptables command.')."\n";
1066: }
1067: return $iptables;
1068: }
1069:
1070: sub firewall_is_active {
1071: if (-e '/proc/net/ip_tables_names') {
1072: return 1;
1073: } else {
1074: return 0;
1075: }
1076: }
1077:
1078: sub get_fw_chains {
1.5 raeburn 1079: my ($iptables,$distro) = @_;
1.1 raeburn 1080: my @fw_chains;
1081: my $suse_config = "/etc/sysconfig/SuSEfirewall2";
1082: my $ubuntu_config = "/etc/ufw/ufw.conf";
1083: if (-e $suse_config) {
1084: push(@fw_chains,'input_ext');
1085: } else {
1086: my @posschains;
1087: if (-e $ubuntu_config) {
1088: @posschains = ('ufw-user-input','INPUT');
1.5 raeburn 1089: } elsif ($distro =~ /^debian5/) {
1090: @posschains = ('INPUT');
1.1 raeburn 1091: } else {
1092: @posschains = ('RH-Firewall-1-INPUT','INPUT');
1093: if (!-e '/etc/sysconfig/iptables') {
1094: if (!-e '/var/lib/iptables') {
1095: print &mt('Unable to find iptables file containing static definitions.')."\n";
1096: }
1097: push(@fw_chains,'RH-Firewall-1-INPUT');
1098: }
1099: }
1100: if ($iptables eq '') {
1101: $iptables = &get_pathto_iptables();
1102: }
1103: my %counts;
1104: if (open(PIPE,"$iptables -L -n |")) {
1105: while(<PIPE>) {
1106: foreach my $chain (@posschains) {
1107: if (/(\Q$chain\E)/) {
1108: $counts{$1} ++;
1109: }
1110: }
1111: }
1112: close(PIPE);
1113: }
1114: foreach my $fw_chain (@posschains) {
1115: if ($counts{$fw_chain}) {
1116: unless(grep(/^\Q$fw_chain\E$/,@fw_chains)) {
1117: push(@fw_chains,$fw_chain);
1118: }
1119: }
1120: }
1121: }
1122: return @fw_chains;
1123: }
1124:
1125: sub firewall_is_port_open {
1126: my ($iptables,$fw_chain,$port) = @_;
1127: # returns 1 if the firewall port is open, 0 if not.
1128: #
1129: # check if firewall is active or installed
1130: return if (! &firewall_is_active());
1131: my $count = 0;
1132: if (open(PIPE,"$iptables -L $fw_chain -n |")) {
1133: while(<PIPE>) {
1134: if (/tcp dpt\:\Q$port\E/) {
1135: $count ++;
1136: last;
1137: }
1138: }
1139: close(PIPE);
1140: } else {
1141: print &mt('Firewall status not checked: unable to run [_1].','iptables -L')."\n";
1142: }
1143: return $count;
1144: }
1145:
1146: sub get_mysql_password {
1147: my ($prompt) = @_;
1148: local $| = 1;
1149: print $prompt.': ';
1150: my $newpasswd = '';
1151: ReadMode 'raw';
1152: my $key;
1153: while(ord($key = ReadKey(0)) != 10) {
1154: if(ord($key) == 127 || ord($key) == 8) {
1155: chop($newpasswd);
1156: print "\b \b";
1157: } elsif(!ord($key) < 32) {
1158: $newpasswd .= $key;
1159: print '*';
1160: }
1161: }
1162: ReadMode 'normal';
1163: print "\n";
1164: return $newpasswd;
1165: }
1166:
1167: sub check_SuSEfirewall2_setup {
1168: my ($instdir) = @_;
1169: my $need_override = 1;
1.9 raeburn 1170: if ((-e "/etc/insserv/overrides/SuSEfirewall2_setup") && (-e "$instdir/sles-suse/SuSEfirewall2_setup")) {
1171: if (open(PIPE, "diff --brief $instdir/sles-suse/SuSEfirewall2_setup /etc/insserv/overrides/SuSEfirewall2_setup |")) {
1.1 raeburn 1172: my $diffres = <PIPE>;
1173: close(PIPE);
1174: chomp($diffres);
1175: unless ($diffres) {
1176: $need_override = 0;
1177: }
1178: }
1179: }
1180: return $need_override;
1181: }
1182:
1183: sub download_versionslist {
1184: my ($production,$testing,%sizes);
1185: if (-e "latest.txt") {
1186: unlink("latest.txt");
1187: }
1188: my $rtncode = system("wget http://install.loncapa.org/versions/latest.txt ".
1189: "> /dev/null 2>&1");
1190: if (!$rtncode) {
1191: if (open(my $fh,"<latest.txt")) {
1192: my @info = <$fh>;
1193: close($fh);
1194: foreach my $line (@info) {
1195: chomp();
1196: if ($line =~ /^\QLATEST-IS: \E([\w\-.]+):(\d+)$/) {
1197: $production = $1;
1198: $sizes{$1} = $2;
1199: } elsif ($line =~ /^LATEST-TESTING-IS: \E([\w\-.]+):(\d+)$/) {
1200: $testing = $1;
1201: $sizes{$1} = $2;
1202: }
1203: }
1204: }
1205: }
1206: return ($production,$testing,\%sizes);
1207: }
1208:
1209: #
1210: # End helper routines.
1211: # Main script starts here
1212: #
1213:
1214: print "
1215: ********************************************************************
1216:
1217: ".&mt('Welcome to LON-CAPA')."
1218:
1219: ".&mt('This script will configure your system for installation of LON-CAPA.')."
1220:
1221: ********************************************************************
1222:
1223: ".&mt('The following actions are available:')."
1224:
1.4 raeburn 1225: ".&mt('1.')." ".&mt('Create the www user/group.')."
1.1 raeburn 1226: ".&mt('This is the user/group ownership under which Apache child processes run.')."
1227: ".&mt('It also owns most directories within the /home/httpd directory.')."
1228: ".&mt('This directory is where most LON-CAPA files and directories are stored.')."
1.4 raeburn 1229: ".&mt('2.')." ".&mt('Install the package LON-CAPA uses to authenticate users.')."
1230: ".&mt('3.')." ".&mt('Set-up the MySQL database.')."
1231: ".&mt('4.')." ".&mt('Set-up MySQL permissions.')."
1232: ".&mt('5.')." ".&mt('Configure Apache web server.')."
1233: ".&mt('6.')." ".&mt('Configure start-up of services.')."
1234: ".&mt('7.')." ".&mt('Check firewall settings.')."
1235: ".&mt('8.')." ".&mt('Stop services not used by LON-CAPA,')."
1.1 raeburn 1236: ".&mt('i.e., services for a print server: [_1] daemon.',"'cups'")."
1.4 raeburn 1237: ".&mt('9.')." ".&mt('Download LON-CAPA source code in readiness for installation.')."
1.1 raeburn 1238:
1239: ".&mt('Typically, you will run this script only once, when you first install LON-CAPA.')."
1240:
1241: ".&mt('The script will analyze your system to determine which actions are recommended.')."
1242: ".&mt('The script will then prompt you to choose the actions you would like taken.')."
1243:
1244: ".&mt('For each the recommended action will be selected if you hit Enter/Return.')."
1245: ".&mt('To override the default, type the lower case option from the two options listed.')."
1246: ".&mt('So, if the default is "yes", ~[Y/n~] will be shown -- type n to override.')."
1247: ".&mt('Whereas if the default is "no", ~[y/N~] will be shown -- type y to override.')."
1248:
1249: ".&mt('To accept the default, simply hit Enter/Return on your keyboard.')."
1250: ".&mt('Otherwise type: y or n then hit the Enter/Return key.')."
1251:
1252: ".&mt('Once a choice has been entered for all nine actions, required changes will be made.')."
1253: ".&mt('Feedback will be displayed on screen, and also stored in: [_1].','loncapa_install.log')."
1254:
1255: ".&mt('Continue? ~[Y/n~] ');
1256:
1257: my $go_on = &get_user_selection(1);
1258: if (!$go_on) {
1259: exit;
1260: }
1261:
1262: my $instdir = `pwd`;
1263: chomp($instdir);
1264:
1265: my %callsub;
1266: my @actions = ('wwwuser','pwauth','mysql','mysqlperms','apache',
1267: 'runlevels','firewall','stopsrvcs','download');
1268: my %prompts = &texthash(
1269: wwwuser => "Create the 'www' user?",
1270: pwauth => 'Install the package LON-CAPA uses to authenticate users?',
1271: mysql => 'Set-up the MySQL database?',
1272: mysqlperms => 'Set-up MySQL permissions?',
1273: apache => 'Configure Apache web server?',
1274: runlevels => 'Set overrides for start-up order of services?',
1275: firewall => 'Configure firewall settings for Apache',
1276: stopsrvcs => 'Stop extra services not required on a LON-CAPA server?',
1277: download => 'Download LON-CAPA source code in readiness for installation?',
1278: );
1279:
1280: print "\n".&mt('Checking system status ...')."\n";
1281:
1282: my $dsn = "DBI:mysql:database=mysql";
1.34 raeburn 1283: my ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,$mysqlrestart,
1284: $recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,$filetouse,$production,
1.35 raeburn 1285: $testing,$apachefw,$uses_systemctl) = &check_required($instdir,$dsn);
1.1 raeburn 1286: if ($distro eq '') {
1287: print "\n".&mt('Linux distribution could not be verified as a supported distribution.')."\n".
1288: &mt('The following are supported: [_1].',
1289: 'CentOS, RedHat Enterprise, Fedora, Scientific Linux, '.
1290: 'openSuSE, SLES, Ubuntu LTS, Debian')."\n\n".
1291: &mt('Stopping execution.')."\n";
1292: exit;
1293: }
1.34 raeburn 1294: if ($mysqlrestart) {
1295: print "\n".&mt('The mysql daemon needs to be restarted using the following command:')."\n".
1296: $mysqlrestart."\n\n".
1297: &mt('Stopping execution of install.pl script.')."\n".
1298: &mt('Please run the install.pl script again, once you have restarted mysql.')."\n";
1299: exit;
1300: }
1.6 raeburn 1301: if ($localecmd ne '') {
1302: print "\n".&mt('Although the LON-CAPA application itself is localized for a number of different languages, the default locale language for the Linux OS on which it runs should be US English.')."\n";
1303: print "\n".&mt('Run the following command from the command line to set the default language for your OS, and then run this LON-CAPA installation set-up script again.')."\n\n".
1304: $localecmd."\n\n".
1305: &mt('Stopping execution.')."\n";
1306: exit;
1307: }
1.1 raeburn 1308: if (!$gotprereqs) {
1.12 raeburn 1309: print "\n".&mt('The LONCAPA-prerequisites package is not installed.')."\n".
1.1 raeburn 1310: &mt('The following command can be used to install the package (and dependencies):')."\n\n".
1311: $updatecmd."\n\n";
1312: if ($installnow eq '') {
1313: print &mt('Stopping execution.')."\n";
1314: exit;
1315: } else {
1316: print &mt('Run command? ~[Y/n~]');
1317: my $install_prereq = &get_user_selection(1);
1318: if ($install_prereq) {
1319: if (open(PIPE,'|-',$installnow)) {
1320: close(PIPE);
1321: $gotprereqs = &check_prerequisites($packagecmd,$distro);
1322: if (!$gotprereqs) {
1.12 raeburn 1323: print &mt('The LONCAPA-prerequisites package is not installed.')."\n".
1.1 raeburn 1324: &mt('Stopping execution.')."\n";
1325: exit;
1326: } else {
1.6 raeburn 1327: ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,
1.34 raeburn 1328: $mysqlrestart,$recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,
1.35 raeburn 1329: $filetouse,$production,$testing,$apachefw,$uses_systemctl) =
1.5 raeburn 1330: &check_required($instdir,$dsn);
1.1 raeburn 1331: }
1332: } else {
1.12 raeburn 1333: print &mt('Failed to run command to install LONCAPA-prerequisites')."\n";
1.1 raeburn 1334: exit;
1335: }
1336: } else {
1337: print &mt('Stopping execution.')."\n";
1338: exit;
1339: }
1340: }
1341: }
1342: unless (ref($recommended) eq 'HASH') {
1343: print "\n".&mt('An error occurred determining which actions are recommended.')."\n\n".
1344: &mt('Stopping execution.')."\n";
1345: exit;
1346: }
1347:
1348: print "\n";
1349: my $num = 0;
1350: foreach my $action (@actions) {
1351: $num ++;
1352: my ($yesno,$defaultrun);
1353: if (ref($recommended) eq 'HASH') {
1.4 raeburn 1354: if (($action eq 'runlevels') || ($action eq 'stopsrvcs')) {
1.1 raeburn 1355: $yesno = '[y/N]';
1356: if (ref($recommended->{$action}) eq 'HASH') {
1357: if (keys(%{$recommended->{$action}}) > 0) {
1358: $yesno = &mt('~[Y/n~]');
1359: $defaultrun = 1;
1360: }
1361: }
1362: } else {
1363: if ($action eq 'download') {
1364: if ($downloadstatus) {
1365: print "\n$downloadstatus\n";
1366: }
1367: }
1368: if ($recommended->{$action}) {
1369: $yesno = mt('~[Y/n~]');
1370: $defaultrun = 1;
1371: } else {
1372: $yesno = &mt('~[y/N~]');
1373: }
1374: }
1375: print $num.'. '.$prompts{$action}." $yesno ";
1376: $callsub{$action} = &get_user_selection($defaultrun);
1377: }
1378: }
1379:
1380: my $lctarball = 'loncapa-current.tar.gz';
1381: my $sourcetarball = $lctarball;
1382: if ($callsub{'download'}) {
1383: my ($production,$testing,$sizes) = &download_versionslist();
1384: if ($production && $testing) {
1385: if ($production ne $testing) {
1386: print &mt('Two recent LON-CAPA releases are available: ')."\n".
1.3 raeburn 1387: &mt('1.').' '.&mt('A production release - version: [_1].',$production)."\n".
1388: &mt('2.').' '.&mt('A testing release - version: [_1].',$testing)."\n\n".
1.1 raeburn 1389: &mt('Download the production release? ~[Y/n~]');
1390: if (&get_user_selection(1)) {
1.4 raeburn 1391: $sourcetarball = 'loncapa-'.$production.'.tar.gz';
1.1 raeburn 1392: } else {
1393: print "\n".&mt('Download the testing release? ~[Y/n~]');
1394: if (&get_user_selection(1)) {
1.4 raeburn 1395: $sourcetarball = 'loncapa-'.$testing.'.tar.gz';
1.1 raeburn 1396: }
1397: }
1398: }
1399: } elsif ($production) {
1400: print &mt('The most recent LON-CAPA release is version: [_1].',$production)."\n".
1401: &mt('Download the production release? ~[Y/n~]');
1402: if (&get_user_selection(1)) {
1.20 raeburn 1403: $sourcetarball = 'loncapa-'.$production.'.tar.gz';
1.1 raeburn 1404: }
1405: }
1406: } elsif ($filetouse ne '') {
1407: $sourcetarball = $filetouse;
1408: }
1409:
1410: print_and_log("\n");
1411:
1412: # Each action: report if skipping, or perform action and provide feedback.
1413: if ($callsub{'wwwuser'}) {
1414: &setup_www();
1415: } else {
1416: &print_and_log(&mt('Skipping creation of user [_1].',"'www'")."\n");
1417: }
1418:
1419: if ($callsub{'pwauth'}) {
1.4 raeburn 1420: &build_and_install_mod_auth_external($instdir);
1.1 raeburn 1421: } else {
1422: &print_and_log(&mt('Skipping [_1] installation.',"'pwauth'")."\n");
1423: }
1424:
1425: if ($callsub{'mysql'}) {
1426: if ($dbh) {
1427: &setup_mysql($callsub{'mysqlperms'},$distro,$dbh,$has_pass,$has_lcdb);
1428: } else {
1429: print &mt('Unable to configure MySQL because access is denied.')."\n";
1430: }
1431: } else {
1432: &print_and_log(&mt('Skipping configuration of MySQL.')."\n");
1433: if ($callsub{'mysqlperms'}) {
1434: if ($dbh) {
1435: &setup_mysql_permissions($dbh,$has_pass);
1436: } else {
1437: print &mt('Unable to configure MySQL because access is denied.')."\n";
1438: }
1439: } else {
1440: &print_and_log(&mt('Skipping MySQL permissions setup.')."\n");
1441: }
1442: }
1443:
1444: if ($dbh) {
1445: if (!$dbh->disconnect) {
1446: &print_and_log(&mt('Failed to disconnect from MySQL:')."\n".
1447: $dbh->errstr);
1448: }
1449: }
1450:
1451: if ($callsub{'apache'}) {
1452: if ($distro =~ /^(suse|sles)/) {
1453: ©_apache2_suseconf($instdir);
1454: } elsif ($distro =~ /^(debian|ubuntu)/) {
1.28 raeburn 1455: ©_apache2_debconf($instdir,$distro);
1.1 raeburn 1456: } else {
1.14 raeburn 1457: ©_httpd_conf($instdir,$distro);
1.1 raeburn 1458: }
1459: } else {
1460: print_and_log(&mt('Skipping configuration of Apache web server.')."\n");
1461: }
1462:
1463: if ($callsub{'runlevels'}) {
1464: my $count = 0;
1465: if (ref($recommended) eq 'HASH') {
1466: if (ref($recommended->{'runlevels'}) eq 'HASH') {
1467: foreach my $type (keys(%{$recommended->{'runlevels'}})) {
1468: next if ($type eq 'insserv');
1469: $count ++;
1470: my $command = $recommended->{'runlevels'}{$type};
1471: if ($command ne '') {
1472: print_and_log(&mt('Runlevel update command run: [_1].',$command)."\n");
1473: system($command);
1474: }
1475: }
1476: if (!$count) {
1477: print_and_log(&mt('No runlevel updates required.')."\n");
1478: }
1479: }
1480: }
1.11 raeburn 1481: if ($distro =~ /^(suse|sles)/) {
1482: &update_SuSEfirewall2_setup($instdir);
1483: }
1.1 raeburn 1484: } else {
1485: &print_and_log(&mt('Skipping setting override for start-up order of services.')."\n");
1486: }
1487:
1488: if ($callsub{'firewall'}) {
1489: if ($distro =~ /^(suse|sles)/) {
1.5 raeburn 1490: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
1491: 'yast -- Security and Users -> Firewall -> Interfaces',
1492: 'ssh, http, https')."\n";
1493: } elsif ($distro =~ /^(debian|ubuntu)(\d+)/) {
1494: if (($1 eq 'ubuntu') || ($2 > 5)) {
1495: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
1496: 'ufw','ssh, http, https')."\n";
1497: } else {
1498: my $fwadded = &get_iptables_rules($distro,$instdir,$apachefw);
1499: if ($fwadded) {
1500: print &mt('Enable firewall? ~[Y/n~]');
1501: my $enable_iptables = &get_user_selection(1);
1502: if ($enable_iptables) {
1503: system('/etc/network/if-pre-up.d/iptables');
1504: print &mt('Firewall enabled using rules defined in [_1].',
1505: '/etc/iptables.loncapa.rules');
1506: }
1507: }
1508: }
1.11 raeburn 1509: } elsif ($distro =~ /^scientific/) {
1510: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
1511: 'system-config-firewall-tui -- Customize',
1512: 'ssh, http')."\n";
1.1 raeburn 1513: } else {
1.5 raeburn 1514: print &mt('Use [_1] to configure the firewall to allow access for [_2].',
1.11 raeburn 1515: 'setup -- Firewall configuration -> Customize',
1.5 raeburn 1516: 'ssh, http, https')."\n";
1.1 raeburn 1517: }
1518: } else {
1.5 raeburn 1519: &print_and_log(&mt('Skipping Firewall configuration.')."\n");
1.1 raeburn 1520: }
1521:
1522: if ($callsub{'stopsrvcs'}) {
1523: &kill_extra_services($distro,$recommended->{'stopsrvcs'});
1524: } else {
1.10 raeburn 1525: &print_and_log(&mt('Skipping stopping unnecessary service ([_1] daemons).',"'cups','memcached'")."\n");
1.1 raeburn 1526: }
1527:
1528: my ($have_tarball,$updateshown);
1529: if ($callsub{'download'}) {
1530: ($have_tarball,$updateshown) = &download_loncapa($instdir,$sourcetarball);
1531: } else {
1532: print_and_log(&mt('Skipping download of LON-CAPA tar file.')."\n\n");
1533: print &mt('LON-CAPA is available for download from: [_1]',
1534: 'http://install.loncapa.org/')."\n";
1535: if (!-e '/etc/loncapa-release') {
1536: &print_and_log(&mt('LON-CAPA is not yet installed on your system.').
1537: "\n\n".
1538: &mt('You may retrieve the source for LON-CAPA by executing:')."\n".
1539: "wget http://install.loncapa.org/versions/$lctarball\n");
1540: } else {
1541: my $currentversion;
1542: if (open(my $fh,"</etc/loncapa-release")) {
1543: my $version = <$fh>;
1544: chomp($version);
1545: if ($version =~ /^\QLON-CAPA release \E([\w\-.]+)$/) {
1546: $currentversion = $1;
1547: }
1548: }
1549: if ($currentversion ne '') {
1550: print &mt('Version of LON-CAPA currently installed on this server is: [_1].',
1551: $currentversion),"\n";
1552: if ($production) {
1553: print &mt('The latest production release of LON-CAPA is [_1].',$production)."\n";
1554: }
1555: if ($testing) {
1556: print &mt('The latest testing release of LON-CAPA is [_1].',$testing)."\n";
1557: }
1558: }
1559: }
1560: if ($filetouse ne '') {
1561: $have_tarball = 1;
1562: }
1563: }
1564:
1565: print "\n".&mt('Requested configuration complete.')."\n\n";
1566: my $apachename;
1567: if ($have_tarball && !$updateshown) {
1568: my ($lcdir) = ($sourcetarball =~ /^([\w.\-]+)\.tar.gz$/);
1569: if (!-e '/etc/loncapa-release') {
1570: print &mt('If you are now ready to install LON-CAPA, enter the following commands:')."\n\n";
1571: } else {
1572: print &mt('If you are now ready to update LON-CAPA, enter the following commands:')."\n\n".
1573: "/etc/init.d/loncontrol stop\n";
1574: if ($distro =~ /^(suse|sles|debian|ubuntu)([\d.]+)/) {
1575: if (($1 eq 'suse') && ($2 < 10)) {
1576: $apachename = 'apache';
1577: } else {
1578: $apachename = 'apache2';
1579: }
1580: } else {
1581: $apachename = 'httpd';
1582: }
1583: print "/etc/init.d/$apachename stop\n";
1584: }
1585: print "cd /root\n".
1586: "tar zxf $sourcetarball\n".
1587: "cd $lcdir\n".
1588: "./UPDATE\n";
1589: if (-e '/etc/loncapa-release') {
1590: print "/etc/init.d/loncontrol start\n";
1591: print "/etc/init.d/$apachename start\n";
1592: }
1593: }
1594: exit;
1595:
1596: #
1597: # End main script
1598: #
1599:
1600: #
1601: # Routines for the actions
1602: #
1603:
1604: sub setup_www {
1605: ##
1606: ## Set up www
1607: ##
1608: print_and_log(&mt('Creating user [_1]',"'www'")."\n");
1609: # -- Add group
1610:
1611: my $status = `/usr/sbin/groupadd www`;
1612: if ($status =~ /\QGroup `www' already exists.\E/) {
1613: print &mt('Group [_1] already exists.',"'www'")."\n";
1614: } elsif ($status ne '') {
1615: print &mt('Unable to add group [_1].',"'www'")."\n";
1616: }
1617:
1618: my $gid = getgrnam('www');
1619:
1620: if (open (PIPE, "/usr/sbin/useradd -c LONCAPA -g $gid www 2>&1 |")) {
1621: $status = <PIPE>;
1622: close(PIPE);
1623: chomp($status);
1624: if ($status =~ /\QAccount `www' already exists.\E/) {
1625: print &mt('Account [_1] already exists.',"'www'")."\n";
1626: } elsif ($status ne '') {
1627: print &mt('Unable to add user [_1].',"'www'")."\n";
1628: }
1629: } else {
1630: print &mt('Unable to run command to add user [_1].',"'www'")."\n";
1631: }
1632:
1633: my $uid = &uid_of_www();
1634: if (($gid ne '') && ($uid ne '')) {
1635: if (!-e '/home/www') {
1636: mkdir('/home/www',0755);
1637: system('chown www:www /home/www');
1638: }
1639: }
1640: writelog ($status);
1641: }
1642:
1643: sub uid_of_www {
1644: my ($num) = (getpwnam('www'))[2];
1645: return $num;
1646: }
1647:
1648: sub build_and_install_mod_auth_external {
1649: my ($instdir) = @_;
1650: my $num = &uid_of_www();
1651: # Patch pwauth
1652: print_and_log(&mt('Building authentication system for LON-CAPA users.')."\n");
1653: my $patch = <<"ENDPATCH";
1654: 148c148
1655: < #define SERVER_UIDS 99 /* user "nobody" */
1656: ---
1657: > #define SERVER_UIDS $num /* user "www" */
1658: ENDPATCH
1659:
1660: if (! -e "/usr/bin/patch") {
1661: print_and_log(&mt('You must install the software development tools package: [_1], when installing Linux.',"'patch'")."\n");
1662: print_and_log(&mt('Authentication installation not completed.')."\n");
1663: return;
1664: }
1665: if (&skip_if_nonempty(`cd /tmp; tar zxf $instdir/pwauth-2.2.8.tar.gz`,
1666: &mt('Unable to extract pwauth')."\n")) {
1667: return;
1668: }
1669: my $dir = "/tmp/pwauth-2.2.8";
1670: if (open(PATCH,"| patch $dir/config.h")) {
1671: print PATCH $patch;
1672: close(PATCH);
1673: print_and_log("\n");
1674: ##
1675: ## Compile patched pwauth
1676: ##
1677: print_and_log(&mt('Compiling pwauth')."\n");
1.12 raeburn 1678: my $result = `cd $dir/; make 2>/dev/null `;
1.1 raeburn 1679: my $expected = <<"END";
1680: gcc -g -c -o pwauth.o pwauth.c
1681: gcc -o pwauth -g pwauth.o -lcrypt
1682: END
1683: if ($result eq $expected) {
1684: print_and_log(&mt('Apparent success compiling pwauth:').
1685: "\n".$result );
1686: # Install patched pwauth
1687: print_and_log(&mt('Copying pwauth to [_1]',' /usr/local/sbin')."\n");
1688: if (copy "$dir/pwauth","/usr/local/sbin/pwauth") {
1.5 raeburn 1689: if (chmod(06755, "/usr/local/sbin/pwauth")) {
1.1 raeburn 1690: print_and_log(&mt('[_1] copied successfully',"'pwauth'").
1691: "\n");
1692: } else {
1693: print &mt('Unable to set permissions on [_1].'.
1694: "/usr/local/sbin/pwauth")."\n";
1695: }
1696: } else {
1697: print &mt('Unable to copy [_1] to [_2]',
1698: "'$dir/pwauth'","/usr/local/sbin/pwauth")."\n$!\n";
1699: }
1700: } else {
1701: print &mt('Unable to compile patched [_1].'."'pwauth'")."\n";
1702: }
1703: } else {
1704: print &mt('Unable to start patch for [_1]',"'pwauth'")."\n";
1705: }
1706: print_and_log("\n");
1707: }
1708:
1709: sub kill_extra_services {
1710: my ($distro,$stopsrvcs) = @_;
1711: if (ref($stopsrvcs) eq 'HASH') {
1712: my @stopping = sort(keys(%{$stopsrvcs}));
1713: if (@stopping) {
1.6 raeburn 1714: my $kill_list = join("', '",@stopping);
1.1 raeburn 1715: if ($kill_list) {
1716: $kill_list = "'".$kill_list."'";
1.6 raeburn 1717: &print_and_log("\n".&mt('Killing unnecessary services ([_1] daemon(s)).',$kill_list)."\n");
1718: foreach my $service (@stopping) {
1719: my $daemon = $service;
1720: if ($service eq 'cups') {
1721: $daemon = 'cupsd';
1722: if ($distro =~ /^(?:debian|ubuntu)(\d+)/) {
1723: my $version = $1;
1724: if (($distro =~ /^ubuntu/) && ($version <= 8)) {
1725: $daemon = 'cupsys';
1726: }
1.12 raeburn 1727: } else {
1.8 raeburn 1728: $daemon = 'cups';
1.6 raeburn 1729: }
1730: }
1.12 raeburn 1731: my $cmd = "ps -ef |grep '$daemon' |grep -v grep";
1732: if (open(PIPE,'-|',$cmd)) {
1733: my $daemonrunning = <PIPE>;
1734: chomp($daemonrunning);
1735: close(PIPE);
1736: if ($daemonrunning) {
1737: &print_and_log(`/etc/init.d/$daemon stop`);
1738: }
1739: }
1.1 raeburn 1740: &print_and_log(&mt('Removing [_1] from startup.',$service)."\n");
1.4 raeburn 1741: if ($distro =~ /^(debian|ubuntu)/) {
1.6 raeburn 1742: &print_and_log(`update-rc.d -f $daemon remove`);
1.1 raeburn 1743: } else {
1.35 raeburn 1744: if (ref($uses_systemctl) eq 'HASH') {
1745: if ($uses_systemctl->{$service}) {
1746: if (`systemctl is-enabled $service`) {
1747: &print_and_log(`systemctl disable $service`);
1748: }
1749: } else {
1750: &print_and_log(`/sbin/chkconfig --del $service`);
1751: }
1752: } else {
1753: &print_and_log(`/sbin/chkconfig --del $service`);
1754: }
1.1 raeburn 1755: }
1756: }
1757: }
1758: }
1759: }
1760: return;
1761: }
1762:
1763: sub setup_mysql {
1764: my ($setup_mysql_permissions,$distro,$dbh,$has_pass,$has_lcdb) = @_;
1.4 raeburn 1765: my @mysql_lc_commands;
1.1 raeburn 1766: unless ($has_lcdb) {
1.4 raeburn 1767: push(@mysql_lc_commands,"CREATE DATABASE loncapa");
1.1 raeburn 1768: }
1.4 raeburn 1769: push(@mysql_lc_commands,"USE loncapa");
1770: push(@mysql_lc_commands,qq{
1.18 raeburn 1771: 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, domain TEXT, dependencies TEXT, modifyinguser TEXT, authorspace TEXT, lowestgradelevel TEXT, highestgradelevel TEXT, standards TEXT, count INT, course INT, course_list TEXT, goto INT, goto_list TEXT, comefrom INT, comefrom_list TEXT, sequsage INT, sequsage_list TEXT, stdno INT, stdno_list TEXT, avetries FLOAT, avetries_list TEXT, difficulty FLOAT, difficulty_list TEXT, disc FLOAT, disc_list TEXT, clear FLOAT, technical FLOAT, correct FLOAT, helpful FLOAT, depth FLOAT, hostname 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)) ENGINE=MYISAM
1.4 raeburn 1772: });
1.1 raeburn 1773: if ($setup_mysql_permissions) {
1.4 raeburn 1774: &setup_mysql_permissions($dbh,$has_pass,@mysql_lc_commands);
1.1 raeburn 1775: } else {
1776: print_and_log(&mt('Skipping MySQL permissions setup.')."\n");
1777: if ($dbh) {
1.4 raeburn 1778: if (@mysql_lc_commands) {
1779: foreach my $lccmd (@mysql_lc_commands) {
1780: $dbh->do($lccmd) || print $dbh->errstr."\n";
1781: }
1782: }
1.1 raeburn 1783: print_and_log(&mt('MySQL database set up complete.')."\n");
1784: } else {
1785: print_and_log(&mt('Problem accessing MySQL.')."\n");
1786: }
1787: }
1788: }
1789:
1790: sub setup_mysql_permissions {
1.4 raeburn 1791: my ($dbh,$has_pass,@mysql_lc_commands) = @_;
1.38 raeburn 1792: my ($mysqlversion,$mysqlsubver,$mysqlname) = &get_mysql_version();
1.36 raeburn 1793: my ($usesauth,@mysql_commands);
1.38 raeburn 1794: if ($mysqlname =~ /^MariaDB/i) {
1795: if ($mysqlversion >= 10.2) {
1796: $usesauth = 1;
1797: }
1798: } else {
1799: if (($mysqlversion > 5.7) || (($mysqlversion == 5.7) && ($mysqlsubver > 5))) {
1800: $usesauth = 1;
1801: }
1802: }
1803: if ($usesauth) {
1.36 raeburn 1804: @mysql_commands = ("INSERT user (Host, User, ssl_cipher, x509_issuer, x509_subject) VALUES('localhost','www','','','')",
1.38 raeburn 1805: "ALTER USER 'www'\@'localhost' IDENTIFIED BY 'localhostkey'");
1.36 raeburn 1806: } else {
1807: @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));");
1808: }
1.1 raeburn 1809: if ($mysqlversion < 4) {
1.4 raeburn 1810: push (@mysql_commands,"
1811: 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')");
1812: } else {
1813: push (@mysql_commands,"
1814: 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 1815: }
1.4 raeburn 1816: push(@mysql_commands,"DELETE FROM user WHERE host<>'localhost'");
1.1 raeburn 1817: if ($has_pass) {
1818: if ($dbh) {
1.4 raeburn 1819: push(@mysql_commands,"FLUSH PRIVILEGES");
1820: if (@mysql_commands) {
1821: foreach my $cmd (@mysql_commands) {
1822: $dbh->do($cmd) || print $dbh->errstr."\n";
1823: }
1824: }
1825: if (@mysql_lc_commands) {
1826: foreach my $lccmd (@mysql_lc_commands) {
1827: $dbh->do($lccmd) || print $dbh->errstr."\n";
1828: }
1829: }
1.1 raeburn 1830: print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1]',"'www'")."\n");
1831: } else {
1832: print_and_log(&mt('Problem accessing MySQL.')."\n".
1833: &mt('Permissions not set.')."\n");
1834: }
1835: } else {
1836: my ($firstpass,$secondpass,$got_passwd,$newmysqlpass);
1837: print &mt('Please enter a root password for the mysql database.')."\n".
1838: &mt('It does not have to match your root account password, but you will need to remember it.')."\n";
1839: my $maxtries = 10;
1840: my $trial = 0;
1841: while ((!$got_passwd) && ($trial < $maxtries)) {
1842: $firstpass = &get_mysql_password(&mt('Enter password'));
1843: if (length($firstpass) > 5) {
1844: $secondpass = &get_mysql_password(&mt('Enter password a second time'));
1845: if ($firstpass eq $secondpass) {
1846: $got_passwd = 1;
1847: $newmysqlpass = $firstpass;
1848: } else {
1849: print(&mt('Passwords did not match. Please try again.')."\n");
1850: }
1851: $trial ++;
1852: } else {
1853: print(&mt('Password too short.')."\n".
1854: &mt('Please choose a password with at least six characters.')."\n");
1855: }
1856: }
1857: if ($got_passwd) {
1.4 raeburn 1858: my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass);
1859: push(@mysql_commands,@newpass_cmds);
1.1 raeburn 1860: } else {
1861: print_and_log(&mt('Failed to get MySQL root password from user input.')."\n");
1862: }
1863: if ($dbh) {
1.4 raeburn 1864: if (@mysql_commands) {
1865: foreach my $cmd (@mysql_commands) {
1866: $dbh->do($cmd) || print $dbh->errstr."\n";
1867:
1868: }
1869: }
1870: if (@mysql_lc_commands) {
1871: foreach my $lccmd (@mysql_lc_commands) {
1872: $dbh->do($lccmd) || print $dbh->errstr."\n";
1873: }
1874: }
1.1 raeburn 1875: if ($got_passwd) {
1876: print_and_log(&mt('MySQL root password stored.')."\n".
1877: &mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n");
1878: } else {
1879: print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n");
1880: }
1881: } else {
1882: print_and_log(&mt('Problem accessing MySQL.')."\n".
1883: &mt('Permissions not set.')."\n");
1884: }
1885: }
1886: }
1887:
1888: sub new_mysql_rootpasswd {
1.36 raeburn 1889: my ($currmysqlpass,$usesauth) = @_;
1890: if ($usesauth) {
1891: return ("ALTER USER 'root'\@'localhost' IDENTIFIED BY '$currmysqlpass'",
1892: "FLUSH PRIVILEGES;");
1893: } else {
1894: return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')",
1895: "FLUSH PRIVILEGES;");
1896: }
1.1 raeburn 1897: }
1898:
1899: sub get_mysql_version {
1.38 raeburn 1900: my ($version,$subversion,$name);
1.1 raeburn 1901: if (open(PIPE," mysql -V |")) {
1902: my $info = <PIPE>;
1903: chomp($info);
1904: close(PIPE);
1.38 raeburn 1905: ($version,$subversion,$name) = ($info =~ /(\d+\.\d+)\.(\d+)\-?(\w*),/);
1.1 raeburn 1906: } else {
1907: print &mt('Could not determine which version of MySQL is installed.').
1908: "\n";
1909: }
1.38 raeburn 1910: return ($version,$subversion,$name);
1.1 raeburn 1911: }
1912:
1913: ###########################################################
1914: ##
1915: ## RHEL/CentOS/Fedora/Scientific Linux
1916: ## Copy LON-CAPA httpd.conf to /etc/httpd/conf
1917: ##
1918: ###########################################################
1919:
1920: sub copy_httpd_conf {
1.14 raeburn 1921: my ($instdir,$distro) = @_;
1922: my $configfile = 'httpd.conf';
1923: if ($distro =~ /^(?:centos|rhes|scientific)(\d+)$/) {
1.29 raeburn 1924: if ($1 >= 7) {
1925: $configfile = 'apache2.4/httpd.conf';
1926: } elsif ($1 > 5) {
1.14 raeburn 1927: $configfile = 'new/httpd.conf';
1928: }
1929: } elsif ($distro =~ /^fedora(\d+)$/) {
1.29 raeburn 1930: if ($1 > 17) {
1931: $configfile = 'apache2.4/httpd.conf';
1932: } elsif ($1 > 10) {
1.14 raeburn 1933: $configfile = 'new/httpd.conf';
1934: }
1935: }
1.1 raeburn 1936: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'httpd.conf'",
1937: "'/etc/httpd/conf/httpd.conf'")."\n");
1938: copy "/etc/httpd/conf/httpd.conf","/etc/httpd/conf/httpd.conf.original";
1.14 raeburn 1939: copy "$instdir/centos-rhes-fedora-sl/$configfile","/etc/httpd/conf/httpd.conf";
1.5 raeburn 1940: chmod(0444,"/etc/httpd/conf/httpd.conf");
1.1 raeburn 1941: print_and_log("\n");
1942: }
1943:
1944: #########################################################
1945: ##
1.17 raeburn 1946: ## Ubuntu/Debian -- copy our loncapa configuration file to
1.1 raeburn 1947: ## sites-available and set the symlink from sites-enabled.
1948: ##
1949: #########################################################
1950:
1951: sub copy_apache2_debconf {
1.28 raeburn 1952: my ($instdir,$distro) = @_;
1.6 raeburn 1953: my $apache2_mods_enabled_dir = '/etc/apache2/mods-enabled';
1954: my $apache2_mods_available_dir = '/etc/apache2/mods-available';
1955: foreach my $module ('headers.load','expires.load') {
1956: unless (-l "$apache2_mods_enabled_dir/$module") {
1957: symlink("$apache2_mods_available_dir/$module","$apache2_mods_enabled_dir/$module");
1958: print_and_log(&mt('Enabling "[_1]" Apache module.',$module)."\n");
1959: }
1960: }
1.28 raeburn 1961: my $apache2_sites_enabled_dir = '/etc/apache2/sites-enabled';
1962: my $apache2_sites_available_dir = '/etc/apache2/sites-available';
1963: my $defaultconfig = "$apache2_sites_enabled_dir/000-default";
1964: my ($distname,$version);
1965: if ($distro =~ /^(debian|ubuntu)(\d+)$/) {
1966: $distname = $1;
1967: $version = $2;
1968: }
1969: if (($distname eq 'ubuntu') && ($version > 12)) {
1970: $defaultconfig = "$apache2_sites_enabled_dir/000-default.conf";
1971: }
1972: if (-l $defaultconfig) {
1973: unlink($defaultconfig);
1974: }
1975: if (($distname eq 'ubuntu') && ($version > 12)) {
1.32 raeburn 1976: print_and_log(&mt('Copying loncapa [_1] config file to [_2] and pointing [_3] to it from conf-enabled.',"'apache2'","'/etc/apache2/conf-available'","'loncapa.conf symlink'")."\n");
1.28 raeburn 1977: my $apache2_conf_enabled_dir = '/etc/apache2/conf-enabled';
1978: my $apache2_conf_available_dir = '/etc/apache2/conf-available';
1979: if (-e "$apache2_conf_available_dir/loncapa") {
1980: copy("$apache2_conf_available_dir/loncapa","$apache2_conf_available_dir/loncapa.original");
1981: }
1.33 raeburn 1982: my $defaultconf = $apache2_conf_enabled_dir.'/loncapa.conf';
1.32 raeburn 1983: copy("$instdir/debian-ubuntu/ubuntu14/loncapa_conf","$apache2_conf_available_dir/loncapa");
1.28 raeburn 1984: chmod(0444,"$apache2_conf_available_dir/loncapa");
1.32 raeburn 1985: if (-l $defaultconf) {
1986: unlink($defaultconf);
1987: }
1988: symlink("$apache2_conf_available_dir/loncapa","$defaultconf");
1989: print_and_log(&mt('Copying loncapa [_1] site file to [_2] and pointing [_3] to it from sites-enabled.',"'apache2'","'/etc/apache2/sites-available'","'000-default.conf symlink'")."\n");
1990: copy("$instdir/debian-ubuntu/ubuntu14/loncapa_site","$apache2_sites_available_dir/loncapa");
1991: chmod(0444,"$apache2_sites_available_dir/loncapa");
1992: symlink("$apache2_sites_available_dir/loncapa","$defaultconfig");
1.28 raeburn 1993: } else {
1994: 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");
1995: if (-e "$apache2_sites_available_dir/loncapa") {
1996: copy("$apache2_sites_available_dir/loncapa","$apache2_sites_available_dir/loncapa.original");
1997: }
1998: copy("$instdir/debian-ubuntu/loncapa","$apache2_sites_available_dir/loncapa");
1999: chmod(0444,"$apache2_sites_available_dir/loncapa");
2000: symlink("$apache2_sites_available_dir/loncapa","$apache2_sites_enabled_dir/000-default");
2001: }
1.1 raeburn 2002: print_and_log("\n");
2003: }
2004:
2005: ###########################################################
2006: ##
2007: ## openSuSE/SLES Copy apache2 config files:
2008: ## default-server.conf, uid.conf, /etc/sysconfig/apache2
2009: ## and create symlink from /srv/www/conf to /etc/apache2
2010: ##
2011: ###########################################################
2012:
2013: sub copy_apache2_suseconf {
2014: my ($instdir) = @_;
2015: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',
2016: "'default-server.conf'",
2017: "'/etc/apache2/default-server.conf'")."\n");
2018: if (!-e "/etc/apache2/default-server.conf.original") {
2019: copy "/etc/apache2/default-server.conf","/etc/apache2/default-server.conf.original";
2020: }
1.9 raeburn 2021: copy "$instdir/sles-suse/default-server.conf","/etc/apache2/default-server.conf";
1.5 raeburn 2022: chmod(0444,"/etc/apache2/default-server.conf");
1.1 raeburn 2023: # Make symlink for conf directory (included in loncapa_apache.conf)
2024: my $can_symlink = (eval { symlink('/etc/apache2','/srv/www/conf'); }, $@ eq '');
2025: if ($can_symlink) {
2026: &print_and_log(&mt('Symlink created for [_1] to [_2].',
2027: "'/srv/www/conf'","'/etc/apache2'")."\n");
2028: } else {
2029: &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");
2030: }
2031: ©_apache2_conf_files($instdir);
2032: ©_sysconfig_apache2_file($instdir);
2033: print_and_log("\n");
2034: }
2035:
2036: ###############################################
2037: ##
2038: ## Modify uid.conf
2039: ##
2040: ###############################################
2041: sub copy_apache2_conf_files {
2042: my ($instdir) = @_;
2043: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',
2044: "'uid.conf'","'/etc/apache2/uid.conf'")."\n");
2045: if (!-e "/etc/apache2/uid.conf.original") {
2046: copy "/etc/apache2/uid.conf","/etc/apache2/uid.conf.original";
2047: }
1.9 raeburn 2048: copy "$instdir/sles-suse/uid.conf","/etc/apache2/uid.conf";
1.5 raeburn 2049: chmod(0444,"/etc/apache2/uid.conf");
1.1 raeburn 2050: }
2051:
2052: ###############################################
2053: ##
2054: ## Modify /etc/sysconfig/apache2
2055: ##
2056: ###############################################
2057: sub copy_sysconfig_apache2_file {
2058: my ($instdir) = @_;
2059: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'sysconfig/apache2'","'/etc/sysconfig/apache2'")."\n");
2060: if (!-e "/etc/sysconfig/apache2.original") {
2061: copy "/etc/sysconfig/apache2","/etc/sysconfig/apache2.original";
2062: }
1.9 raeburn 2063: copy "$instdir/sles-suse/sysconfig_apache2","/etc/sysconfig/apache2";
1.5 raeburn 2064: chmod(0444,"/etc/sysconfig/apache2");
1.1 raeburn 2065: }
2066:
2067: ###############################################
2068: ##
2069: ## Add/Modify /etc/insserv/overrides
2070: ##
2071: ###############################################
2072:
2073: sub update_SuSEfirewall2_setup {
2074: my ($instdir) = @_;
2075: print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'SuSEfirewall2_setup'","'/etc/insserv/overrides/SuSEfirewall2_setup'")."\n");
2076: if (!-e "/etc/insserv/overrides/SuSEfirewall2_setup") {
2077: if (!-d "/etc/insserv") {
2078: mkdir("/etc/insserv",0755);
2079: }
2080: if (!-d "/etc/insserv/overrides") {
2081: mkdir("/etc/insserv/overrides",0755);
2082: }
2083: } elsif (!-e "/etc/insserv/overrides/SuSEfirewall2_setup.original") {
2084: copy "/etc/insserv/overrides/SuSEfirewall2_setup","/etc/insserv/overrides/SuSEfirewall2_setup.original"
2085: }
1.9 raeburn 2086: copy "$instdir/sles-suse/SuSEfirewall2_setup","/etc/insserv/overrides/SuSEfirewall2_setup";
1.5 raeburn 2087: chmod(0444,"/etc/insserv/overrides/SuSEfirewall2_setup");
2088: }
2089:
2090: sub get_iptables_rules {
2091: my ($distro,$instdir,$apachefw) = @_;
2092: my (@fwchains,@ports);
2093: if (&firewall_is_active()) {
2094: my $iptables = &get_pathto_iptables();
2095: if ($iptables ne '') {
2096: @fwchains = &get_fw_chains($iptables,$distro);
2097: }
2098: }
2099: if (ref($apachefw) eq 'HASH') {
2100: foreach my $service ('http','https') {
2101: unless ($apachefw->{$service}) {
2102: push (@ports,$service);
2103: }
2104: }
2105: } else {
2106: @ports = ('http','https');
2107: }
2108: if (@ports == 0) {
2109: return;
2110: }
2111: my $ask_to_enable;
2112: if (-e "/etc/iptables.loncapa.rules") {
1.9 raeburn 2113: if (open(PIPE, "diff --brief $instdir/debian-ubuntu/iptables.loncapa.rules /etc/iptables.loncapa.rules |")) {
1.5 raeburn 2114: my $diffres = <PIPE>;
2115: close(PIPE);
2116: chomp($diffres);
2117: if ($diffres) {
2118: print &mt('Warning: [_1] exists but differs from LON-CAPA supplied file.','/etc/iptables.loncapa.rules')."\n";
2119: }
2120: } else {
2121: print &mt('Error: unable to open [_1] to compare contents with LON-CAPA supplied file.','/etc/iptables.loncapa.rules')."\n";
2122: }
2123: } else {
1.9 raeburn 2124: if (-e "$instdir/debian-ubuntu/iptables.loncapa.rules") {
2125: copy "$instdir/debian-ubuntu/iptables.loncapa.rules","/etc/iptables.loncapa.rules";
1.5 raeburn 2126: chmod(0600,"/etc/iptables.loncapa.rules");
2127: }
2128: }
2129: if (-e "/etc/iptables.loncapa.rules") {
2130: if (-e "/etc/network/if-pre-up.d/iptables") {
1.9 raeburn 2131: if (open(PIPE, "diff --brief $instdir/debian-ubuntu/iptables /etc/network/if-pre-up/iptables |")) {
1.5 raeburn 2132: my $diffres = <PIPE>;
2133: close(PIPE);
2134: chomp($diffres);
2135: if ($diffres) {
2136: print &mt('Warning: [_1] exists but differs from LON-CAPA supplied file.','/etc/network/if-pre-up.d/iptables')."\n";
2137: }
2138: } else {
2139: print &mt('Error: unable to open [_1] to compare contents with LON-CAPA supplied file.','/etc/network/if-pre-up.d/iptables')."\n";
2140: }
2141: } else {
1.9 raeburn 2142: copy "$instdir/debian-ubuntu/iptables","/etc/network/if-pre-up.d/iptables";
1.5 raeburn 2143: chmod(0755,"/etc/network/if-pre-up.d/iptables");
2144: 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'));
2145: $ask_to_enable = 1;
2146: }
2147: }
2148: return $ask_to_enable;
1.1 raeburn 2149: }
2150:
2151: sub download_loncapa {
2152: my ($instdir,$lctarball) = @_;
2153: my ($have_tarball,$updateshown);
2154: if (! -e "$instdir/$lctarball") {
2155: print_and_log(&mt('Retrieving LON-CAPA source files from: [_1]',
2156: 'http://install.loncapa.org')."\n");
2157: system("wget http://install.loncapa.org/versions/$lctarball ".
2158: "2>/dev/null 1>/dev/null");
2159: if (! -e "./$lctarball") {
2160: print &mt('Unable to retrieve LON-CAPA source files from: [_1].',
2161: "http://install.loncapa.org/versions/$lctarball")."\n";
2162: } else {
2163: $have_tarball = 1;
2164: }
2165: print_and_log("\n");
2166: } else {
2167: $have_tarball = 1;
2168: print_and_log("
2169: ------------------------------------------------------------------------
2170:
2171: ".&mt('You seem to have a version of loncapa-current.tar.gz in [_1]',$instdir)."\n".
2172: &mt('This copy will be used and a new version will NOT be downloaded.')."\n".
2173: &mt('If you wish, you may download a new version by executing:')."
2174:
1.2 raeburn 2175: wget http://install.loncapa.org/versions/loncapa-current.tar.gz
1.1 raeburn 2176:
2177: ------------------------------------------------------------------------
2178: ");
2179: }
2180:
2181: ##
2182: ## untar loncapa.tar.gz
2183: ##
2184: if ($have_tarball) {
2185: print_and_log(&mt('Extracting LON-CAPA source files')."\n");
2186: writelog(`cd ~root; tar zxf $instdir/$lctarball`);
2187: print_and_log("\n");
2188: print &mt('LON-CAPA source files extracted.')."\n".
2189: &mt('It remains for you to execute the following commands:')."
2190:
2191: cd /root/loncapa-N.N (N.N should correspond to a version number like '0.4')
2192: ./UPDATE
2193:
2194: ".&mt('If you have any trouble, please see [_1] and [_2]',
2195: 'http://install.loncapa.org/','http://help.loncapa.org/')."\n";
2196: $updateshown = 1;
2197: }
2198: return ($have_tarball,$updateshown);
2199: }
2200:
2201: close LOG;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>