--- doc/install/linux/install.pl 2011/05/05 16:38:07 1.11 +++ doc/install/linux/install.pl 2011/05/31 13:29:46 1.19 @@ -72,7 +72,7 @@ if (!open(LOG,">>loncapa_install.log")) &mt('Stopping execution.')."\n"; exit; } else { - print LOG '$Id: install.pl,v 1.11 2011/05/05 16:38:07 raeburn Exp $'."\n"; + print LOG '$Id: install.pl,v 1.19 2011/05/31 13:29:46 raeburn Exp $'."\n"; } # @@ -219,7 +219,7 @@ sub get_distro { } } elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) { $distro = 'suse'.$1; - $updatecmd = 'yast -i LONCAPA-preprequisites'; + $updatecmd = 'yast -i LONCAPA-prerequisites'; } elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) { $distro = 'suse'.$1; if ($1 >= 10.3 ) { @@ -425,21 +425,31 @@ sub check_mysql_running { print_and_log(&mt('MySQL is running.')."\n"); return 1; } else { - system("/etc/rc.d/init.d/$mysqldaemon start"); + system("/etc/init.d/$mysqldaemon start >/dev/null 2>&1 "); print_and_log(&mt('Waiting for MySQL to start.')."\n"); sleep 5; - if (open (PIPE, "/etc/init.d/$mysqldaemon 2>&1 |")) { - my $status = ; + if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) { + $status = ; close(PIPE); chomp($status); - if ($status =~ /\(pid\s+\d\)/) { + if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) { print_and_log(&mt('MySQL is running.')."\n"); return 1; } else { - print_and_log(&mt('Unable to start MySQL.')."\n"); + print_and_log(&mt('Still waiting for MySQL to start.')."\n"); + sleep 5; + if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) { + $status = ; + close(PIPE); + chomp($status); + if ($status =~ /^\Q$proc_owner\E\s+\d+\s+/) { + print_and_log(&mt('MySQL is running.')."\n"); + return 1; + } else { + print_and_log(&mt('Given up waiting for MySQL to start.')."\n"); + } + } } - } else { - print_and_log(&mt('Unable to start MySQL.')."\n"); } } } else { @@ -490,6 +500,17 @@ sub chkconfig { my $nrlstr = join('',@norunlevels); foreach my $type ('apache','mysql','ntp','cups','memcached') { my $service = $daemon{$type}; + if ($type eq 'ntp') { + if ($distro =~ /^(?:fedora)(\d+)/) { + my $version = $1; + if ($version >= 15) { + if (!-l "/etc/systemd/system/multi-user.target.wants/ntpd.service") { + $needfix{$type} = 'systemctl enable ntpd.service'; + } + next; + } + } + } my $command = $checker_bin.' --list '.$service.' 2>/dev/null'; if ($type eq 'cups') { if ($distro =~ /^(?:debian|ubuntu)(\d+)/) { @@ -590,11 +611,11 @@ sub chkapache { my ($distro,$instdir) = @_; my $fixapache = 1; if ($distro =~ /^(debian|ubuntu)/) { - if (!-e "$instdir/debian-ubuntu/apache2.conf") { + if (!-e "$instdir/debian-ubuntu/loncapa") { $fixapache = 0; print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n"; - } elsif ((-e "/etc/apache2/sites-available/loncapa") && (-e "$instdir/debian-ubuntu/apache2.conf")) { - if (open(PIPE, "diff --brief $instdir/debian-ubuntu/apache2.conf /etc/apache2/sites-available/loncapa |")) { + } elsif ((-e "/etc/apache2/sites-available/loncapa") && (-e "$instdir/debian-ubuntu/loncapa")) { + if (open(PIPE, "diff --brief $instdir/debian-ubuntu/loncapa /etc/apache2/sites-available/loncapa |")) { my $diffres = ; close(PIPE); chomp($diffres); @@ -643,11 +664,21 @@ sub chkapache { } } } else { - if (!-e "$instdir/centos-rhes-fedora-sl/httpd.conf") { + my $configfile = 'httpd.conf'; + if ($distro =~ /^(?:centos|rhes|scientific)(\d+)$/) { + if ($1 > 5) { + $configfile = 'new/httpd.conf'; + } + } elsif ($distro =~ /^fedora(\d+)$/) { + if ($1 > 10) { + $configfile = 'new/httpd.conf'; + } + } + if (!-e "$instdir/centos-rhes-fedora-sl/$configfile") { $fixapache = 0; print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n"; - } elsif ((-e "/etc/httpd/conf/httpd.conf") && (-e "$instdir/centos-rhes-fedora-sl/httpd.conf")) { - if (open(PIPE, "diff --brief $instdir/centos-rhes-fedora-sl/httpd.conf /etc/httpd/conf/httpd.conf |")) { + } elsif ((-e "/etc/httpd/conf/httpd.conf") && (-e "$instdir/centos-rhes-fedora-sl/$configfile")) { + if (open(PIPE, "diff --brief $instdir/centos-rhes-fedora-sl/$configfile /etc/httpd/conf/httpd.conf |")) { my $diffres = ; close(PIPE); chomp($diffres); @@ -678,8 +709,12 @@ sub chksrvcs { chomp($daemonrunning); close(PIPE); if ($daemonrunning) { - if ($service eq 'memcached') { - unless ($daemonrunning =~ m{^www[^/]+\Q/usr/sbin/memcached -m 400 -v\E$}) { + if ($service eq 'memcached') { + my $cmd = '/usr/bin/memcached'; + if ($distro =~ /^(suse|sles)/) { + $cmd = '/usr/sbin/memcached'; + } + unless ($daemonrunning =~ m{^www[^/]+\Q$cmd -m 400 -v\E$}) { $stopsrvcs{$service} = 1; } } else { @@ -823,7 +858,8 @@ sub check_mysql_setup { sub check_mysql_wwwuser { my $mysql_wwwuser; - my $dbhn = DBI->connect("DBI:mysql:database=information_schema",'www','localhostkey'); + my $dbhn = DBI->connect("DBI:mysql:database=information_schema",'www','localhostkey', + {PrintError => +0}) || return; if ($dbhn) { $mysql_wwwuser = 1; $dbhn->disconnect; @@ -1092,7 +1128,7 @@ if ($localecmd ne '') { exit; } if (!$gotprereqs) { - print "\n".&mt('The LONCAPA-prequisites package is not installed.')."\n". + print "\n".&mt('The LONCAPA-prerequisites package is not installed.')."\n". &mt('The following command can be used to install the package (and dependencies):')."\n\n". $updatecmd."\n\n"; if ($installnow eq '') { @@ -1106,7 +1142,7 @@ if (!$gotprereqs) { close(PIPE); $gotprereqs = &check_prerequisites($packagecmd,$distro); if (!$gotprereqs) { - print &mt('The LONCAPA-prequisites package is not installed.')."\n". + print &mt('The LONCAPA-prerequisites package is not installed.')."\n". &mt('Stopping execution.')."\n"; exit; } else { @@ -1116,7 +1152,7 @@ if (!$gotprereqs) { &check_required($instdir,$dsn); } } else { - print &mt('Failed to run command to install LONCAPA-prequisites')."\n"; + print &mt('Failed to run command to install LONCAPA-prerequisites')."\n"; exit; } } else { @@ -1240,7 +1276,7 @@ if ($callsub{'apache'}) { } elsif ($distro =~ /^(debian|ubuntu)/) { ©_apache2_debconf($instdir); } else { - ©_httpd_conf($instdir); + ©_httpd_conf($instdir,$distro); } } else { print_and_log(&mt('Skipping configuration of Apache web server.')."\n"); @@ -1461,7 +1497,7 @@ ENDPATCH ## Compile patched pwauth ## print_and_log(&mt('Compiling pwauth')."\n"); - my $result = `cd $dir/; make`; + my $result = `cd $dir/; make 2>/dev/null `; my $expected = <<"END"; gcc -g -c -o pwauth.o pwauth.c gcc -o pwauth -g pwauth.o -lcrypt @@ -1510,16 +1546,24 @@ sub kill_extra_services { if (($distro =~ /^ubuntu/) && ($version <= 8)) { $daemon = 'cupsys'; } - } elsif ($distro =~ /^(?:suse|sles|scientific)/) { + } else { $daemon = 'cups'; } } - &print_and_log(`/etc/init.d/$daemon stop`); + my $cmd = "ps -ef |grep '$daemon' |grep -v grep"; + if (open(PIPE,'-|',$cmd)) { + my $daemonrunning = ; + chomp($daemonrunning); + close(PIPE); + if ($daemonrunning) { + &print_and_log(`/etc/init.d/$daemon stop`); + } + } &print_and_log(&mt('Removing [_1] from startup.',$service)."\n"); if ($distro =~ /^(debian|ubuntu)/) { &print_and_log(`update-rc.d -f $daemon remove`); } else { - &print_and_log(`chkconfig --del $service`); + &print_and_log(`/sbin/chkconfig --del $service`); } } } @@ -1536,7 +1580,7 @@ sub setup_mysql { } push(@mysql_lc_commands,"USE loncapa"); push(@mysql_lc_commands,qq{ -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 +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 }); if ($setup_mysql_permissions) { &setup_mysql_permissions($dbh,$has_pass,@mysql_lc_commands); @@ -1666,18 +1710,28 @@ sub get_mysql_version { ########################################################### sub copy_httpd_conf { - my ($instdir) = @_; + my ($instdir,$distro) = @_; + my $configfile = 'httpd.conf'; + if ($distro =~ /^(?:centos|rhes|scientific)(\d+)$/) { + if ($1 > 5) { + $configfile = 'new/httpd.conf'; + } + } elsif ($distro =~ /^fedora(\d+)$/) { + if ($1 > 10) { + $configfile = 'new/httpd.conf'; + } + } print_and_log(&mt('Copying the LON-CAPA [_1] to [_2].',"'httpd.conf'", "'/etc/httpd/conf/httpd.conf'")."\n"); copy "/etc/httpd/conf/httpd.conf","/etc/httpd/conf/httpd.conf.original"; - copy "$instdir/centos-rhes-fedora-sl/httpd.conf","/etc/httpd/conf/httpd.conf"; + copy "$instdir/centos-rhes-fedora-sl/$configfile","/etc/httpd/conf/httpd.conf"; chmod(0444,"/etc/httpd/conf/httpd.conf"); print_and_log("\n"); } ######################################################### ## -## Ubuntu/Debian -- copy our apache2 configuration file to +## Ubuntu/Debian -- copy our loncapa configuration file to ## sites-available and set the symlink from sites-enabled. ## ######################################################### @@ -1693,7 +1747,7 @@ sub copy_apache2_debconf { if (-e "$apache2_sites_available_dir/loncapa") { copy("$apache2_sites_available_dir/loncapa","$apache2_sites_available_dir/loncapa.original"); } - copy("$instdir/debian-ubuntu/apache2.conf","$apache2_sites_available_dir/loncapa"); + copy("$instdir/debian-ubuntu/loncapa","$apache2_sites_available_dir/loncapa"); chmod(0444,"$apache2_sites_available_dir/loncapa"); symlink("$apache2_sites_available_dir/loncapa","$apache2_sites_enabled_dir/000-default"); my $apache2_mods_enabled_dir = '/etc/apache2/mods-enabled';