🔨 Rewrite to use bashio

This commit is contained in:
ludeeus 2019-03-24 13:58:20 +01:00
parent 2f230c47ab
commit 4a9cdd344e
5 changed files with 11 additions and 37 deletions

View file

@ -1,26 +1,8 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Phlex
# This files check if all user configuration requirements are met
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Check SSL requirements, if enabled
if hass.config.true 'ssl'; then
if ! hass.config.has_value 'certfile'; then
hass.die 'SSL is enabled, but no certfile was specified'
fi
if ! hass.config.has_value 'keyfile'; then
hass.die 'SSL is enabled, but no keyfile was specified'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'certfile')"; then
hass.die 'The configured certfile is not found'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then
hass.die 'The configured keyfile is not found'
fi
fi
bashio::config.require.ssl 'ssl' 'certfile' 'keyfile'

View file

@ -1,12 +1,10 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Phlex
# Configures Phlex
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
if ! hass.file_exists '/data/config.php'; then
if ! bashio::fs.file_exists '/data/config.php'; then
cp /opt/default_config.php /data/config.php
fi

View file

@ -1,28 +1,26 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Phlex
# Configures NGINX for use with Phlex
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
declare certfile
declare keyfile
# Enable SSL
if hass.config.true 'ssl'; then
if bashio::config.true 'ssl'; then
rm /etc/nginx/nginx.conf
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
certfile=$(hass.config.get 'certfile')
keyfile=$(hass.config.get 'keyfile')
certfile=$(bashio::.config 'certfile')
keyfile=$(bashio::.config 'keyfile')
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
fi
# Disables IPv6 in case its disabled by the user
if ! hass.config.true 'ipv6'; then
if ! bashio::config.true 'ipv6'; then
sed -i '/listen \[::\].*/ d' /etc/nginx/nginx.conf
fi

View file

@ -1,13 +1,11 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Phlex
# Runs the NGINX daemon
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Wait for PHP-FPM to become available
s6-svwait -u -t 5000 /var/run/s6/services/php-fpm
hass.log.info "Starting Phlex..."
bashio::log.info "Starting Phlex..."
exec nginx -g "daemon off;"

View file

@ -3,7 +3,5 @@
# Community Hass.io Add-ons: Phlex
# Runs the PHP-FPM daemon
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
exec php-fpm7 --nodaemonize