summaryrefslogtreecommitdiffstats
path: root/kubernetes/common/mariadb-init/resources/config/db_init.sh
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2020-07-02 20:10:04 +0200
committerKrzysztof Opasiak <k.opasiak@samsung.com>2020-07-02 20:10:04 +0200
commitc5dac87fa301247928211d5944be22ae14bcd534 (patch)
treef7278dd7b66a45ddd932332c80efc5adc4b40f3d /kubernetes/common/mariadb-init/resources/config/db_init.sh
parentcc39379f8a7e42d122225af8fd7425a2a3b5325c (diff)
[COMMON] Allow to use ' in mariadb-init
' is one of characters that are placed in passwords by our default password generation algorith. As ' is a special character in SQL we need to escape it before concatenating it with SQL command. Let's also add set -e to fail if any of databases has not been created Issue-ID: OOM-2436 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Change-Id: Ida8c75639eaa4049e3f874d30666f1fe4dc02e12
Diffstat (limited to 'kubernetes/common/mariadb-init/resources/config/db_init.sh')
-rwxr-xr-xkubernetes/common/mariadb-init/resources/config/db_init.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/kubernetes/common/mariadb-init/resources/config/db_init.sh b/kubernetes/common/mariadb-init/resources/config/db_init.sh
index b2fdb14b12..40254d469b 100755
--- a/kubernetes/common/mariadb-init/resources/config/db_init.sh
+++ b/kubernetes/common/mariadb-init/resources/config/db_init.sh
@@ -14,11 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# make sure the script fails if any of commands failed
+set -e
+
while read DB ; do
USER_VAR="MYSQL_USER_${DB^^}"
PASS_VAR="MYSQL_PASSWORD_${DB^^}"
USER=${!USER_VAR}
- PASS=${!PASS_VAR}
+ PASS=`echo -n ${!PASS_VAR} | sed -e "s/'/''/g"`
MYSQL_OPTS=( -h ${DB_HOST} -P ${DB_PORT} -uroot -p${MYSQL_ROOT_PASSWORD} )
echo "Creating database ${DB} and user ${USER}..."