-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
68 lines (55 loc) · 2.19 KB
/
entrypoint.sh
File metadata and controls
68 lines (55 loc) · 2.19 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
CONF=/appdaemon
VAPPS=/apps
VDASH=/dashboards
# if configuration file doesn't exist, fail
if [ ! -f $CONF/appdaemon.yaml ]; then
echo "appdaemon.yaml does not exist. Exiting..."
exit 1
fi
# if apps folder doesn't exist, fail
if [ ! -d $CONF/apps ]; then
echo "app folder does not exist. Exiting..."
exit 2
fi
echo "Copying app files from ${VAPPS} to ${CONF}/apps"
cp --verbose -rf ${VAPPS}/** ${CONF}/apps
# if apps file doesn't exist, fail
if [ ! -f $CONF/apps/apps.yaml ]; then
# cp $CONF_SRC/apps/apps.yaml.example $CONF/apps/apps.yaml
echo "apps.yaml does not exist. Exiting..."
exit 3
fi
# if dashboards folder doesn't exist, fail
if [ ! -d $CONF/dashboards ]; then
echo "dashboards folder does not exist. Exiting..."
exit 4
fi
echo "Copying dashboard files from ${VDASH} to ${CONF}/dashboards"
cp --verbose -rf ${VDASH}/** ${CONF}/dashboards
# if ENV HA_URL is set, change the value in appdaemon.yaml
if [ -n "$API_KEY" ]; then
sed -i "s/^ api_key:.*/ api_key: $(echo $API_KEY | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')/" $CONF/appdaemon.yaml
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_TOKEN is set, change the value in appdaemon.yaml
if [ -n "$HA_TOKEN" ]; then
sed -i "s/^ token:.*/ token: $(echo $HA_TOKEN | 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!
exec appdaemon -c $CONF $EXTRA_CMD