mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 21:24:20 +01:00
Refactor of check_config add-on (#586)
* check_config: Rewrite onto Bashio * check_config: Removed extra slash from Dockerfile * check_config: Added README file * check_config: Formatted config.json, changed link * check_config: Bumped version, updated changelog * Update Dockerfile * Update run.sh * Update CHANGELOG.md * check_config: Added Known issues and limitations section to README * check_config: Bumped version to 2.0 * check_config: Bumped version in CHANGELOG * check_config: Remove typo in option name in README
This commit is contained in:
committed by
Pascal Vizeli
parent
7e6adcab32
commit
0f936dfb31
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2.0
|
||||
- Migrated add-on onto Bashio
|
||||
- Improved add-on log output
|
||||
- Added documentation to add-on itself
|
||||
- Added support for Home Assistant wheels repository
|
||||
|
||||
## 1.0
|
||||
- Update to Python 3.7
|
||||
- Add colorlog to pip packages
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
# Setup base
|
||||
RUN apk add --no-cache \
|
||||
jq \
|
||||
gcc \
|
||||
libffi-dev \
|
||||
openssl-dev \
|
||||
musl-dev \
|
||||
# Add Hass.io wheels repository
|
||||
ARG BUILD_ARCH
|
||||
ENV WHEELS_LINKS=https://wheels.home-assistant.io/alpine-3.9/${BUILD_ARCH}/
|
||||
|
||||
# Copy data
|
||||
COPY run.sh /
|
||||
|
||||
79
check_config/README.md
Normal file
79
check_config/README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Hass.io Core Add-on: Check Home Assistant configuration
|
||||
|
||||
Check your current configuration against any Home Assistant version.
|
||||
|
||||
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield]
|
||||
|
||||
## About
|
||||
|
||||
You can use this add-on to check whether your configuration files are valid against the
|
||||
new version of Home Assistant before you actually update your Home Assistant
|
||||
installation. This add-on will help you avoid errors due to breaking changes,
|
||||
resulting in a smooth update.
|
||||
|
||||
## Installation
|
||||
|
||||
The installation of this add-on is straightforward and easy to do.
|
||||
|
||||
1. Navigate in your Home Assistant frontend to **Hass.io** -> **Add-on Store**.
|
||||
2. Find the "Check Home Assistant configuration" add-on and click it.
|
||||
3. Click on the "INSTALL" button.
|
||||
|
||||
## How to use
|
||||
|
||||
In the configuration section, set the version you want to check your configuration
|
||||
against. In case you'd like to check your configuration against the latest version of
|
||||
Home Assistant, just leave `latest`, which is already there as the default.
|
||||
|
||||
1. Start the add-on.
|
||||
2. Have some patience and wait a couple of minutes.
|
||||
3. Check the add-on log output to see the result.
|
||||
|
||||
If the log ends with `Configuration check finished - no error found! :)`,
|
||||
it means the check against your configuration passes on the specified
|
||||
Home Assistant version.
|
||||
|
||||
## Configuration
|
||||
|
||||
Add-on configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "latest"
|
||||
}
|
||||
```
|
||||
|
||||
### Option: `version` (required)
|
||||
|
||||
The version of Home Assistant that want to check your configuration against.
|
||||
|
||||
Setting this option to `latest` will result in checking your configuration
|
||||
against the latest stable release of Home Assistant.
|
||||
|
||||
## Known issues and limitations
|
||||
|
||||
- Currently, this add-on only support checking against Home Assistant >= 0.94
|
||||
or less 0.91.
|
||||
|
||||
## Support
|
||||
|
||||
Got questions?
|
||||
|
||||
You have several options to get them answered:
|
||||
|
||||
- The [Home Assistant Discord Chat Server][discord].
|
||||
- The Home Assistant [Community Forum][forum].
|
||||
- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit]
|
||||
|
||||
In case you've found an bug, please [open an issue on our GitHub][issue].
|
||||
|
||||
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
|
||||
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
|
||||
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
|
||||
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
|
||||
[discord]: https://discord.gg/c5DvZ4e
|
||||
[forum]: https://community.home-assistant.io
|
||||
[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg
|
||||
[issue]: https://github.com/home-assistant/hassio-addons/issues
|
||||
[reddit]: https://reddit.com/r/homeassistant
|
||||
[repository]: https://github.com/hassio-addons/repository
|
||||
@@ -1,13 +1,22 @@
|
||||
{
|
||||
"name": "Check Home Assistant configuration",
|
||||
"version": "1.0",
|
||||
"version": "2.0",
|
||||
"slug": "check_config",
|
||||
"description": "Check current Home Assistant configuration against a new version",
|
||||
"url": "https://home-assistant.io/addons/check_config/",
|
||||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/check_config",
|
||||
"arch": [
|
||||
"armhf",
|
||||
"armv7",
|
||||
"aarch64",
|
||||
"amd64",
|
||||
"i386"
|
||||
],
|
||||
"startup": "once",
|
||||
"boot": "manual",
|
||||
"map": ["config", "ssl"],
|
||||
"map": [
|
||||
"config",
|
||||
"ssl"
|
||||
],
|
||||
"options": {
|
||||
"version": "latest"
|
||||
},
|
||||
|
||||
@@ -1,42 +1,48 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bashio
|
||||
set -e
|
||||
|
||||
CONFIG_PATH=/data/options.json
|
||||
VERSION=$(bashio::config 'version')
|
||||
|
||||
VERSION=$(jq --raw-output ".version" $CONFIG_PATH)
|
||||
|
||||
# generate install string
|
||||
if [ "$VERSION" == "latest" ]; then
|
||||
CMD="homeassistant"
|
||||
else
|
||||
CMD="homeassistant==$VERSION"
|
||||
# Generate install string
|
||||
CMD="homeassistant"
|
||||
if [ "${VERSION}" != "latest" ]; then
|
||||
CMD="homeassistant==${VERSION}"
|
||||
fi
|
||||
|
||||
echo "[Info] Start install HomeAssistant $VERSION"
|
||||
bashio::log.info "Installing Home Assistant: ${VERSION}..."
|
||||
bashio::log.info "Please be patient, this might take a few minutes..."
|
||||
|
||||
if ! PIP_OUTPUT="$(pip3 install "$CMD")"
|
||||
then
|
||||
echo "[Error] Install HomeAssistant: $PIP_OUTPUT"
|
||||
exit 1
|
||||
# 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##*=}."
|
||||
|
||||
echo "[Info] Installed $INSTALLED_VERSION, check config now"
|
||||
|
||||
# Making an temporary copy of your configuration
|
||||
bashio::log.info "Making a copy of your configuration for checking..."
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
if echo "$HASS_OUTPUT" | grep -i ERROR > /dev/null
|
||||
then
|
||||
echo "[Error] Found error inside log output!"
|
||||
echo "$HASS_OUTPUT"
|
||||
exit 1
|
||||
# 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
|
||||
|
||||
echo "[Info] Configuration check finished - no error found! :)"
|
||||
# You rock! <(*_*)>
|
||||
bashio::log.info "Configuration check finished - no error found! :)"
|
||||
|
||||
Reference in New Issue
Block a user