Bug#4385 mysqlsetup does not support mariaDB in Ubuntu

This commit is contained in:
Casandra Qiu 2014-11-22 21:24:28 -05:00
parent 28d2110a5e
commit 69bf4249be

View File

@ -147,29 +147,41 @@ if ( -e "/etc/debian_version" ){
# determine whether redhat or sles
$::linuxos = xCAT::Utils->osver();
#
# check to see if mysql is installed
#
my $cmd = "rpm -qa | grep -i perl-DBD-mysql";
if ( $::debianflag ){
$cmd = "dpkg -l | grep mysql-server";
}
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
my $message =
"\nMySQL perl DBD is not installed. If on AIX, it should be first obtained from the xcat dependency tarballs and installed before running this command.\n If on Linux, install from the OS CDs.";
xCAT::MsgUtils->message("E", " $cmd failed. $message");
exit(1);
}
# is this MariaDB or MySQL
$::MariaDB=0;
$cmd = "rpm -qa | grep -i mariadb"; # check this is MariaDB not MySQL
my $cmd;
if ( $::debianflag ){
$cmd = "dpkg -l | grep mariadb";
} else {
$cmd = "rpm -qa | grep -i mariadb"; # check this is MariaDB not MySQL
}
xCAT::Utils->runcmd($cmd, -1);
if ($::RUNCMD_RC == 0) {
$::MariaDB=1;
}
#
# check to see if mysql is installed
#
$cmd = "rpm -qa | grep -i perl-DBD-mysql";
my $msg = "\nMySQL perl DBD ";
if ( $::debianflag ){
if ( $::MariaDB ){
$cmd = "dpkg -l | grep -i mariadb-server";
$msg = "\nmariadb-server ";
} else {
$cmd = "dpkg -l | grep mysql-server";
$msg = "\nmysql-server ";
}
}
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
my $message =
"\n$msg is not installed. If on AIX, it should be first obtained from the xcat dependency tarballs and installed before running this command.\n If on Linux, install from the OS CDs.";
xCAT::MsgUtils->message("E", " $cmd failed. $message");
exit(1);
}
# check to see if MySQL is running
$::mysqlrunning = 0;
$::xcatrunningmysql = 0;
@ -187,6 +199,29 @@ if (grep(/$mysqlcheck/, @output))
}
$::mysqlrunning = 1;
}
#for ubuntu 14, after install mysql/maria server, the mysql will running
#need to stop mysql in order to setup init xcat mysql
if ( $::debianflag ){
$cmd = "pidof mysqld";
xCAT::Utils->runcmd($cmd, -1);
if ($::RUNCMD_RC == 0)
{
if ($::INIT)
{
my $ret=xCAT::Utils->stopservice("mysql");
if ($ret != 0)
{
xCAT::MsgUtils->message("E", " failed to stop mysql/mariadb.");
exit(1);
}
}
else {
$::mysqlrunning = 1;
}
}
}
if (-e ("/etc/xcat/cfgloc")) # check to see if xcat is using mysql
{ # cfgloc exists
$cmd = "fgrep mysql /etc/xcat/cfgloc";
@ -1000,6 +1035,10 @@ sub mysqlreboot
$cmd = "chkconfig mariadb on";
} else { #sles
$cmd = "chkconfig mysql on";
if ( $::debianflag ){
$cmd = "update-rc.d mysql defaults";
}
}
} else { # mysql
if ($::linuxos =~ /rh.*/)