diff --git a/src/freedombone-utils-mongodb b/src/freedombone-utils-mongodb index cbc648bc..b9f87c75 100755 --- a/src/freedombone-utils-mongodb +++ b/src/freedombone-utils-mongodb @@ -141,6 +141,11 @@ function drop_database_mongodb { return fi mongo $database_name --eval "db.runCommand( { dropDatabase: 1 } )" + if [ $app_name ]; then + if grep -q "$app_name" $MONGODB_APPS_FILE; then + sed -i "/$app_name/d" $MONGODB_APPS_FILE + fi + fi } function initialise_database_mongodb { @@ -157,4 +162,9 @@ function create_database_mongodb { app_admin_password="$2" app_admin_username=$3 mongo admin --eval "db.createUser({user: '$app_admin_username', pwd: '$app_admin_password', roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ] })" + if [ $app_name ]; then + if ! grep -q "$app_name" $MONGODB_APPS_FILE; then + echo "$app_name" >> $MONGODB_APPS_FILE + fi + fi }