-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·52 lines (42 loc) · 1.3 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·52 lines (42 loc) · 1.3 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
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e
if [ ! "$MMS_API_KEY" ]; then
{
echo 'error: MMS_API_KEY was not specified'
echo 'try something like: docker run -e MMS_API_KEY=... ...'
echo '(see https://mms.mongodb.com/settings/monitoring-agent for your mmsApiKey)'
echo
echo 'Other variables:'
echo ' - MMS_GROUP_ID='"$MMS_GROUP_ID"
} >&2
exit 1
fi
if [ ! "$MMS_GROUP_ID" ]; then
{
echo 'error: MMS_GROUP_ID was not specified'
echo 'try something like: docker run -e MMS_GROUP_ID=... ...'
echo '(see https://mms.mongodb.com/settings/monitoring-agent for your mmsApiKey)'
echo
echo 'Other variables:'
echo ' - MMS_API_KEY='"$MMS_API_KEY"
} >&2
exit 1
fi
# "sed -i" can't operate on the file directly, and it tries to make a copy in the same directory, which our user can't do
config_tmp="$(mktemp)"
cat /etc/mongodb-mms/automation-agent.config > "$config_tmp"
set_config() {
key="$1"
value="$2"
sed_escaped_value="$(echo "$value" | sed 's/[\/&]/\\&/g')"
sed -ri "s/^($key)[ ]*=.*$/\1 = $sed_escaped_value/" "$config_tmp"
}
set_config mmsApiKey "$MMS_API_KEY"
set_config mmsGroupId "$MMS_GROUP_ID"
cat "$config_tmp" > /etc/mongodb-mms/automation-agent.config
rm "$config_tmp"
trap "echo TRAPed signal" HUP INT QUIT TERM
exec "$@"
echo "[hit enter key to exit] or run 'docker stop <container>'"
read
echo "exited $0"