Browse Source

Update script to run multiple times on mongod 3.2

Oz N Tiram 6 years ago
parent
commit
8f7d5863a3
1 changed files with 5 additions and 4 deletions
  1. 5 4
      tests/init_mongo.js

+ 5 - 4
tests/init_mongo.js

@@ -1,7 +1,8 @@
 // run this script with $ mongo < init_mongo.js
 
-db.createUser({user: "tester", pwd: "12345678",
-              roles: [{role: "dbAdmin", db: "pwmantest"},
+if ( !  db.getUser("tester") ) {
+     db.createUser({user: "tester", pwd: "12345678",
+                   roles: [{role: "dbAdmin", db: "pwmantest"},
                       {role: "readWrite", db: "pwmantest"},]
-              })
-
+                   })
+}