Skip to content

Commit 216bade

Browse files
committed
Merge pull request #18 from meghuizen/patch-1
Add DirectAdmin support.
2 parents 35955db + 33d97c6 commit 216bade

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mysqltuner.pl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,23 @@ sub mysql_setup {
321321
badprint "Attempted to use login credentials from Plesk, but they failed.\n";
322322
exit 0;
323323
}
324+
} elsif ( -r "/usr/local/directadmin/conf/mysql.conf" and $doremote == 0 ){
325+
# It's a DirectAdmin box, use the available credentials
326+
my $mysqluser=`cat /usr/local/directadmin/conf/mysql.conf | egrep '^user=.*'`;
327+
my $mysqlpass=`cat /usr/local/directadmin/conf/mysql.conf | egrep '^passwd=.*'`;
328+
329+
$mysqluser =~ s/user=//;
330+
$mysqluser =~ s/[\r\n]//;
331+
$mysqlpass =~ s/passwd=//;
332+
$mysqlpass =~ s/[\r\n]//;
333+
334+
$mysqllogin = "-u $mysqluser -p$mysqlpass";
335+
336+
my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`;
337+
unless ($loginstatus =~ /mysqld is alive/) {
338+
badprint "Attempted to use login credentials from DirectAdmin, but they failed.\n";
339+
exit 0;
340+
}
324341
} elsif ( -r "/etc/mysql/debian.cnf" and $doremote == 0 ){
325342
# We have a debian maintenance account, use it
326343
$mysqllogin = "--defaults-file=/etc/mysql/debian.cnf";

0 commit comments

Comments
 (0)