forked from cloudflare/docker-opentsdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·32 lines (23 loc) · 1.21 KB
/
run.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
#!/bin/bash
set -e
export TSD_CONF_tsd__network__port=${TSD_CONF_tsd__network__port:-${PORT}}
export TSD_CONF_tsd__http__cachedir=${TSD_CONF_tsd__http__cachedir:-/var/cache/opentsdb}
export TSD_CONF_tsd__http__staticroot=${TSD_CONF_tsd__http__staticroot:-/usr/local/share/opentsdb/static}
if [ ! -e /etc/opentsdb/opentsdb.conf ]; then
touch /etc/opentsdb/opentsdb.conf
for VAR in $(env); do
if [[ $VAR =~ ^TSD_CONF_ ]]; then
tsd_conf_name=$(echo "$VAR" | sed -r 's/^TSD_CONF_([^=]*)=.*/\1/' | sed 's/__/./g' | tr '[:upper:]' '[:lower:]')
tsd_conf_value=$(echo "$VAR" | sed -r "s/^[^=]*=(.*)/\1/")
echo "$tsd_conf_name = $tsd_conf_value" >> /etc/opentsdb/opentsdb.conf
fi
done
fi
export TSD_ROOT_LOG_LEVEL=${TSD_ROOT_LOG_LEVEL:-INFO}
export TSD_QUERY_LOG_LEVEL=${TSD_QUERY_LOG_LEVEL:-INFO}
export TSD_LOG_SERVICE_VERSION=${VCS_REF:-unknown}
sed "s/{{ROOT_LOG_LEVEL}}/${TSD_ROOT_LOG_LEVEL}/" -i /etc/opentsdb/logback.xml
sed "s/{{QUERY_LOG_LEVEL}}/${TSD_QUERY_LOG_LEVEL}/" -i /etc/opentsdb/logback.xml
sed "s/{{SERVICE_VERSION}}/${TSD_LOG_SERVICE_VERSION}/" -i /etc/opentsdb/logback.xml
chown opentsdb "${TSD_CONF_tsd__http__cachedir}"
exec gosu opentsdb /unprivileged.sh "$@"