Skip to content

Commit 2022158

Browse files
committed
Swap around some environment checks
1 parent 2b441f1 commit 2022158

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

install/assets/functions/10-db-backup

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ bootstrap_variables() {
6565
### Set the Database Authentication Details or parse any custom URIs
6666
case "$dbtype" in
6767
"mongo" )
68-
if [ -z "${MONGO_CUSTOM_URI}" ] ; then
69-
[[ ( -n "${DB_USER}" ) ]] && MONGO_USER_STR=" --username ${DB_USER}"
70-
[[ ( -n "${DB_PASS}" ) ]] && MONGO_PASS_STR=" --password ${DB_PASS}"
71-
[[ ( -n "${DB_NAME}" ) ]] && MONGO_DB_STR=" --db ${DB_NAME}"
72-
[[ ( -n "${DB_AUTH}" ) ]] && MONGO_AUTH_STR=" --authenticationDatabase ${DB_AUTH}"
73-
else
68+
if [ -n "${MONGO_CUSTOM_URI}" ] ; then
7469
mongo_uri_proto=$(echo ${MONGO_CUSTOM_URI} | grep :// | sed -e's,^\(.*://\).*,\1,g')
7570
mongo_uri_scratch="${MONGO_CUSTOM_URI/${mongo_uri_proto}/}"
7671
mongo_uri_username_password=$(echo ${mongo_uri_scratch} | grep @ | rev | cut -d@ -f2- | rev)
@@ -82,6 +77,11 @@ bootstrap_variables() {
8277
mongo_uri_options=$(echo ${mongo_uri_scratch} | cut -d/ -f2 | cut -d? -f2 )
8378
DB_NAME=${DB_NAME:-"${mongo_uri_database,,}"}
8479
DB_HOST=${DB_HOST:-"${mongo_uri_hostname,,}"}
80+
else
81+
[[ ( -n "${DB_USER}" ) ]] && MONGO_USER_STR=" --username ${DB_USER}"
82+
[[ ( -n "${DB_PASS}" ) ]] && MONGO_PASS_STR=" --password ${DB_PASS}"
83+
[[ ( -n "${DB_NAME}" ) ]] && MONGO_DB_STR=" --db ${DB_NAME}"
84+
[[ ( -n "${DB_AUTH}" ) ]] && MONGO_AUTH_STR=" --authenticationDatabase ${DB_AUTH}"
8585
fi
8686
;;
8787
"mysql" )

0 commit comments

Comments
 (0)