--- doc/install/linux/install.pl 2014/12/19 20:23:36 1.34 +++ doc/install/linux/install.pl 2016/08/09 15:20:45 1.37 @@ -72,7 +72,7 @@ if (!open(LOG,">>loncapa_install.log")) &mt('Stopping execution.')."\n"; exit; } else { - print LOG '$Id: install.pl,v 1.34 2014/12/19 20:23:36 raeburn Exp $'."\n"; + print LOG '$Id: install.pl,v 1.37 2016/08/09 15:20:45 raeburn Exp $'."\n"; } # @@ -386,7 +386,7 @@ sub check_required { return ($distro,$gotprereqs,$localecmd); } my ($mysqlon,$mysqlsetup,$mysqlrestart,$dbh,$has_pass,$has_lcdb,%recommended, - $downloadstatus,$filetouse,$production,$testing,$apachefw,$tostop); + $downloadstatus,$filetouse,$production,$testing,$apachefw,$tostop,$uses_systemctl); my $wwwuid = &uid_of_www(); my $wwwgid = getgrnam('www'); if (($wwwuid eq '') || ($wwwgid eq '')) { @@ -424,14 +424,14 @@ sub check_required { } } ($recommended{'firewall'},$apachefw) = &chkfirewall($distro); - ($recommended{'runlevels'},$tostop) = &chkconfig($distro,$instdir); + ($recommended{'runlevels'},$tostop,$uses_systemctl) = &chkconfig($distro,$instdir); $recommended{'apache'} = &chkapache($distro,$instdir); $recommended{'stopsrvcs'} = &chksrvcs($distro,$tostop); ($recommended{'download'},$downloadstatus,$filetouse,$production,$testing) = &need_download(); return ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow, $mysqlrestart,\%recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus, - $filetouse,$production,$testing,$apachefw); + $filetouse,$production,$testing,$apachefw,$uses_systemctl); } sub check_mysql_running { @@ -448,23 +448,32 @@ sub check_mysql_running { $process = 'mysqld'; $proc_owner = 'mysql'; } - } - if ($distro =~ /^fedora(\d+)/) { + } elsif ($distro =~ /^fedora(\d+)/) { if ($1 >= 16) { $process = 'mysqld'; $proc_owner = 'mysql'; $use_systemctl = 1; } - } - if ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) { + if ($1 >= 22) { + $mysqldaemon ='mariadb'; + } + } elsif ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) { if ($1 >= 7) { $mysqldaemon ='mariadb'; $process = 'mysqld'; $proc_owner = 'mysql'; $use_systemctl = 1; } + } elsif ($distro =~ /^sles(\d+)/) { + if ($1 >= 12) { + $use_systemctl = 1; + } + } elsif ($distro =~ /^suse(\d+)/) { + if ($1 >= 13) { + $use_systemctl = 1; + } } - if (open(PIPE,"ps -ef |grep $process |grep ^$proc_owner 2>&1 |")) { + if (open(PIPE,"ps -ef |grep $process |grep ^$proc_owner |grep -v grep 2>&1 |")) { my $status = ; close(PIPE); chomp($status); @@ -532,9 +541,18 @@ sub chkconfig { if ($distro =~ /^(suse|sles)9/) { $daemon{'apache'} = 'apache'; } - if ($distro =~ /^suse(\d+)/) { - if ($1 > 11) { + if ($distro =~ /^(suse|sles)([\d\.]+)/) { + my $name = $1; + my $num = $2; + if ($num > 11) { $uses_systemctl{'apache'} = 1; + if (($name eq 'sles') || ($name eq 'suse' && $num >= 13.2)) { + $uses_systemctl{'mysql'} = 1; + $uses_systemctl{'ntp'} = 1; + $uses_systemctl{'cups'} = 1; + $uses_systemctl{'memcached'} = 1; + $daemon{'ntp'} = 'ntpd'; + } } } } elsif ($distro =~ /^(?:debian|ubuntu)(\d+)/) { @@ -556,6 +574,11 @@ sub chkconfig { if ($version >= 16) { $uses_systemctl{'mysql'} = 1; $uses_systemctl{'apache'} = 1; + $uses_systemctl{'memcached'} = 1; + $uses_systemctl{'cups'} = 1; + } + if ($version >= 22) { + $daemon{'mysql'} = 'mariadb'; } } elsif ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) { my $version = $1; @@ -563,6 +586,8 @@ sub chkconfig { $uses_systemctl{'ntp'} = 1; $uses_systemctl{'mysql'} = 1; $uses_systemctl{'apache'} = 1; + $uses_systemctl{'memcached'} = 1; + $uses_systemctl{'cups'} = 1; $daemon{'mysql'} = 'mariadb'; } } @@ -586,13 +611,18 @@ sub chkconfig { foreach my $type ('apache','mysql','ntp','cups','memcached') { my $service = $daemon{$type}; if ($uses_systemctl{$type}) { - if (!-l "/etc/systemd/system/multi-user.target.wants/$service.service") { - $needfix{$type} = "systemctl enable $service.service"; + if (($type eq 'memcached') || ($type eq 'cups')) { + if (-l "/etc/systemd/system/multi-user.target.wants/$service.service") { + $tostop{$type} = 1; + } + } else { + if (!-l "/etc/systemd/system/multi-user.target.wants/$service.service") { + $needfix{$type} = "systemctl enable $service.service"; + } } - next; } else { my $command = $checker_bin.' --list '.$service.' 2>/dev/null'; - if ($type eq 'cups') { + if ($type eq 'cups') { if ($distro =~ /^(?:debian|ubuntu)(\d+)/) { my $version = $1; if (($distro =~ /^ubuntu/) && ($version <= 8)) { @@ -649,7 +679,7 @@ sub chkconfig { } } } - return (\%needfix,\%tostop); + return (\%needfix,\%tostop,\%uses_systemctl); } sub chkfirewall { @@ -1249,7 +1279,7 @@ print "\n".&mt('Checking system status . my $dsn = "DBI:mysql:database=mysql"; my ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow,$mysqlrestart, $recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus,$filetouse,$production, - $testing,$apachefw) = &check_required($instdir,$dsn); + $testing,$apachefw,$uses_systemctl) = &check_required($instdir,$dsn); if ($distro eq '') { print "\n".&mt('Linux distribution could not be verified as a supported distribution.')."\n". &mt('The following are supported: [_1].', @@ -1293,7 +1323,7 @@ if (!$gotprereqs) { } else { ($distro,$gotprereqs,$localecmd,$packagecmd,$updatecmd,$installnow, $mysqlrestart,$recommended,$dbh,$has_pass,$has_lcdb,$downloadstatus, - $filetouse,$production,$testing,$apachefw) = + $filetouse,$production,$testing,$apachefw,$uses_systemctl) = &check_required($instdir,$dsn); } } else { @@ -1708,7 +1738,17 @@ sub kill_extra_services { if ($distro =~ /^(debian|ubuntu)/) { &print_and_log(`update-rc.d -f $daemon remove`); } else { - &print_and_log(`/sbin/chkconfig --del $service`); + if (ref($uses_systemctl) eq 'HASH') { + if ($uses_systemctl->{$service}) { + if (`systemctl is-enabled $service`) { + &print_and_log(`systemctl disable $service`); + } + } else { + &print_and_log(`/sbin/chkconfig --del $service`); + } + } else { + &print_and_log(`/sbin/chkconfig --del $service`); + } } } } @@ -1746,8 +1786,15 @@ CREATE TABLE IF NOT EXISTS metadata (tit sub setup_mysql_permissions { my ($dbh,$has_pass,@mysql_lc_commands) = @_; - my $mysqlversion = &get_mysql_version(); - my @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));"); + my ($mysqlversion,$mysqlsubver) = &get_mysql_version(); + my ($usesauth,@mysql_commands); + if (($mysqlversion > 5.7) || (($mysqlversion == 5.7) && ($mysqlsubver > 5))) { + @mysql_commands = ("INSERT user (Host, User, ssl_cipher, x509_issuer, x509_subject) VALUES('localhost','www','','','')", + "ALTER USER 'www'\@'localhost' IDENTIFIED BY 'localhostkey'"); + $usesauth = 1; + } else { + @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));"); + } if ($mysqlversion < 4) { push (@mysql_commands," 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')"); @@ -1828,23 +1875,28 @@ INSERT db (Host,Db,User,Select_priv,Inse } sub new_mysql_rootpasswd { - my ($currmysqlpass) = @_; - return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')", - "FLUSH PRIVILEGES;"); + my ($currmysqlpass,$usesauth) = @_; + if ($usesauth) { + return ("ALTER USER 'root'\@'localhost' IDENTIFIED BY '$currmysqlpass'", + "FLUSH PRIVILEGES;"); + } else { + return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')", + "FLUSH PRIVILEGES;"); + } } sub get_mysql_version { - my $version; + my ($version,$subversion); if (open(PIPE," mysql -V |")) { my $info = ; chomp($info); close(PIPE); - ($version) = ($info =~ /(\d+\.\d+)\.\d+,/); + ($version,$subversion) = ($info =~ /(\d+\.\d+)\.(\d+)[\-\w]*,/); } else { print &mt('Could not determine which version of MySQL is installed.'). "\n"; } - return $version; + return ($version,$subversion); } ###########################################################