X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=kubernetes%2Fportal%2Fcomponents%2Fportal-mariadb%2Fresources%2Fconfig%2Fmariadb%2Fdocker-entrypoint.sh;h=709877943c5e49ecc927759524354b666f056ab9;hb=8c26e59d30a185186cf33988a0dbb859409f73eb;hp=ddaf099bdf5ace400f3f7759adca603b86558150;hpb=3b7a11ca5949f2fc944e404a5916ca24af4514e9;p=oom.git diff --git a/kubernetes/portal/components/portal-mariadb/resources/config/mariadb/docker-entrypoint.sh b/kubernetes/portal/components/portal-mariadb/resources/config/mariadb/docker-entrypoint.sh index ddaf099bdf..709877943c 100644 --- a/kubernetes/portal/components/portal-mariadb/resources/config/mariadb/docker-entrypoint.sh +++ b/kubernetes/portal/components/portal-mariadb/resources/config/mariadb/docker-entrypoint.sh @@ -1,7 +1,6 @@ #!/bin/bash set -eo pipefail -shopt -s nullglob # logging functions mysql_log() { @@ -111,7 +110,7 @@ docker_temp_server_start() { # only use the root password if the database has already been initializaed # so that it won't try to fill in a password file when it hasn't been set yet extraArgs="" - if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + if [ "$DATABASE_ALREADY_EXISTS" = "false" ]; then extraArgs=${extraArgs}" --dont-use-mysql-root-password" fi if echo 'SELECT 1' |docker_process_sql ${extraArgs} --database=mysql >/dev/null 2>&1; then @@ -170,11 +169,20 @@ docker_init_database_dir() { mysql_note "Database files initialized" } +if [ -z "$DATADIR" ]; then + DATADIR='unknown' +fi +if [ -z "$SOCKET" ]; then + SOCKET='unknown' +fi +if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + DATABASE_ALREADY_EXISTS='false' +fi + # Loads various settings that are used elsewhere in the script # This should be called after mysql_check_config, but before any other functions docker_setup_env() { # Get config - declare -g DATADIR SOCKET DATADIR="$(mysql_get_config 'datadir' "$@")" SOCKET="$(mysql_get_config 'socket' "$@")" @@ -186,7 +194,6 @@ docker_setup_env() { file_env 'MYSQL_ROOT_PASSWORD' file_env 'PORTAL_DB_TABLES' - declare -g DATABASE_ALREADY_EXISTS if [ -d "$DATADIR/mysql" ]; then DATABASE_ALREADY_EXISTS='true' fi @@ -337,7 +344,7 @@ _main() { fi # there's no database, so it needs to be initialized - if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + if [ "$DATABASE_ALREADY_EXISTS" = "false" ]; then docker_verify_minimum_env # check dir permissions to reduce likelihood of half-initialized database