This repository has been archived by the owner on Jan 21, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #1
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/with-contenv bash | ||
# ============================================================================== | ||
# Community Hass.io Add-ons: Happy Bubbles | ||
# Persists the presence database (and create if missing) | ||
# ============================================================================== | ||
# shellcheck disable=SC1091 | ||
source /usr/lib/hassio-addons/base.sh | ||
|
||
if ! hass.file_exists '/data/presence.db'; then | ||
hass.log.debug 'Starting Presence temporarly...' | ||
|
||
cd /opt || exit | ||
exec 3< <(./precense) | ||
|
||
# Wait until the db exists | ||
until hass.file_exists "/opt/precense.db"; do | ||
sleep 1 | ||
done | ||
|
||
# Just to be safe, wait another 2 seconds | ||
sleep 2 | ||
|
||
# Kill it, if still alive | ||
kill "$(pgrep precense)" >/dev/null 2>&1 || true | ||
|
||
# Move the created database into a safe place | ||
mv /opt/precense.db /data/precense.db | ||
|
||
hass.log.debug 'Persistent precense database created' | ||
fi | ||
|
||
ln -s /data/precense.db /opt/precense.db |