From 4fe5262e828c2f3a4f8a5be0e1308a683d3b058e Mon Sep 17 00:00:00 2001 From: GuangrongFu Date: Wed, 10 Mar 2021 10:23:31 +0800 Subject: [PATCH] Init DB Using envsubst Change-Id: I8f6d5a455b52ca03c7754f570b353f7b1ddbddf9 Issue-ID: HOLMES-396 Signed-off-by: GuangrongFu --- rulemgt-standalone/src/main/assembly/bin/initDB.sh | 6 +++--- rulemgt-standalone/src/main/assembly/bin/run.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rulemgt-standalone/src/main/assembly/bin/initDB.sh b/rulemgt-standalone/src/main/assembly/bin/initDB.sh index 32ba72a..436d48d 100644 --- a/rulemgt-standalone/src/main/assembly/bin/initDB.sh +++ b/rulemgt-standalone/src/main/assembly/bin/initDB.sh @@ -25,7 +25,7 @@ host=$5 echo "Initializing the holmes rule management database..." main_path=$HOME/.. -if [[ -d /opt/hrmconfig ]]; then +if [ -d /opt/hrmconfig ]; then cp /opt/hrmconfig/onap-holmes_rulemgt-createobj.sql "$main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql" else sed -i "s|DBNAME|$dbname|g" "$main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql" @@ -40,7 +40,7 @@ echo "password=$password" echo "port=$port" echo "host=$host" -if [[ -z `env | grep PGPASSWORD` ]]; then +if [ -z `env | grep PGPASSWORD` ]; then export PGPASSWORD=$password need_unset=1 fi @@ -49,7 +49,7 @@ psql -U "$user" -p "$port" -h "$host" -d "$dbname" -f $main_path/dbscripts/postg psql -U "$user" -p "$port" -h "$host" -d "$dbname" --command 'select * from aplus_rule;' sql_result=$? -if [[ $need_unset -eq 1 ]]; then +if [ $need_unset -eq 1 ]; then unset PGPASSWORD fi diff --git a/rulemgt-standalone/src/main/assembly/bin/run.sh b/rulemgt-standalone/src/main/assembly/bin/run.sh index 3e0ff97..5b645b1 100644 --- a/rulemgt-standalone/src/main/assembly/bin/run.sh +++ b/rulemgt-standalone/src/main/assembly/bin/run.sh @@ -49,7 +49,7 @@ if [ -z ${DB_NAME} ]; then fi # if deployed using helm, use the helm-generated configuration file. -if [[ -d /opt/hrmconfig ]]; then +if [ -d /opt/hrmconfig ]; then cp /opt/hrmconfig/rulemgt.yml "$main_path/conf/rulemgt.yml" else sed -i "s|user:.*|user: $JDBC_USERNAME|" "$main_path/conf/rulemgt.yml" -- 2.16.6