Adding and removing mongodb databases from the apps list

This commit is contained in:
Bob Mottram 2017-11-23 19:43:11 +00:00
parent 7c06684656
commit 33de19cd99
1 changed files with 10 additions and 0 deletions

View File

@ -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
}