From 4efd58d23d11faf1a9ce1c7d3ccbe9fee5930da7 Mon Sep 17 00:00:00 2001 From: David Hill Date: Fri, 2 Dec 2016 00:08:01 +0000 Subject: [PATCH] update --- oam/install_scripts/post-mysql-install | 19 ++++++-- oamapps/postConfigure/helpers.cpp | 64 ------------------------- oamapps/postConfigure/postConfigure.cpp | 3 +- 3 files changed, 16 insertions(+), 70 deletions(-) diff --git a/oam/install_scripts/post-mysql-install b/oam/install_scripts/post-mysql-install index 6f4503ce2..25f8eb0bb 100755 --- a/oam/install_scripts/post-mysql-install +++ b/oam/install_scripts/post-mysql-install @@ -11,14 +11,21 @@ checkForError() { if [ `cat /tmp/error.check | wc -c` -ne 0 ]; then if test -f $HOME/.my.cnf ; then password=`cat $HOME/.my.cnf | grep password | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'` - pwprompt="-p$password" - return 1; + if [ ! -z $password ]; then + pwprompt="-p$password" + else + echo "MySQL Password file missing or incorrect, check .my.cnf file" + rm -f /tmp/error.check + $installdir/mysql/mysql-Columnstore stop + sleep 2 + exit 2; + fi else echo "MySQL Password file missing or incorrect, check .my.cnf file" rm -f /tmp/error.check $installdir/mysql/mysql-Columnstore stop sleep 2 - exit 1; + exit 2; fi fi @@ -60,7 +67,9 @@ for arg in "$@"; do rpmmode="$(echo $arg | awk -F= '{print $2}')" elif [ $(expr -- "$arg" : '--password=') -eq 11 ]; then password="$(echo $arg | awk -F= '{print $2}')" - pwprompt="-p$password" + if [ ! -z $password ]; then + pwprompt="-p$password" + fi elif [ $(expr -- "$arg" : '--installdir=') -eq 13 ]; then installdir="$(echo $arg | awk -F= '{print $2}')" prefix=$(dirname $installdir) @@ -118,7 +127,7 @@ if [ -x $installdir/mysql/mysql-Columnstore ]; then echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing" $installdir/mysql/mysql-Columnstore stop sleep 2 - exit 1; + exit 2; fi fi diff --git a/oamapps/postConfigure/helpers.cpp b/oamapps/postConfigure/helpers.cpp index a00d78497..ea1a50343 100644 --- a/oamapps/postConfigure/helpers.cpp +++ b/oamapps/postConfigure/helpers.cpp @@ -259,70 +259,6 @@ void mysqlSetup() HOME = p; } - //check for password set - //start in the same way that mysqld will be started normally. - try { - oam.actionMysqlCalpont(MYSQL_START); - } - catch(const std::exception &exc) - { - std::cerr << exc.what() << std::endl; - } - sleep(2); - - for (;;) - { - // check if mysql is supported and get info - string calpontMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root "; - string cmd = calpontMysql + pwprompt + " -e 'status' > /tmp/idbmysql.log 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) { - //check and get password - string mysqlpw = oam::UnassignedName; - try { - mysqlpw = oam.getMySQLPassword(false); - cout << "NOTE: Using MariaDB Columnstore password from " + HOME + "/.my.cnf" << endl; - } - catch (...) - { - cout << endl << "MariDB Columnstore login failure, password is assigned. Need MariaDB Columnstore password configuration file " + HOME + "/.my.cnf on local module" << endl; - exit(1); - } - - mysqlpw = "'" + mysqlpw + "'"; - pwprompt = "--password=" + mysqlpw; - - try { - oam.setSystemConfig("MySQLPasswordConfig", "y"); - } - catch(const std::exception &exc) - { - std::cerr << exc.what() << std::endl; - } - } - else - { - if (!oam.checkLogStatus("/tmp/idbmysql.log", "Columnstore") ) { - cout << endl << "ERROR: MariaDB Columnstore runtime error, exit..." << endl << endl; - system("cat /tmp/idbmysql.log"); - exit (1); - } - else - { - try { - oam.actionMysqlCalpont(MYSQL_STOP); - } - catch(const std::exception &exc) - { - std::cerr << exc.what() << std::endl; - } - unlink("/tmp/idbmysql.log"); - break; - } - } - } - cmd = installDir + "/bin/post-mysql-install " + pwprompt + " --installdir=" + installDir + " > /tmp/post-mysql-install.log";; rtnCode = system(cmd.c_str()); if (WEXITSTATUS(rtnCode) == 2) { diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index e558ef886..1ea77a892 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -3018,7 +3018,8 @@ int main(int argc, char *argv[]) cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "bin/getMySQLpw > /tmp/mysqlpw.log 2>&1"; rtnCode = system(cmd.c_str()); if (WEXITSTATUS(rtnCode) != 0) { - cout << endl << "MariaDB Columnstore login failure, password is assigned. Need MariaDB Columnstore password configuration file " + HOME + "/.my.cnf on " << remoteModuleName << endl; + cout << endl << "MariaDB Columnstore login failure, MySQL Root password is set." << endl; + cout << "Need MariaDB Columnstore password configuration file " + HOME + "/.my.cnf on " << remoteModuleName << endl; exit(1); }