From 2022158a4e5c124e2862525ced9fee3914b49c68 Mon Sep 17 00:00:00 2001 From: Dave Conroy Date: Fri, 7 Oct 2022 08:33:19 -0700 Subject: [PATCH] Swap around some environment checks --- install/assets/functions/10-db-backup | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install/assets/functions/10-db-backup b/install/assets/functions/10-db-backup index 3c0f662..4fbaf5a 100755 --- a/install/assets/functions/10-db-backup +++ b/install/assets/functions/10-db-backup @@ -65,12 +65,7 @@ bootstrap_variables() { ### Set the Database Authentication Details or parse any custom URIs case "$dbtype" in "mongo" ) - if [ -z "${MONGO_CUSTOM_URI}" ] ; then - [[ ( -n "${DB_USER}" ) ]] && MONGO_USER_STR=" --username ${DB_USER}" - [[ ( -n "${DB_PASS}" ) ]] && MONGO_PASS_STR=" --password ${DB_PASS}" - [[ ( -n "${DB_NAME}" ) ]] && MONGO_DB_STR=" --db ${DB_NAME}" - [[ ( -n "${DB_AUTH}" ) ]] && MONGO_AUTH_STR=" --authenticationDatabase ${DB_AUTH}" - else + if [ -n "${MONGO_CUSTOM_URI}" ] ; then mongo_uri_proto=$(echo ${MONGO_CUSTOM_URI} | grep :// | sed -e's,^\(.*://\).*,\1,g') mongo_uri_scratch="${MONGO_CUSTOM_URI/${mongo_uri_proto}/}" mongo_uri_username_password=$(echo ${mongo_uri_scratch} | grep @ | rev | cut -d@ -f2- | rev) @@ -82,6 +77,11 @@ bootstrap_variables() { mongo_uri_options=$(echo ${mongo_uri_scratch} | cut -d/ -f2 | cut -d? -f2 ) DB_NAME=${DB_NAME:-"${mongo_uri_database,,}"} DB_HOST=${DB_HOST:-"${mongo_uri_hostname,,}"} + else + [[ ( -n "${DB_USER}" ) ]] && MONGO_USER_STR=" --username ${DB_USER}" + [[ ( -n "${DB_PASS}" ) ]] && MONGO_PASS_STR=" --password ${DB_PASS}" + [[ ( -n "${DB_NAME}" ) ]] && MONGO_DB_STR=" --db ${DB_NAME}" + [[ ( -n "${DB_AUTH}" ) ]] && MONGO_AUTH_STR=" --authenticationDatabase ${DB_AUTH}" fi ;; "mysql" )