version 1.39, 2016/08/28 16:15:53
|
version 1.45, 2018/06/20 12:12:39
|
Line 27 use strict;
|
Line 27 use strict;
|
use File::Copy; |
use File::Copy; |
use Term::ReadKey; |
use Term::ReadKey; |
use DBI; |
use DBI; |
|
use Cwd(); |
|
use File::Basename(); |
|
use lib File::Basename::dirname(Cwd::abs_path($0)); |
use LCLocalization::localize; |
use LCLocalization::localize; |
|
|
# ========================================================= The language handle |
# ========================================================= The language handle |
Line 467 sub check_mysql_running {
|
Line 470 sub check_mysql_running {
|
} elsif ($distro =~ /^sles(\d+)/) { |
} elsif ($distro =~ /^sles(\d+)/) { |
if ($1 >= 12) { |
if ($1 >= 12) { |
$use_systemctl = 1; |
$use_systemctl = 1; |
|
$proc_owner = 'mysql'; |
|
$process = 'mysqld'; |
} |
} |
} elsif ($distro =~ /^suse(\d+)/) { |
} elsif ($distro =~ /^suse(\d+)/) { |
if ($1 >= 13) { |
if ($1 >= 13) { |
Line 559 sub chkconfig {
|
Line 564 sub chkconfig {
|
my $version = $1; |
my $version = $1; |
@runlevels = qw/2 3 4 5/; |
@runlevels = qw/2 3 4 5/; |
@norunlevels = qw/0 1 6/; |
@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{'mysql'} = 'mysql'; |
$daemon{'apache'} = 'apache2'; |
$daemon{'apache'} = 'apache2'; |
$daemon{'ntp'} = 'ntp'; |
$daemon{'ntp'} = 'ntp'; |
Line 1517 if ($callsub{'firewall'}) {
|
Line 1530 if ($callsub{'firewall'}) {
|
} |
} |
|
|
if ($callsub{'stopsrvcs'}) { |
if ($callsub{'stopsrvcs'}) { |
&kill_extra_services($distro,$recommended->{'stopsrvcs'}); |
&kill_extra_services($distro,$recommended->{'stopsrvcs'},$uses_systemctl); |
} else { |
} else { |
&print_and_log(&mt('Skipping stopping unnecessary service ([_1] daemons).',"'cups','memcached'")."\n"); |
&print_and_log(&mt('Skipping stopping unnecessary service ([_1] daemons).',"'cups','memcached'")."\n"); |
} |
} |
Line 1704 END
|
Line 1717 END
|
} |
} |
|
|
sub kill_extra_services { |
sub kill_extra_services { |
my ($distro,$stopsrvcs) = @_; |
my ($distro,$stopsrvcs,$uses_systemctl) = @_; |
if (ref($stopsrvcs) eq 'HASH') { |
if (ref($stopsrvcs) eq 'HASH') { |
my @stopping = sort(keys(%{$stopsrvcs})); |
my @stopping = sort(keys(%{$stopsrvcs})); |
if (@stopping) { |
if (@stopping) { |
Line 1735 sub kill_extra_services {
|
Line 1748 sub kill_extra_services {
|
} |
} |
} |
} |
&print_and_log(&mt('Removing [_1] from startup.',$service)."\n"); |
&print_and_log(&mt('Removing [_1] from startup.',$service)."\n"); |
if ($distro =~ /^(debian|ubuntu)/) { |
if ($distro =~ /^(?:debian|ubuntu)(\d+)/) { |
&print_and_log(`update-rc.d -f $daemon remove`); |
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 { |
} else { |
if (ref($uses_systemctl) eq 'HASH') { |
if (ref($uses_systemctl) eq 'HASH') { |
if ($uses_systemctl->{$service}) { |
if ($uses_systemctl->{$service}) { |
Line 1787 CREATE TABLE IF NOT EXISTS metadata (tit
|
Line 1811 CREATE TABLE IF NOT EXISTS metadata (tit
|
sub setup_mysql_permissions { |
sub setup_mysql_permissions { |
my ($dbh,$has_pass,@mysql_lc_commands) = @_; |
my ($dbh,$has_pass,@mysql_lc_commands) = @_; |
my ($mysqlversion,$mysqlsubver,$mysqlname) = &get_mysql_version(); |
my ($mysqlversion,$mysqlsubver,$mysqlname) = &get_mysql_version(); |
my ($usesauth,@mysql_commands); |
my ($usesauth,$hasauthcol,@mysql_commands); |
if ($mysqlname =~ /^MariaDB/i) { |
if ($mysqlname =~ /^MariaDB/i) { |
if ($mysqlversion >= 10.2) { |
if ($mysqlversion >= 10.2) { |
$usesauth = 1; |
$usesauth = 1; |
|
} elsif ($mysqlversion >= 5.5) { |
|
$hasauthcol = 1; |
} |
} |
} else { |
} else { |
if (($mysqlversion > 5.7) || (($mysqlversion == 5.7) && ($mysqlsubver > 5))) { |
if (($mysqlversion > 5.7) || (($mysqlversion == 5.7) && ($mysqlsubver > 5))) { |
$usesauth = 1; |
$usesauth = 1; |
|
} elsif (($mysqlversion >= 5.6) || (($mysqlversion == 5.5) && ($mysqlsubver >= 7))) { |
|
$hasauthcol = 1; |
} |
} |
} |
} |
if ($usesauth) { |
if ($usesauth) { |
@mysql_commands = ("INSERT user (Host, User, ssl_cipher, x509_issuer, x509_subject) VALUES('localhost','www','','','')", |
@mysql_commands = ("INSERT user (Host, User, ssl_cipher, x509_issuer, x509_subject, authentication_string) VALUES('localhost','www','','','','')", |
"ALTER USER 'www'\@'localhost' IDENTIFIED BY 'localhostkey'"); |
"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 { |
} else { |
@mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));"); |
@mysql_commands = ("INSERT user (Host, User, Password, ssl_cipher, x509_issuer, x509_subject) VALUES('localhost','www',password('localhostkey'),'','','');"); |
} |
} |
if ($mysqlversion < 4) { |
if ($mysqlversion < 4) { |
push (@mysql_commands," |
push (@mysql_commands," |
Line 1852 INSERT db (Host,Db,User,Select_priv,Inse
|
Line 1882 INSERT db (Host,Db,User,Select_priv,Inse
|
} |
} |
} |
} |
if ($got_passwd) { |
if ($got_passwd) { |
my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass); |
my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass,$usesauth); |
push(@mysql_commands,@newpass_cmds); |
push(@mysql_commands,@newpass_cmds); |
} else { |
} else { |
print_and_log(&mt('Failed to get MySQL root password from user input.')."\n"); |
print_and_log(&mt('Failed to get MySQL root password from user input.')."\n"); |
Line 1861 INSERT db (Host,Db,User,Select_priv,Inse
|
Line 1891 INSERT db (Host,Db,User,Select_priv,Inse
|
if (@mysql_commands) { |
if (@mysql_commands) { |
foreach my $cmd (@mysql_commands) { |
foreach my $cmd (@mysql_commands) { |
$dbh->do($cmd) || print $dbh->errstr."\n"; |
$dbh->do($cmd) || print $dbh->errstr."\n"; |
|
|
} |
} |
} |
} |
if (@mysql_lc_commands) { |
if (@mysql_lc_commands) { |
Line 1885 INSERT db (Host,Db,User,Select_priv,Inse
|
Line 1914 INSERT db (Host,Db,User,Select_priv,Inse
|
sub new_mysql_rootpasswd { |
sub new_mysql_rootpasswd { |
my ($currmysqlpass,$usesauth) = @_; |
my ($currmysqlpass,$usesauth) = @_; |
if ($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;"); |
"FLUSH PRIVILEGES;"); |
} else { |
} else { |
return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')", |
return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')", |