-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.sh
executable file
·47 lines (38 loc) · 1.15 KB
/
startup.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
#!/bin/bash
set -e
PASSWORD_FILE="/run/secrets/$ROOT_PASSWORD_SECRET"
if [ ! -f $PASSWORD_FILE ]; then
echo "Password file '$PASSWORD_FILE' not found. ROOT_PASSWORD_SECRET is required and must be bound as a secret"
exit 1
fi
SHAREDKEY_FILE="/run/secrets/$SHARED_KEY_SECRET"
if [ "$SHARED_KEY_SECRET" != "" ]; then
if [ ! -f "$SHAREDKEY_FILE" ]; then
echo "SHARED_KEY_SECRET was defined but no secret found at $SHAREDKEY_FILE"
exit 1
fi
cp $SHAREDKEY_FILE /sharedkey
chmod 600 /sharedkey
fi
if [ "$REPLICA_SET_NAME" = "" ]; then
echo "REPLICA_SET_NAME is required"
exit 2
fi
if [ "$ROOT_USERNAME" = "" ]; then
echo "ROOT_USERNAME is required"
exit 2
fi
/config.sh &
#MAX WIRED TIGER CACHE
#https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-wiredtigercachesizegb
WC=""
if [ "$WIRED_TIGER_CACHE_SIZE_GB" != "" ]; then
WC="--wiredTigerCacheSizeGB $WIRED_TIGER_CACHE_SIZE_GB"
fi
echo ">>> Starting Mongo replica..."
AE=""
if [ "$SHARED_KEY_SECRET" != "" ]; then
AE="--keyFile /sharedkey"
fi
set -x
mongod --port 27017 $AE $WC --replSet $REPLICA_SET_NAME --bind_ip_all --dbpath /data