File tree Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Original file line number Diff line number Diff line change 66# shellcheck disable=SC1091
77source /usr/lib/hassio-addons/base.sh
88
9+ declare secret
10+
11+ # If secret file exists, skip this script
12+ if hass.file_exists " /data/secret" ; then
13+ exit 0
14+ fi
15+
16+ # Generate secret based on the Hass.io token
17+ secret=" ${HASSIO_TOKEN: 21: 32} "
18+
919exec 3< <( influxd)
1020
1121sleep 3
@@ -23,27 +33,30 @@ if [[ "$i" = 0 ]]; then
2333fi
2434
2535influx -execute \
26- " CREATE USER chronograf WITH PASSWORD '${HASSIO_TOKEN } '" \
36+ " CREATE USER chronograf WITH PASSWORD '${secret } '" \
2737 & > /dev/null || true
2838
2939influx -execute \
30- " SET PASSWORD FOR chronograf = '${HASSIO_TOKEN } '" \
40+ " SET PASSWORD FOR chronograf = '${secret } '" \
3141 & > /dev/null || true
3242
3343influx -execute \
3444 " GRANT ALL PRIVILEGES TO chronograf" \
3545 & > /dev/null || true
3646
3747influx -execute \
38- " CREATE USER kapacitor WITH PASSWORD '${HASSIO_TOKEN } '" \
48+ " CREATE USER kapacitor WITH PASSWORD '${secret } '" \
3949 & > /dev/null || true
4050
4151influx -execute \
42- " SET PASSWORD FOR kapacitor = '${HASSIO_TOKEN } '" \
52+ " SET PASSWORD FOR kapacitor = '${secret } '" \
4353 & > /dev/null || true
4454
4555influx -execute \
4656 " GRANT ALL PRIVILEGES TO kapacitor" \
4757 & > /dev/null || true
4858
4959kill " $( pgrep influxd) " > /dev/null 2>&1
60+
61+ # Save secret for future use
62+ echo " ${secret} " > /data/secret
Original file line number Diff line number Diff line change 66# shellcheck disable=SC1091
77source /usr/lib/hassio-addons/base.sh
88
9- sed -i " s/password.*/password = \" ${HASSIO_TOKEN} \" /" \
9+ declare secret
10+
11+ secret=$( < /data/secret)
12+
13+ sed -i " s/password.*/password = \" ${secret} \" /" \
1014 /etc/kapacitor/kapacitor.conf
Original file line number Diff line number Diff line change 88source /usr/lib/hassio-addons/base.sh
99
1010declare -a options
11+ declare secret
1112
1213# Wait for InfluxDB to become available
1314s6-svwait -u -t 5000 /var/run/s6/services/influxdb
1415
1516# Wait for Kapacitor to become available
1617s6-svwait -u -t 5000 /var/run/s6/services/kapacitor
1718
19+ secret=$(</data/secret)
20+
1821# Wait for InfluxDB...
1922hass.log.info "Chronograf is waiting until InfluxDB is available..."
2023for i in {1800..0}; do
2124 if influx \
2225 -execute "SHOW DATABASES" \
2326 -username "chronograf" \
24- -password "${HASSIO_TOKEN }" \
27+ -password "${secret }" \
2528 > /dev/null 2>&1; then
2629 break;
2730 fi
@@ -40,7 +43,7 @@ options+=(--bolt-path=/data/chronograf.db)
4043options+=(--influxdb-url="http://localhost:8086")
4144
4245options+=(--influxdb-username="chronograf")
43- options+=(--influxdb-password="${HASSIO_TOKEN }")
46+ options+=(--influxdb-password="${secret }")
4447options+=(--kapacitor-url="http://localhost:9092")
4548
4649# Find the matching Chronograph log level
Original file line number Diff line number Diff line change 66# shellcheck disable=SC1091
77source /usr/lib/hassio-addons/base.sh
88
9+ declare secret
10+
911# Wait for InfluxDB to become available
1012s6-svwait -u -t 5000 /var/run/s6/services/influxdb
1113
14+ secret=$(</data/secret)
15+
1216# Wait for InfluxDB...
1317hass.log.info "Kapacitor is waiting until InfluxDB is available..."
1418for i in {1800..0}; do
1519 if influx \
1620 -execute "SHOW DATABASES" \
1721 -username "kapacitor" \
18- -password "${HASSIO_TOKEN }" \
22+ -password "${secret }" \
1923 > /dev/null 2>&1; then
2024 break;
2125 fi
You can’t perform that action at this time.
0 commit comments