-
Notifications
You must be signed in to change notification settings - Fork 688
/
docker-entrypoint.sh
26 lines (24 loc) · 990 Bytes
/
docker-entrypoint.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
#!/bin/bash
if [ ! -f /app/db/PrometheusAlertDB.db ]; then
cp /opt/PrometheusAlertDB.db /app/db/PrometheusAlertDB.db
echo 'init ok!'
else
echo 'pass!'
fi
if env | grep -q '^PA_.\+=.\+'; then
for VAR_NAME in $(env | grep '^PA_.\+=.\+' | sed -r "s/^PA_([^=]*).*/\1/g");do
if echo ${VAR_NAME} | grep -q '.*\-.*'; then
echo "\"PA_${VAR_NAME}\" in Environment variable contains '-',this will be ignored."
continue
fi
CONF_ITEM=$(grep -Eio "${VAR_NAME/_/-}|${VAR_NAME}" /app/conf/app.conf|tail -n 1)
if [[ -z ${CONF_ITEM} ]]; then
echo "\"PA_${VAR_NAME}\" in Environment variable not found from config file"
continue
fi
CONF_CONTENT=$(eval echo \${PA_${VAR_NAME}})
echo "Config overridden from Environment variable, ${CONF_ITEM}=${CONF_CONTENT}."
sed -i -E "s@(${CONF_ITEM})(\ *=\ *).*@\1\2${CONF_CONTENT}@i" /app/conf/app.conf
done
fi
exec /app/PrometheusAlert