Browse Source

Adding and removing mongodb databases from the apps list

Bob Mottram 7 years ago
parent
commit
33de19cd99
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      src/freedombone-utils-mongodb

+ 10
- 0
src/freedombone-utils-mongodb View File

141
         return
141
         return
142
     fi
142
     fi
143
     mongo $database_name --eval "db.runCommand( { dropDatabase: 1 } )"
143
     mongo $database_name --eval "db.runCommand( { dropDatabase: 1 } )"
144
+    if [ $app_name ]; then
145
+        if grep -q "$app_name" $MONGODB_APPS_FILE; then
146
+            sed -i "/$app_name/d" $MONGODB_APPS_FILE
147
+        fi
148
+    fi
144
 }
149
 }
145
 
150
 
146
 function initialise_database_mongodb {
151
 function initialise_database_mongodb {
157
     app_admin_password="$2"
162
     app_admin_password="$2"
158
     app_admin_username=$3
163
     app_admin_username=$3
159
     mongo admin --eval "db.createUser({user: '$app_admin_username', pwd: '$app_admin_password', roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ] })"
164
     mongo admin --eval "db.createUser({user: '$app_admin_username', pwd: '$app_admin_password', roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ] })"
165
+    if [ $app_name ]; then
166
+        if ! grep -q "$app_name" $MONGODB_APPS_FILE; then
167
+           echo "$app_name" >> $MONGODB_APPS_FILE
168
+        fi
169
+    fi
160
 }
170
 }