This repository was archived by the owner on Nov 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongo_maint.sh
More file actions
executable file
·43 lines (33 loc) · 1.47 KB
/
mongo_maint.sh
File metadata and controls
executable file
·43 lines (33 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#
# Admin config script for the PDC's HubDB (MongoDB) service
# Halt on errors or unset variables
#
set -e -o nounset
# Wait for mongo to start, important after boot
#
while [ $( pgrep -c mongod ) -eq 0 ]
do
sleep 60
done
sleep 5
# Set db keys to prevent duplicates
#
mongo query_composer_development --eval \
'printjson( db.users.ensureIndex({ username : 1 }, { unique: true }))'
mongo query_composer_development --eval \
'printjson( db.endpoints.ensureIndex({ base_url : 1 }, { unique: true }))'
mongo query_composer_development --eval \
'printjson( db.users.ensureIndex({ username: 1 }, { unique: true }))'
mongo query_composer_development --eval \
'printjson( db.queries.ensureIndex({ description: 1 }, { unique: true }))'
# Dump MongoDB, report failure if unsuccessful
#
mkdir -p /data/dump/
mongodump --out /data/dump/
# Import admin and user accounts
#
mongo query_composer_development --eval \
'db.users.insert({ "first_name" : "PDC", "last_name" : "Admin", "username" : "admin", "email" : "admin@pdcbc.ca", "encrypted_password" : "\$2a\$10\$ZSuPxdODbumiMGOxtVSpRu0Rd0fQ2HhC7tMu2IobKTaAsPMmFlBD.", "agree_license" : true, "approved" : true, "admin" : true })'
mongo query_composer_development --eval \
'db.users.insert({ "first_name" : "PDC", "last_name" : "User", "username" : "user", "email" : "user@pdcbc.ca", "encrypted_password" : "\$2a\$10\$ZSuPxdODbumiMGOxtVSpRu0Rd0fQ2HhC7tMu2IobKTaAsPMmFlBD.", "agree_license" : true, "approved" : true, "admin" : false })'