[LON-CAPA-cvs] cvs: doc /install/linux install.pl
raeburn
raeburn at source.lon-capa.org
Fri Dec 19 15:23:37 EST 2014
raeburn Fri Dec 19 20:23:37 2014 EDT
Modified files:
/doc/install/linux install.pl
Log:
- Ubuntu 14 sometimes needs a restart of mysql before install.pl will connect
to it to verify set up status.
Index: doc/install/linux/install.pl
diff -u doc/install/linux/install.pl:1.33 doc/install/linux/install.pl:1.34
--- doc/install/linux/install.pl:1.33 Fri Dec 19 14:34:36 2014
+++ doc/install/linux/install.pl Fri Dec 19 20:23:36 2014
@@ -72,7 +72,7 @@
&mt('Stopping execution.')."\n";
exit;
} else {
- print LOG '$Id: install.pl,v 1.33 2014/12/19 14:34:36 raeburn Exp $'."\n";
+ print LOG '$Id: install.pl,v 1.34 2014/12/19 20:23:36 raeburn Exp $'."\n";
}
#
@@ -385,8 +385,8 @@
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 @@
$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 @@
($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 @@
$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 = <PIPE>;
close(PIPE);
chomp($status);
@@ -922,13 +931,36 @@
}
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 (<PIPE>) {
+ 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";
@@ -955,11 +987,11 @@
}
}
}
- } 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 {
@@ -1215,8 +1247,8 @@
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".
@@ -1226,6 +1258,13 @@
&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".
@@ -1253,7 +1292,7 @@
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);
}
More information about the LON-CAPA-cvs
mailing list