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