--- doc/install/linux/install.pl 2016/08/09 15:20:45 1.37 +++ doc/install/linux/install.pl 2018/06/20 12:12:39 1.45 @@ -27,6 +27,9 @@ use strict; use File::Copy; use Term::ReadKey; use DBI; +use Cwd(); +use File::Basename(); +use lib File::Basename::dirname(Cwd::abs_path($0)); use LCLocalization::localize; # ========================================================= The language handle @@ -72,7 +75,7 @@ if (!open(LOG,">>loncapa_install.log")) &mt('Stopping execution.')."\n"; exit; } else { - print LOG '$Id: install.pl,v 1.37 2016/08/09 15:20:45 raeburn Exp $'."\n"; + print LOG '$Id: install.pl,v 1.45 2018/06/20 12:12:39 raeburn Exp $'."\n"; } # @@ -454,7 +457,7 @@ sub check_mysql_running { $proc_owner = 'mysql'; $use_systemctl = 1; } - if ($1 >= 22) { + if ($1 >= 19) { $mysqldaemon ='mariadb'; } } elsif ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) { @@ -467,6 +470,8 @@ sub check_mysql_running { } elsif ($distro =~ /^sles(\d+)/) { if ($1 >= 12) { $use_systemctl = 1; + $proc_owner = 'mysql'; + $process = 'mysqld'; } } elsif ($distro =~ /^suse(\d+)/) { if ($1 >= 13) { @@ -559,7 +564,15 @@ sub chkconfig { my $version = $1; @runlevels = qw/2 3 4 5/; @norunlevels = qw/0 1 6/; - $checker_bin = '/usr/sbin/sysv-rc-conf'; + if (($distro =~ /^ubuntu/) && ($version <= 16)) { + $checker_bin = '/usr/sbin/sysv-rc-conf'; + } else { + $uses_systemctl{'ntp'} = 1; + $uses_systemctl{'mysql'} = 1; + $uses_systemctl{'apache'} = 1; + $uses_systemctl{'memcached'} = 1; + $uses_systemctl{'cups'} = 1; + } $daemon{'mysql'} = 'mysql'; $daemon{'apache'} = 'apache2'; $daemon{'ntp'} = 'ntp'; @@ -577,7 +590,7 @@ sub chkconfig { $uses_systemctl{'memcached'} = 1; $uses_systemctl{'cups'} = 1; } - if ($version >= 22) { + if ($version >= 19) { $daemon{'mysql'} = 'mariadb'; } } elsif ($distro =~ /^(?:centos|rhes|scientific)(\d+)/) { @@ -1517,7 +1530,7 @@ if ($callsub{'firewall'}) { } if ($callsub{'stopsrvcs'}) { - &kill_extra_services($distro,$recommended->{'stopsrvcs'}); + &kill_extra_services($distro,$recommended->{'stopsrvcs'},$uses_systemctl); } else { &print_and_log(&mt('Skipping stopping unnecessary service ([_1] daemons).',"'cups','memcached'")."\n"); } @@ -1704,7 +1717,7 @@ END } sub kill_extra_services { - my ($distro,$stopsrvcs) = @_; + my ($distro,$stopsrvcs,$uses_systemctl) = @_; if (ref($stopsrvcs) eq 'HASH') { my @stopping = sort(keys(%{$stopsrvcs})); if (@stopping) { @@ -1735,8 +1748,19 @@ sub kill_extra_services { } } &print_and_log(&mt('Removing [_1] from startup.',$service)."\n"); - if ($distro =~ /^(debian|ubuntu)/) { - &print_and_log(`update-rc.d -f $daemon remove`); + if ($distro =~ /^(?:debian|ubuntu)(\d+)/) { + my $version = $1; + if (($distro =~ /^ubuntu/) && ($version > 16)) { + 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(`update-rc.d -f $daemon remove`); + } } else { if (ref($uses_systemctl) eq 'HASH') { if ($uses_systemctl->{$service}) { @@ -1786,14 +1810,28 @@ CREATE TABLE IF NOT EXISTS metadata (tit sub setup_mysql_permissions { my ($dbh,$has_pass,@mysql_lc_commands) = @_; - 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; + my ($mysqlversion,$mysqlsubver,$mysqlname) = &get_mysql_version(); + my ($usesauth,$hasauthcol,@mysql_commands); + if ($mysqlname =~ /^MariaDB/i) { + if ($mysqlversion >= 10.2) { + $usesauth = 1; + } elsif ($mysqlversion >= 5.5) { + $hasauthcol = 1; + } } else { - @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));"); + if (($mysqlversion > 5.7) || (($mysqlversion == 5.7) && ($mysqlsubver > 5))) { + $usesauth = 1; + } elsif (($mysqlversion >= 5.6) || (($mysqlversion == 5.5) && ($mysqlsubver >= 7))) { + $hasauthcol = 1; + } + } + if ($usesauth) { + @mysql_commands = ("INSERT user (Host, User, ssl_cipher, x509_issuer, x509_subject, authentication_string) VALUES('localhost','www','','','','')", + "ALTER USER 'www'\@'localhost' IDENTIFIED WITH mysql_native_password BY 'localhostkey'"); + } elsif ($hasauthcol) { + @mysql_commands = ("INSERT user (Host, User, Password, ssl_cipher, x509_issuer, x509_subject, authentication_string) VALUES('localhost','www',password('localhostkey'),'','','','');"); + } else { + @mysql_commands = ("INSERT user (Host, User, Password, ssl_cipher, x509_issuer, x509_subject) VALUES('localhost','www',password('localhostkey'),'','','');"); } if ($mysqlversion < 4) { push (@mysql_commands," @@ -1844,7 +1882,7 @@ INSERT db (Host,Db,User,Select_priv,Inse } } if ($got_passwd) { - my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass); + my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass,$usesauth); push(@mysql_commands,@newpass_cmds); } else { print_and_log(&mt('Failed to get MySQL root password from user input.')."\n"); @@ -1853,7 +1891,6 @@ INSERT db (Host,Db,User,Select_priv,Inse if (@mysql_commands) { foreach my $cmd (@mysql_commands) { $dbh->do($cmd) || print $dbh->errstr."\n"; - } } if (@mysql_lc_commands) { @@ -1877,7 +1914,7 @@ INSERT db (Host,Db,User,Select_priv,Inse sub new_mysql_rootpasswd { my ($currmysqlpass,$usesauth) = @_; if ($usesauth) { - return ("ALTER USER 'root'\@'localhost' IDENTIFIED BY '$currmysqlpass'", + return ("ALTER USER 'root'\@'localhost' IDENTIFIED WITH mysql_native_password BY '$currmysqlpass'", "FLUSH PRIVILEGES;"); } else { return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')", @@ -1886,17 +1923,17 @@ sub new_mysql_rootpasswd { } sub get_mysql_version { - my ($version,$subversion); + my ($version,$subversion,$name); if (open(PIPE," mysql -V |")) { my $info = ; chomp($info); close(PIPE); - ($version,$subversion) = ($info =~ /(\d+\.\d+)\.(\d+)[\-\w]*,/); + ($version,$subversion,$name) = ($info =~ /(\d+\.\d+)\.(\d+)\-?(\w*),/); } else { print &mt('Could not determine which version of MySQL is installed.'). "\n"; } - return ($version,$subversion); + return ($version,$subversion,$name); } ###########################################################