diff --git a/configurator/CHANGELOG.md b/configurator/CHANGELOG.md index efedb1d..5ab0900 100644 --- a/configurator/CHANGELOG.md +++ b/configurator/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.5 +- Added basic git stash functionality +- Added NOTIFY_SERVICE option +- Notifying if used passwords are insecure and when SESAME has been used +- PASSWORD can optionally be provided as SHA256 hash +- Added SESAME_TOTP_SECRET for TOTP based IP whitelisting +- Added git diff functionality +- Red colored menu button as indicator for outdated version +- Removed right dragging area for editor settings +- Added IGNORE_SSL option to disable SSL verification when connecting to HASS API +- Allow customizing loglevel +- Show client IP address in network status modal + ## 0.4 - Update Configurator to version 0.2.9 - Material Icons and HASS-help now open in new tab instead of modal diff --git a/configurator/Dockerfile b/configurator/Dockerfile index fbc866d..fae7e9a 100644 --- a/configurator/Dockerfile +++ b/configurator/Dockerfile @@ -1,19 +1,15 @@ ARG BUILD_FROM FROM $BUILD_FROM -# Add env -ENV LANG C.UTF-8 - # Setup base ARG CONFIGURATOR_VERSION -RUN apk add --no-cache python3 git curl \ - && pip3 install GitPython \ +RUN apk add --no-cache git curl openssh \ + && pip3 install --no-cache-dir GitPython pyotp \ && curl -s -o /configurator.py https://raw.githubusercontent.com/danielperna84/hass-configurator/$CONFIGURATOR_VERSION/configurator.py \ - && sed -i "s/GIT = False/GIT = True/g" /configurator.py \ && apk del curl # Copy data -COPY map.py run.sh / +COPY run.sh / RUN chmod a+x /run.sh CMD ["/run.sh"] diff --git a/configurator/build.json b/configurator/build.json index 9494063..e2be8bc 100644 --- a/configurator/build.json +++ b/configurator/build.json @@ -1,5 +1,11 @@ { + "build_from": { + "amd64": "homeassistant/amd64-base-python:3.6", + "i386": "homeassistant/i386-base-python:3.6", + "armhf": "homeassistant/armhf-base-python:3.6", + "aarch64": "homeassistant/aarch64-base-python:3.6" + }, "args": { - "CONFIGURATOR_VERSION": "0.2.9" + "CONFIGURATOR_VERSION": "0.3.1" } } diff --git a/configurator/config.json b/configurator/config.json index d2e90dd..bfc22a9 100644 --- a/configurator/config.json +++ b/configurator/config.json @@ -1,6 +1,6 @@ { "name": "Configurator", - "version": "0.4", + "version": "1.0", "slug": "configurator", "description": "Browser-based configuration file editor for Home Assistant.", "url": "https://home-assistant.io/addons/configurator", @@ -15,29 +15,33 @@ "options": { "username": "admin", "password": null, + "ssl": false, "certfile": "fullchain.pem", "keyfile": "privkey.pem", - "ssl": false, "allowed_networks": ["192.168.0.0/16", "172.30.0.0/16"], "banned_ips": ["8.8.8.8"], "banlimit": 0, "ignore_pattern": ["__pycache__"], "dirsfirst": false, - "enforce_basepath": false + "enforce_basepath": false, + "notify_service": "persistent_notification.create" }, "schema": { "username": "str", "password": "match(.+)", + "ssl": "bool", "certfile": "str", "keyfile": "str", - "ssl": "bool", "allowed_networks": ["str"], "banned_ips": ["str"], "banlimit": "int", "ignore_pattern": ["str"], "dirsfirst": "bool", "enforce_basepath": "bool", + "notify_service": "str", "sesame": "str?", + "sesame_totp_secret": "str?", + "loglevel": "str?", "verify_hostname": "str?" }, "image": "homeassistant/{arch}-addon-configurator" diff --git a/configurator/map.py b/configurator/map.py deleted file mode 100644 index 7446fc8..0000000 --- a/configurator/map.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Mapping hass.io options.json into configurator config.""" -import json -import os -from pathlib import Path -import sys - -hassio_options = Path("/data/options.json") - -# Read hass.io options -with hassio_options.open('r') as json_file: - options = json.loads(json_file.read()) - -configurator = { - 'BASEPATH': "/config", - 'ENFORCE_BASEPATH': options['enforce_basepath'], - 'HASS_API': "http://hassio/homeassistant/api/", - 'HASS_API_PASSWORD': os.environ.get('HASSIO_TOKEN', ''), - 'CREDENTIALS': - "{}:{}".format(options['username'], options['password']), - 'SSL_CERTIFICATE': - "ssl/{}".format(options['certfile']) if options['ssl'] else None, - 'SSL_KEY': - "ssl/{}".format(options['keyfile']) if options['ssl'] else None, - 'ALLOWED_NETWORKS': options['allowed_networks'], - 'BANNED_IPS': options['banned_ips'], - 'IGNORE_PATTERN': options['ignore_pattern'], - 'BANLIMIT': options['banlimit'], - 'DIRSFIRST': options['dirsfirst'], - 'SESAME': options.get('sesame'), - 'VERIFY_HOSTNAME': options.get('verify_hostname'), -} - -with Path(sys.argv[1]).open('w') as json_file: - json_file.write(json.dumps(configurator)) diff --git a/configurator/run.sh b/configurator/run.sh index d7a0515..6919d5a 100644 --- a/configurator/run.sh +++ b/configurator/run.sh @@ -1,8 +1,46 @@ #!/bin/bash -set -e +# shellcheck disable=SC2155 -# Map hassio value into hass-configurator options -python3 /map.py /tmp/configurator.json +CONFIG_PATH=/data/options.json + +export HC_BASEPATH=/config +export HC_HASS_API=http://hassio/homeassistant/api/ +export HC_HASS_API_PASSWORD=$HASSIO_TOKEN +export HC_GIT=true +export HC_VERIFY_HOSTNAME=false +export HC_IGNORE_SSL=false + +export HC_ENFORCE_BASEPATH=$(jq --raw-output '.enforce_basepath' $CONFIG_PATH) +export HC_USERNAME=$(jq --raw-output '.username' $CONFIG_PATH) +export HC_PASSWORD=$(jq --raw-output '.password' $CONFIG_PATH) +export HC_NOTIFY_SERVICE=$(jq --raw-output '.notify_service' $CONFIG_PATH) +export HC_ALLOWED_NETWORKS=$(jq --raw-output '.allowed_networks | join(",")' $CONFIG_PATH) +export HC_BANNED_IPS=$(jq --raw-output '.banned_ips | join(",")' $CONFIG_PATH) +export HC_BANLIMIT=$(jq --raw-output '.banlimit' $CONFIG_PATH) +export HC_IGNORE_PATTERN=$(jq --raw-output '.ignore_pattern | join(",")' $CONFIG_PATH) +export HC_DIRSFIRST=$(jq --raw-output '.dirsfirst' $CONFIG_PATH) +export HC_VERIFY_HOSTNAME=$(jq --raw-output '.verify_hostname // empty' $CONFIG_PATH) + +SSL=$(jq --raw-output '.ssl // false' $CONFIG_PATH) +if [ "$SSL" == "true" ]; then + export HC_SSL_CERTIFICATE=$(jq --raw-output '.certfile' $CONFIG_PATH) + export HC_SSL_KEY=$(jq --raw-output '.keyfile' $CONFIG_PATH) +fi + +LOGLEVEL=$(jq --raw-output '.loglevel // empty' $CONFIG_PATH) +if [ ! -z "$LOGLEVEL" ]; then + export HC_LOGLEVEL=$LOGLEVEL +fi + +SESAME=$(jq --raw-output '.sesame // empty' $CONFIG_PATH) +if [ ! -z "$SESAME" ]; then + export HC_SESAME=$SESAME +fi + +SESAME_TOTP_SECRET=$(jq --raw-output '.sesame_totp_secret // empty' $CONFIG_PATH) +if [ ! -z "$SESAME_TOTP_SECRET" ]; then + export HC_SESAME_TOTP_SECRET=$SESAME_TOTP_SECRET +fi # Run configurator -exec python3 /configurator.py /tmp/configurator.json +exec python3 /configurator.py