-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear-all-data.sh
executable file
·47 lines (43 loc) · 2.1 KB
/
clear-all-data.sh
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
44
45
46
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# OpenCRVS is also distributed under the terms of the Civil Registration
# & Healthcare Disclaimer located at http://opencrvs.org/license.
#
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
# graphic logo are (registered/a) trademark(s) of Plan International.
if [ "$REPLICAS" = "0" ]; then
HOST=mongo1
NETWORK=opencrvs_default
echo "Working with no replicas"
elif [ "$REPLICAS" = "1" ]; then
HOST=rs0/mongo1
NETWORK=opencrvs_overlay_net
echo "Working with 1 replica"
elif [ "$REPLICAS" = "3" ]; then
HOST=rs0/mongo1,mongo2,mongo3
NETWORK=opencrvs_overlay_net
echo "Working with 3 replicas"
elif [ "$REPLICAS" = "5" ]; then
HOST=rs0/mongo1,mongo2,mongo3,mongo4,mongo5
NETWORK=opencrvs_overlay_net
echo "Working with 5 replicas"
else
echo "Script must be passed an understandable number of replicas: 0,1,3 or 5"
exit 1
fi
mongo_credentials() {
if [ ! -z ${MONGODB_ADMIN_USER+x} ] || [ ! -z ${MONGODB_ADMIN_PASSWORD+x} ]; then
echo "--username $MONGODB_ADMIN_USER --password $MONGODB_ADMIN_PASSWORD --authenticationDatabase admin";
else
echo "";
fi
}
# It's fine if these fail as it might be that the databases do not exist at this point
docker run --rm --network=$NETWORK mongo:4.4 mongo hearth-dev $(mongo_credentials) --host $HOST --eval "db.dropDatabase()"
docker run --rm --network=$NETWORK mongo:4.4 mongo openhim-dev $(mongo_credentials) --host $HOST --eval "db.dropDatabase()"
docker run --rm --network=$NETWORK mongo:4.4 mongo user-mgnt $(mongo_credentials) --host $HOST --eval "db.dropDatabase()"
docker run --rm --network=$NETWORK mongo:4.4 mongo application-config $(mongo_credentials) --host $HOST --eval "db.dropDatabase()"
docker run --rm --network=$NETWORK appropriate/curl curl -XDELETE 'http://elasticsearch:9200/*' -v
docker run --rm --network=$NETWORK appropriate/curl curl -X POST 'http://influxdb:8086/query?db=ocrvs' --data-urlencode "q=DROP SERIES FROM /.*/" -v