Files
addons/check_config/run.sh
Pascal Vizeli e8fa8aa5c8 Update New CLI (#500)
* Update New CLI

* Fix shell

* ssh: Include hassio bash completion (#501)
2019-01-09 13:59:44 +01:00

43 lines
901 B
Bash
Executable File

#!/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
INSTALLED_VERSION="$(pip freeze | grep homeassistant)"
echo "[Info] Installed $INSTALLED_VERSION, check config now"
cp -fr /config /tmp/config
if ! HASS_OUTPUT="$(hass -c /tmp/config --script check_config)"
then
echo "[Error] Wrong config found!"
echo "$HASS_OUTPUT"
exit 1
fi
if echo "$HASS_OUTPUT" | grep -i ERROR > /dev/null
then
echo "[Error] Found error inside log output!"
echo "$HASS_OUTPUT"
exit 1
fi
echo "[Info] Configuration check finished - no error found! :)"