From 69bf4249be98d1344cb26f1cb64b195ab4c02c0c Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Sat, 22 Nov 2014 21:24:28 -0500 Subject: [PATCH] Bug#4385 mysqlsetup does not support mariaDB in Ubuntu --- xCAT-client/bin/mysqlsetup | 71 +++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index 0947a4688..4da94aab2 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -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.*/)