Skip to content

Commit

Permalink
🚑 Adds in wait for InfluxDB to become ready
Browse files Browse the repository at this point in the history
Ref #6
  • Loading branch information
frenck committed Sep 25, 2018
1 parent 930e1da commit 07886ac
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions influxdb/rootfs/etc/cont-init.d/20-system-users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,40 @@ exec 3< <(influxd)

sleep 3

for i in {30..0}; do
if influx -execute "SHOW DATABASES" &> /dev/null; then
break;
fi
hassio.log.info "InfluxDB init process in progress..."
sleep 2
done

if [[ "$i" = 0 ]]; then
hass.die "InfluxDB init process failed."
fi

influx -execute \
"CREATE USER chronograf WITH PASSWORD '${HASSIO_TOKEN}'" \
|| true
&> /dev/null || true

influx -execute \
"SET PASSWORD FOR chronograf = '${HASSIO_TOKEN}'" \
|| true
&> /dev/null || true

influx -execute \
"GRANT ALL PRIVILEGES TO chronograf" \
|| true
&> /dev/null || true

influx -execute \
"CREATE USER kapacitor WITH PASSWORD '${HASSIO_TOKEN}'" \
|| true
&> /dev/null || true

influx -execute \
"SET PASSWORD FOR kapacitor = '${HASSIO_TOKEN}'" \
|| true
&> /dev/null || true

influx -execute \
"GRANT ALL PRIVILEGES TO kapacitor" \
|| true
&> /dev/null || true

kill "$(pgrep influxd)" >/dev/null 2>&1

0 comments on commit 07886ac

Please sign in to comment.