🔨 replace copy with symlink from /config

This commit is contained in:
Timmo 2018-10-06 17:40:59 +01:00
parent b5cf42fbea
commit 4e7933306e
7 changed files with 9 additions and 93 deletions

View file

@ -14,7 +14,8 @@ if [ ! -f "$config_file" ]; then
hass.log.info "Created. You should now edit this file at '$config_file'"
fi
hass.log.info "Copy config to API.."
mkdir -p /usr/src/api/files
cp "$config_file" /usr/src/api/files/config.json
if [ ! -f "/usr/src/api/files/config.json" ]; then
hass.log.info "Symlink config to API directory.."
mkdir -p /usr/src/api/files
ln -sf "$config_file" /usr/src/api/files/config.json
fi

View file

@ -15,8 +15,9 @@ if hass.config.true 'ssl'; then
cp "$keyfile" /usr/src/api/privkey.pem
fi
if hass.file_exists "/config/home-panel.db"; then
hass.log.info "Copy DB to api.."
if [ ! -f "/config/home-panel.db" ]; then
hass.log.info "Symlink DB to API directory.."
touch /config/home-panel.db
mkdir -p /usr/src/api/files
cp /config/home-panel.db /usr/src/api/files/home-panel.db
ln -sf "/config/home-panel.db" /usr/src/api/files/home-panel.db
fi

View file

@ -1,38 +0,0 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Timmo Hass.io Add-ons: Home Panel
# This copies the nginx configs to their respective locations
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
certfile="/ssl/$(hass.config.get 'certfile')"
keyfile="/ssl/$(hass.config.get 'keyfile')"
if hass.config.true 'ssl'; then
hass.log.info "Copy enabled SSL nginx config"
echo "server {
listen 8234 ssl http2 default_server;
listen [::]:8234 ssl http2 default_server;
root /usr/share/nginx/html;
index index.html;
server_name 172.0.0.1;
ssl_certificate ${certfile};
ssl_certificate_key ${keyfile};
location / {
try_files \$uri /index.html;
}
}" > /etc/nginx/conf.d/default.conf;
else
hass.log.info "Copy disabled SSL nginx config"
echo "server {
listen 8234 default_server;
listen [::]:8234 default_server;
root /usr/share/nginx/html;
index index.html;
server_name 172.0.0.1;
location / {
try_files \$uri /index.html;
}
}" > /etc/nginx/conf.d/default.conf;
fi

View file

@ -1,9 +0,0 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Timmo Hass.io Add-ons: Home Panel
# Take down the S6 supervision tree when Home Panel fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -1,16 +0,0 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Timmo Hass.io Add-ons: Home Panel
# Keeps the config file up to date
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
config_file="/config/$(hass.config.get 'config_file')"
# shellcheck disable=SC2162
# shellcheck disable=SC2034
inotifywait -e modify -m "$config_file" | while read file; do \
hass.log.debug "Update Config.." \
&& cp "$config_file" /usr/src/api/files/config.json; \
done

View file

@ -1,9 +0,0 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Timmo Hass.io Add-ons: Home Panel
# Take down the S6 supervision tree when Home Panel fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -1,14 +0,0 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Timmo Hass.io Add-ons: Home Panel
# Copy back db to preserve data between restarts
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# shellcheck disable=SC2162
# shellcheck disable=SC2034
inotifywait -m "/usr/src/api/files/home-panel.db" | while read file; do \
hass.log.debug "Backup db.." \
&& cp /usr/src/api/files/home-panel.db /config/home-panel.db; \
done