From 462e3883d26612875a2978abdb8324109b41e081 Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 6 Jul 2016 17:52:14 +0200 Subject: [PATCH] Changes in MANO DB init scripts to allow db_name as input parameter Signed-off-by: tierno --- database_utils/init_mano_db.sh | 12 ++++++------ database_utils/mano_db_structure.sql | 10 ---------- scripts/install-openmano.sh | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/database_utils/init_mano_db.sh b/database_utils/init_mano_db.sh index c876ea42..cbb76ef4 100755 --- a/database_utils/init_mano_db.sh +++ b/database_utils/init_mano_db.sh @@ -41,11 +41,11 @@ function usage(){ echo -e " -p PASS database password. 'No password' by default. Prompts if DB access fails" echo -e " -P PORT database port. '$DBPORT' by default" echo -e " -h HOST database host. '$DBHOST' by default" -# echo -e " -d NAME database name. '$DBNAME' by default. Prompts if DB access fails" + echo -e " -d NAME database name. '$DBNAME' by default. Prompts if DB access fails" echo -e " --help shows this help" } -while getopts ":u:p:P:h:-:" o; do +while getopts ":u:p:P:d:h:-:" o; do case "${o}" in u) DBUSER="$OPTARG" @@ -56,9 +56,9 @@ while getopts ":u:p:P:h:-:" o; do P) DBPORT="$OPTARG" ;; -# d) -# DBNAME="$OPTARG" -# ;; + d) + DBNAME="$OPTARG" + ;; h) DBHOST="$OPTARG" ;; @@ -106,7 +106,7 @@ done #${DIRNAME}/quick_delete_db.sh $MUSER $MPASS $MDB $HOST $PORT echo " loading ${DIRNAME}/${DBNAME}_structure.sql" -mysql $DBHOST_ $DBPORT_ $DBUSER_ $DBPASS_ < ${DIRNAME}/${DBNAME}_structure.sql +mysql $DBHOST_ $DBPORT_ $DBUSER_ $DBPASS_ $DBNAME < ${DIRNAME}/mano_db_structure.sql echo " migrage database version" ${DIRNAME}/migrate_mano_db.sh $DBHOST_ $DBPORT_ $DBUSER_ $DBPASS_ -d$DBNAME diff --git a/database_utils/mano_db_structure.sql b/database_utils/mano_db_structure.sql index aca07aa0..c70fbc1c 100644 --- a/database_utils/mano_db_structure.sql +++ b/database_utils/mano_db_structure.sql @@ -36,16 +36,6 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; --- --- Current Database: `mano_db` --- - -/*!40000 DROP DATABASE IF EXISTS `mano_db`*/; - -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mano_db` /*!40100 DEFAULT CHARACTER SET latin1 */; - -USE `mano_db`; - -- -- Table structure for table `datacenter_nets` -- diff --git a/scripts/install-openmano.sh b/scripts/install-openmano.sh index c4f05e05..75bfe28a 100755 --- a/scripts/install-openmano.sh +++ b/scripts/install-openmano.sh @@ -235,7 +235,7 @@ echo "CREATE USER 'mano'@'localhost' identified by 'manopw';" | mysql -u$DBUSE echo "GRANT ALL PRIVILEGES ON mano_db.* TO 'mano'@'localhost';" | mysql -u$DBUSER $DBPASSWD_PARAM -s || ! echo "Failed while creating user mano at dabase" || exit 1 echo " Database 'mano_db' created, user 'mano' password 'manopw'" -su $SUDO_USER -c 'openmano/database_utils/init_mano_db.sh -u mano -p manopw' || ! echo "Failed while creating user mano at dabase" || exit 1 +su $SUDO_USER -c 'openmano/database_utils/init_mano_db.sh -u mano -p manopw -d mano_db' || ! echo "Failed while creating user mano at dabase" || exit 1 if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] then -- 2.25.1