-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrun.sh
61 lines (55 loc) · 1.83 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
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
#!/usr/bin/env bashio
export MQTTHOST=$(bashio::config "mqtt_host")
export MQTTPORT=$(bashio::config "mqtt_port")
export MQTTUSER=$(bashio::config "mqtt_user")
export MQTTPASSWORD=$(bashio::config "mqtt_password")
if [ $MQTTHOST = '<auto_detect>' ]; then
if bashio::services.available 'mqtt'; then
MQTTHOST=$(bashio::services mqtt "host")
if [ $MQTTHOST = 'localhost' ] || [ $MQTTHOST = '127.0.0.1' ]; then
echo "Discovered invalid value for MQTT host: ${MQTTHOST}"
echo "Overriding with default alias for Mosquitto MQTT addon"
MQTTHOST="core-mosquitto"
fi
echo "Using discovered MQTT Host: ${MQTTHOST}"
else
echo "No Home Assistant MQTT service found, using defaults"
MQTTHOST="172.30.32.1"
echo "Using default MQTT Host: ${MQTTHOST}"
fi
else
echo "Using configured MQTT Host: ${MQTTHOST}"
fi
if [ $MQTTPORT = '<auto_detect>' ]; then
if bashio::services.available 'mqtt'; then
MQTTPORT=$(bashio::services mqtt "port")
echo "Using discovered MQTT Port: ${MQTTPORT}"
else
MQTTPORT="1883"
echo "Using default MQTT Port: ${MQTTPORT}"
fi
else
echo "Using configured MQTT Port: ${MQTTPORT}"
fi
if [ $MQTTUSER = '<auto_detect>' ]; then
if bashio::services.available 'mqtt'; then
MQTTUSER=$(bashio::services mqtt "username")
echo "Using discovered MQTT User: ${MQTTUSER}"
else
MQTTUSER=""
echo "Using anonymous MQTT connection"
fi
else
echo "Using configured MQTT User: ${MQTTUSER}"
fi
if [ $MQTTPASSWORD = '<auto_detect>' ]; then
if bashio::services.available 'mqtt'; then
MQTTPASSWORD=$(bashio::services mqtt "password")
echo "Using discovered MQTT password: <hidden>"
else
MQTTPASSWORD=""
fi
else
echo "Using configured MQTT password: <hidden>"
fi
node index.js