forked from AppDaemon/appdaemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerStart.sh
41 lines (33 loc) · 1.33 KB
/
dockerStart.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
#!/bin/sh
CONF=/conf
CONF_SRC=/usr/src/app/conf
# if configuration file doesn't exist, copy the default
if [ ! -f $CONF/appdaemon.yaml ]; then
cp $CONF_SRC/appdaemon.yaml.example $CONF/appdaemon.yaml
fi
# if apps folder doesn't exist, copy the default
if [ ! -d $CONF/apps ]; then
cp -r $CONF_SRC/apps $CONF/apps
fi
# if dashboards folder doesn't exist, copy the default
if [ ! -d $CONF/dashboards ]; then
cp -r $CONF_SRC/dashboards $CONF/dashboards
fi
# if ENV HA_URL is set, change the value in appdaemon.yaml
if [ -n "$HA_URL" ]; then
sed -i "s/^ ha_url:.*/ ha_url: $(echo $HA_URL | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')/" $CONF/appdaemon.yaml
fi
# if ENV HA_KEY is set, change the value in appdaemon.yaml
if [ -n "$HA_KEY" ]; then
sed -i "s/^ ha_key:.*/ ha_key: $(echo $HA_KEY | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')/" $CONF/appdaemon.yaml
fi
# if ENV DASH_URL is set, change the value in appdaemon.yaml
if [ -n "$DASH_URL" ]; then
if grep -q "^ dash_url" $CONF/appdaemon.yaml; then
sed -i "s/^ dash_url:.*/ dash_url: $(echo $DASH_URL | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')/" $CONF/appdaemon.yaml
else
sed -i "s/# Apps/HADashboard:\r\n dash_url: $(echo $DASH_URL | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')\r\n# Apps/" $CONF/appdaemon.yaml
fi
fi
# Lets run it!
appdaemon -c $CONF $EXTRA_CMD