Merge "[COMMON] Fix some array bashisms"
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>
Thu, 16 Dec 2021 19:43:11 +0000 (19:43 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 16 Dec 2021 19:43:11 +0000 (19:43 +0000)
kubernetes/common/mariadb-init/resources/config/db_init.sh

index df7c336..8f7e7ce 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 {{/*
 # Copyright © 2019 Orange
@@ -32,13 +32,13 @@ while read DB ; do
 */}}
     eval USER=\$$USER_VAR
     PASS=$(eval echo -n \$$PASS_VAR | sed -e "s/'/''/g")
-    MYSQL_OPTS=( -h ${DB_HOST} -P ${DB_PORT} -uroot -p${MYSQL_ROOT_PASSWORD} )
+    MYSQL_OPTS=" -h "${DB_HOST}" -P "${DB_PORT}" -uroot -p"${MYSQL_ROOT_PASSWORD}
 
     echo "Creating database ${DB} and user ${USER}..."
 
-    mysql "${MYSQL_OPTS[@]}" -e "CREATE OR REPLACE USER '${USER}'@'%' IDENTIFIED BY '${PASS}'"
-    mysql "${MYSQL_OPTS[@]}" -e "CREATE DATABASE IF NOT EXISTS ${DB}"
-    mysql "${MYSQL_OPTS[@]}" -e "GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'%'"
+    mysql $MYSQL_OPTS -e "CREATE OR REPLACE USER '${USER}'@'%' IDENTIFIED BY '${PASS}'"
+    mysql $MYSQL_OPTS -e "CREATE DATABASE IF NOT EXISTS ${DB}"
+    mysql $MYSQL_OPTS -e "GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'%'"
 
     echo "Created database ${DB} and user ${USER}."
 done <<EOF