--- doc/install/linux/install.pl 2014/10/29 20:56:18 1.32 +++ doc/install/linux/install.pl 2014/12/19 20:23:36 1.34 @@ -72,7 +72,7 @@ if (!open(LOG,">>loncapa_install.log")) &mt('Stopping execution.')."\n"; exit; } else { - print LOG '$Id: install.pl,v 1.32 2014/10/29 20:56:18 raeburn Exp $'."\n"; + print LOG '$Id: install.pl,v 1.34 2014/12/19 20:23:36 raeburn Exp $'."\n"; } # @@ -385,8 +385,8 @@ sub check_required { unless ($localecmd eq '') { return ($distro,$gotprereqs,$localecmd); } - my ($mysqlon,$mysqlsetup,$dbh,$has_pass,$has_lcdb,%recommended,$downloadstatus, - $filetouse,$production,$testing,$apachefw,$tostop); + my ($mysqlon,$mysqlsetup,$mysqlrestart,$dbh,$has_pass,$has_lcdb,%recommended, + $downloadstatus,$filetouse,$production,$testing,$apachefw,$tostop); my $wwwuid = &uid_of_www(); my $wwwgid = getgrnam('www'); if (($wwwuid eq '') || ($wwwgid eq '')) { @@ -398,20 +398,29 @@ sub check_required { $mysqlon = &check_mysql_running($distro); if ($mysqlon) { my $mysql_has_wwwuser = &check_mysql_wwwuser(); - ($mysqlsetup,$has_pass,$dbh) = - &check_mysql_setup($instdir,$dsn); - if ($mysqlsetup eq 'noroot') { - $recommended{'mysqlperms'} = 1; + ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser) = + &check_mysql_setup($instdir,$dsn,$distro,$mysql_has_wwwuser); + if ($mysqlsetup eq 'needsrestart') { + $mysqlrestart = ''; + if ($distro eq 'ubuntu') { + $mysqlrestart = 'sudo '; + } + $mysqlrestart .= 'service mysql restart'; + return ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,$mysqlrestart); } else { - unless ($mysql_has_wwwuser) { + if ($mysqlsetup eq 'noroot') { $recommended{'mysqlperms'} = 1; + } else { + unless ($mysql_has_wwwuser) { + $recommended{'mysqlperms'} = 1; + } + } + if ($dbh) { + $has_lcdb = &check_loncapa_mysqldb($dbh); + } + unless ($has_lcdb) { + $recommended{'mysql'} = 1; } - } - if ($dbh) { - $has_lcdb = &check_loncapa_mysqldb($dbh); - } - unless ($has_lcdb) { - $recommended{'mysql'} = 1; } } ($recommended{'firewall'},$apachefw) = &chkfirewall($distro); @@ -421,7 +430,7 @@ sub check_required { ($recommended{'download'},$downloadstatus,$filetouse,$production,$testing) = &need_download(); return ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow, - \%recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus, + $mysqlrestart,\%recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus, $filetouse,$production,$testing,$apachefw); } @@ -455,7 +464,7 @@ sub check_mysql_running { $use_systemctl = 1; } } - if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) { + if (open(PIPE,"ps -ef |grep $process |grep ^$proc_owner 2>&1 |")) { my $status = ; close(PIPE); chomp($status); @@ -685,16 +694,26 @@ sub chkapache { if ($distro =~ /^(debian|ubuntu)(\d+)$/) { my $distname = $1; my $version = $2; - if (!-e "$instdir/debian-ubuntu/loncapa") { + my ($stdconf,$stdsite); + if (($distname eq 'ubuntu') && ($version > 12)) { + $stdconf = "$instdir/debian-ubuntu/ubuntu14/loncapa_conf"; + $stdsite = "$instdir/debian-ubuntu/ubuntu14/loncapa_sites"; + } else { + $stdconf = "$instdir/debian-ubuntu/loncapa"; + } + if (!-e $stdconf) { $fixapache = 0; print &mt('Warning: No LON-CAPA Apache configuration file found for installation check.')."\n"; } else { - my $configfile = "/etc/apache2/sites-available/loncapa"; + my ($configfile,$sitefile); if (($distname eq 'ubuntu') && ($version > 12)) { + $sitefile = '/etc/apache2/sites-available/loncapa'; $configfile = "/etc/apache2/conf-available/loncapa"; + } else { + $configfile = "/etc/apache2/sites-available/loncapa"; } - if (-e $configfile) { - if (open(PIPE, "diff --brief $instdir/debian-ubuntu/loncapa $configfile |")) { + if (($configfile ne '') && (-e $configfile) && (-e $stdconf)) { + if (open(PIPE, "diff --brief $stdconf $configfile |")) { my $diffres = ; close(PIPE); chomp($diffres); @@ -703,6 +722,18 @@ sub chkapache { } } } + if ((!$fixapache) && ($distname eq 'ubuntu') && ($version > 12)) { + if (($sitefile ne '') && (-e $sitefile) && (-e $stdsite)) { + if (open(PIPE, "diff --brief $stdsite $sitefile |")) { + my $diffres = ; + close(PIPE); + chomp($diffres); + unless ($diffres) { + $fixapache = 0; + } + } + } + } } if (!$fixapache) { foreach my $module ('headers.load','expires.load') { @@ -900,13 +931,36 @@ sub need_download { } sub check_mysql_setup { - my ($instdir,$dsn) = @_; + my ($instdir,$dsn,$distro,$mysql_has_wwwuser) = @_; my ($mysqlsetup,$has_pass); my $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0}); if ($dbh) { $mysqlsetup = 'noroot'; } elsif ($DBI::err =~ /1045/) { $has_pass = 1; + } elsif ($distro =~ /^ubuntu(\d+)$/) { + my $version = $1; + if ($1 > 12) { + print_and_log(&mt('Restarting mysql, please be patient')."\n"); + if (open (PIPE, "service mysql restart 2>&1 |")) { + while () { + print $_; + } + close(PIPE); + } + unless ($mysql_has_wwwuser) { + $mysql_has_wwwuser = &check_mysql_wwwuser(); + } + $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0}); + if ($dbh) { + $mysqlsetup = 'noroot'; + } elsif ($DBI::err =~ /1045/) { + $has_pass = 1; + } else { + $mysqlsetup = 'needsrestart'; + return ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser); + } + } } if ($has_pass) { print &mt('You have already set a root password for the MySQL database.')."\n"; @@ -933,11 +987,11 @@ sub check_mysql_setup { } } } - } elsif ($mysqlsetup ne 'noroot') { + } elsif ($mysqlsetup ne 'noroot') { print_and_log(&mt('Problem accessing MySQL.')."\n"); $mysqlsetup = 'rootfail'; } - return ($mysqlsetup,$has_pass,$dbh); + return ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser); } sub check_mysql_wwwuser { @@ -1193,8 +1247,8 @@ my %prompts = &texthash( print "\n".&mt('Checking system status ...')."\n"; my $dsn = "DBI:mysql:database=mysql"; -my ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,$recommended, - $dbh,$has_pass,$has_lcdb,$downloadstatus,$filetouse,$production, +my ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,$mysqlrestart, + $recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,$filetouse,$production, $testing,$apachefw) = &check_required($instdir,$dsn); if ($distro eq '') { print "\n".&mt('Linux distribution could not be verified as a supported distribution.')."\n". @@ -1204,6 +1258,13 @@ if ($distro eq '') { &mt('Stopping execution.')."\n"; exit; } +if ($mysqlrestart) { + print "\n".&mt('The mysql daemon needs to be restarted using the following command:')."\n". + $mysqlrestart."\n\n". + &mt('Stopping execution of install.pl script.')."\n". + &mt('Please run the install.pl script again, once you have restarted mysql.')."\n"; + exit; +} if ($localecmd ne '') { 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"; 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". @@ -1231,7 +1292,7 @@ if (!$gotprereqs) { exit; } else { ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow, - $recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus, + $mysqlrestart,$recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus, $filetouse,$production,$testing,$apachefw) = &check_required($instdir,$dsn); } @@ -1855,7 +1916,7 @@ sub copy_apache2_debconf { if (-e "$apache2_conf_available_dir/loncapa") { copy("$apache2_conf_available_dir/loncapa","$apache2_conf_available_dir/loncapa.original"); } - my $defaultconf = $apache2_conf_available_dir.'/loncapa.conf'; + my $defaultconf = $apache2_conf_enabled_dir.'/loncapa.conf'; copy("$instdir/debian-ubuntu/ubuntu14/loncapa_conf","$apache2_conf_available_dir/loncapa"); chmod(0444,"$apache2_conf_available_dir/loncapa"); if (-l $defaultconf) {