diff --git a/wmbusmeters-ha-addon-edge/rootfs/etc/services.d/wmbusmeters/finish b/wmbusmeters-ha-addon-edge/rootfs/etc/services.d/wmbusmeters/finish new file mode 100644 index 0000000..a9ef5ef --- /dev/null +++ b/wmbusmeters-ha-addon-edge/rootfs/etc/services.d/wmbusmeters/finish @@ -0,0 +1,13 @@ +#!/usr/bin/env bashio +# ============================================================================== +# Take down the S6 supervision tree when service fails +# s6-overlay docs: https://github.com/just-containers/s6-overlay +# ============================================================================== + +if [[ "$1" -ne 0 ]] && [[ "$1" -ne 256 ]]; then + bashio::log.warning "wmbusmeters exited with status $1. Restarting..." + sleep 2 + exit 111 +fi + +exit 0 diff --git a/wmbusmeters-ha-addon-edge/run.sh b/wmbusmeters-ha-addon-edge/run.sh index 675d219..210c164 100644 --- a/wmbusmeters-ha-addon-edge/run.sh +++ b/wmbusmeters-ha-addon-edge/run.sh @@ -40,7 +40,9 @@ then mkdir -p /data/drivers fi rm -rf ${CONFIG_DATA_PATH}/etc/wmbusmeters.drivers.d/* -cp /data/drivers/* ${CONFIG_DATA_PATH}/etc/wmbusmeters.drivers.d/ || true +if [ -n "$(ls -A /data/drivers 2>/dev/null)" ]; then + cp /data/drivers/* "${CONFIG_DATA_PATH}/etc/wmbusmeters.drivers.d/" +fi echo -e "$CONFIG_CONF" | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' > $CONFIG_DATA_PATH/etc/wmbusmeters.conf @@ -111,8 +113,5 @@ chmod a+x /wmbusmeters/mosquitto_pub.sh # Running MQTT discovery /mqtt_discovery.sh ${pub_args[@]} -c $CONFIG_PATH -w $CONFIG_DATA_PATH || true -#bashio::log.info "Starting web configuration service." -#python3 /flask/app.py & - bashio::log.info "Running wmbusmeters ..." -/wmbusmeters/wmbusmeters --usestdoutforlogging --useconfig=$CONFIG_DATA_PATH +/wmbusmeters/wmbusmeters --useconfig=$CONFIG_DATA_PATH