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