mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 13:44:20 +01:00
49
check_config/data/run.sh
Executable file
49
check_config/data/run.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bashio
|
||||
set -e
|
||||
|
||||
VERSION=$(bashio::config 'version')
|
||||
|
||||
# Generate install string
|
||||
CMD="homeassistant"
|
||||
if [ "${VERSION}" != "latest" ]; then
|
||||
CMD="homeassistant==${VERSION}"
|
||||
fi
|
||||
|
||||
bashio::log.info "Installing Home Assistant: ${VERSION}..."
|
||||
bashio::log.info "Please be patient, this might take a few minutes..."
|
||||
|
||||
# Install Home Assistant with the requested version
|
||||
if ! PIP_OUTPUT="$(pip3 install --find-links "${WHEELS_LINKS}" "${CMD}")"; then
|
||||
bashio::log.error "An error occurred while installing Home Assistant:"
|
||||
bashio::log "${PIP_OUTPUT}"
|
||||
bashio::exit.nok
|
||||
fi
|
||||
INSTALLED_VERSION="$(pip freeze | grep homeassistant)"
|
||||
bashio::log.info "Installed Home Assistant ${INSTALLED_VERSION##*=}"
|
||||
bashio::log.info "Don't worry, this temporary installation is not overwriting your current one."
|
||||
|
||||
# Making an temporary copy of your configuration
|
||||
bashio::log.info "Making a copy of your configuration for checking..."
|
||||
cp -fr /config /tmp/config
|
||||
|
||||
# Start configuration check
|
||||
bashio::log.info "Checking your configuration against this version..."
|
||||
if ! HASS_OUTPUT="$(hass -c /tmp/config --script check_config)"; then
|
||||
# The configuration check exited with an error
|
||||
bashio::log.error "The configuration check did not pass!"
|
||||
bashio::log.error "See the output below for more details."
|
||||
bashio::log "${HASS_OUTPUT}"
|
||||
bashio::exit.nok
|
||||
fi
|
||||
|
||||
# Scan configuration check output for occurrances of "ERROR"
|
||||
if echo "${HASS_OUTPUT}" | grep -i ERROR > /dev/null; then
|
||||
# An "ERROR" occurance has been found, exit with an error
|
||||
bashio::log.error "Found an error in the log output of the check!"
|
||||
bashio::log.error "See the output below for more details."
|
||||
bashio::log "${HASS_OUTPUT}"
|
||||
bashio::exit.nok
|
||||
fi
|
||||
|
||||
# You rock! <(*_*)>
|
||||
bashio::log.info "Configuration check finished - no error found! :)"
|
||||
Reference in New Issue
Block a user