parent
7b0664bbbf
commit
18eed21ecd
1 changed files with 18 additions and 15 deletions
|
@ -101,9 +101,7 @@ sub usage {
|
|||
" --port <port> Port to use for connection (default: 3306)\n".
|
||||
" --user <username> Username to use for authentication\n".
|
||||
" --pass <password> Password to use for authentication\n".
|
||||
" Database type\n".
|
||||
" --mysql Run with mysql database (default)\n".
|
||||
" --maria Run with mariadb database\n".
|
||||
" --mysqladmin <path> Path to a custom mysqladmin executable\n".
|
||||
"\n".
|
||||
" Performance and Reporting Options\n".
|
||||
" --skipsize Don't enumerate tables and their types/sizes (default: on)\n".
|
||||
|
@ -253,13 +251,18 @@ my ($mysqllogin,$doremote,$remotestring);
|
|||
sub mysql_setup {
|
||||
$doremote = 0;
|
||||
$remotestring = '';
|
||||
my $command = `which mysqladmin`;
|
||||
chomp($command);
|
||||
if ( $opt{mysqladmin} ) {
|
||||
$command = $opt{mysqladmin};
|
||||
}
|
||||
elsif (! -e $command ) {
|
||||
badprint "Unable to find mysqladmin in your \$PATH. Is MySQL installed?\n";
|
||||
my $mysqladmincmd;
|
||||
if ($opt{mysqladmin}) {
|
||||
$mysqladmincmd = $opt{mysqladmin};
|
||||
} else {
|
||||
$mysqladmincmd = `which mysqladmin`;
|
||||
}
|
||||
chomp($mysqladmincmd);
|
||||
if (! -e $mysqladmincmd && $opt{mysqladmin}) {
|
||||
badprint "Unable to find the mysqladmin command you specified: ".$mysqladmincmd."\n";
|
||||
exit;
|
||||
} elsif (! -e $mysqladmincmd) {
|
||||
badprint "Couldn't find mysqladmin in your \$PATH. Is MySQL installed?\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -284,7 +287,7 @@ sub mysql_setup {
|
|||
# Did we already get a username and password passed on the command line?
|
||||
if ($opt{user} ne 0 and $opt{pass} ne 0) {
|
||||
$mysqllogin = "-u $opt{user} -p'$opt{pass}'".$remotestring;
|
||||
my $loginstatus = `$command ping $mysqllogin 2>&1`;
|
||||
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
|
||||
if ($loginstatus =~ /mysqld is alive/) {
|
||||
goodprint "Logged in using credentials passed on the command line\n";
|
||||
return 1;
|
||||
|
@ -296,7 +299,7 @@ sub mysql_setup {
|
|||
if ( -r "/etc/psa/.psa.shadow" and $doremote == 0 ) {
|
||||
# It's a Plesk box, use the available credentials
|
||||
$mysqllogin = "-u admin -p`cat /etc/psa/.psa.shadow`";
|
||||
my $loginstatus = `$command ping $mysqllogin 2>&1`;
|
||||
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
|
||||
unless ($loginstatus =~ /mysqld is alive/) {
|
||||
badprint "Attempted to use login credentials from Plesk, but they failed.\n";
|
||||
exit 0;
|
||||
|
@ -304,7 +307,7 @@ sub mysql_setup {
|
|||
} elsif ( -r "/etc/mysql/debian.cnf" and $doremote == 0 ){
|
||||
# We have a debian maintenance account, use it
|
||||
$mysqllogin = "--defaults-file=/etc/mysql/debian.cnf";
|
||||
my $loginstatus = `$command $mysqllogin ping 2>&1`;
|
||||
my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`;
|
||||
if ($loginstatus =~ /mysqld is alive/) {
|
||||
goodprint "Logged in using credentials from debian maintenance account.\n";
|
||||
return 1;
|
||||
|
@ -314,7 +317,7 @@ sub mysql_setup {
|
|||
}
|
||||
} else {
|
||||
# It's not Plesk or debian, we should try a login
|
||||
my $loginstatus = `$command $remotestring ping 2>&1`;
|
||||
my $loginstatus = `$mysqladmincmd $remotestring ping 2>&1`;
|
||||
if ($loginstatus =~ /mysqld is alive/) {
|
||||
# Login went just fine
|
||||
$mysqllogin = " $remotestring ";
|
||||
|
@ -341,7 +344,7 @@ sub mysql_setup {
|
|||
$mysqllogin .= " -p'$password'";
|
||||
}
|
||||
$mysqllogin .= $remotestring;
|
||||
my $loginstatus = `$command ping $mysqllogin 2>&1`;
|
||||
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
|
||||
if ($loginstatus =~ /mysqld is alive/) {
|
||||
print STDERR "\n";
|
||||
if (! length($password)) {
|
||||
|
|
Loading…
Reference in a new issue