diff --git a/check_config/Dockerfile b/check_config/Dockerfile new file mode 100644 index 0000000..fab0ef5 --- /dev/null +++ b/check_config/Dockerfile @@ -0,0 +1,15 @@ +FROM %%BASE_IMAGE%% + +# Add version +ENV VERSION %%VERSION%% +ENV LANG C.UTF-8 + +# Setup base +RUN apk add --no-cache jq python3 \ + && pip3 install --no-cache --upgrade pip + +# Copy data +COPY run.sh / +RUN chmod a+x /run.sh + +CMD [ "/run.sh" ] diff --git a/check_config/config.json b/check_config/config.json new file mode 100644 index 0000000..806ce5d --- /dev/null +++ b/check_config/config.json @@ -0,0 +1,16 @@ +{ + "name": "Check HomeAssistant config", + "version": "0.1", + "slug": "check_config", + "description": "Check HomeAssistant config with a new version", + "url": "https://home-assistant.io/addons/check_config/", + "startup": "once", + "boot": "manual", + "map": ["config", "ssl"], + "options": { + "version": "latest" + }, + "schema": { + "version": "str" + } +} diff --git a/check_config/run.sh b/check_config/run.sh new file mode 100644 index 0000000..c50b99b --- /dev/null +++ b/check_config/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +CONFIG_PATH=/data/options.json + +VERSION=$(jq --raw-output ".version" $CONFIG_PATH) + +# generate install string +if [ "$VERSION" == "latest" ]; then + CMD="homeassistant" +else + CMD="homeassistant==$VERSION" +fi + +echo "[INFO] Start install HomeAssistant $VERSION" + +if ! PIP_OUTPUT="$(pip3 install "$CMD")" +then + echo "[ERROR] Install HomeAssistant: $PIP_OUTPUT" + exit 1 +fi + +echo "[INFO] Install done, check config now" + +exec hass -c /config --script check_config