From 78183ccdac33631ace6d0024a1954816e79bc0b6 Mon Sep 17 00:00:00 2001 From: Timmo Date: Fri, 29 Mar 2019 22:14:19 +0000 Subject: [PATCH] :arrow_up: :hammer: Upgrade to Home Panel v0.8.0 --- README.md | 11 +- home-panel/Dockerfile | 21 ++- home-panel/config.json | 6 +- .../rootfs/etc/cont-init.d/10-requirements.sh | 7 - .../rootfs/etc/cont-init.d/20-config.sh | 14 -- home-panel/rootfs/etc/home-panel/default.json | 37 +++++ .../home-panel/home-panel-config.default.json | 149 ------------------ home-panel/rootfs/etc/services.d/api/run | 6 +- 8 files changed, 54 insertions(+), 197 deletions(-) delete mode 100644 home-panel/rootfs/etc/cont-init.d/20-config.sh create mode 100644 home-panel/rootfs/etc/home-panel/default.json delete mode 100644 home-panel/rootfs/etc/home-panel/home-panel-config.default.json diff --git a/README.md b/README.md index 1c04f10..ec240eb 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,7 @@ Example add-on configuration: "log_level": "info", "ssl": true, "certfile": "fullchain.pem", - "keyfile": "privkey.pem", - "config_file": "home-panel-config.json" + "keyfile": "privkey.pem" } ``` @@ -112,14 +111,6 @@ The private key file to use for SSL. **Note**: _The file MUST be stored in `/ssl/`, which is default for Hass.io_ -### Option: `config_file` - -The location of your config.json in `/config/`. More information on - configuration [here][config]. You can edit the config file while the - addon is running. Just refresh the app's page. - -**Note**: _The file MUST be stored in `/config/`._ - ## Changelog & Releases This repository keeps a change log using [GitHub's releases][releases] diff --git a/home-panel/Dockerfile b/home-panel/Dockerfile index f3cc3fe..6d220f2 100644 --- a/home-panel/Dockerfile +++ b/home-panel/Dockerfile @@ -2,25 +2,33 @@ ARG BUILD_FROM=hassioaddons/base:3.0.1 # hadolint ignore=DL3006 FROM ${BUILD_FROM} +# Copy root filesystem +COPY rootfs / + # Install packages # hadolint ignore=DL3003 RUN \ apk add --no-cache --virtual .build-dependencies \ - yarn=1.12.3-r0 \ git=2.20.1-r0 \ + openssl=1.1.1b-r1 \ + yarn=1.12.3-r0 \ \ && apk add --no-cache \ nginx=1.14.2-r0 \ nodejs-current=11.3.0-r0 \ \ - && git clone --branch "v0.5.0" --depth=1 \ - "https://github.com/timmo001/home-panel-api.git" /opt/api \ - \ && curl -J -L -o /tmp/panel.zip \ - "https://github.com/timmo001/home-panel/releases/download/v0.7.0/home-panel-built.zip" \ + "https://github.com/timmo001/home-panel/releases/download/v0.8.0/home-panel-built.zip" \ && unzip -d /tmp /tmp/panel.zip \ && mv /tmp/build /opt/panel \ \ + && git clone --branch "v0.8.0" --depth=1 \ + "https://github.com/timmo001/home-panel.git" /tmp/panel \ + && mv /tmp/panel/api /opt/api \ + \ + && mv /etc/home-panel/default.json /opt/api/config \ + && sed -i "s/API_AUTH_SECRET/$(openssl rand -base64 32)/g" /opt/api/config/default.json \ + \ && cd /opt/api \ && yarn install \ \ @@ -28,9 +36,6 @@ RUN \ && apk del --purge .build-dependencies \ && rm -fr /tmp/* -# Copy root filesystem -COPY rootfs / - # Build arguments ARG BUILD_ARCH ARG BUILD_DATE diff --git a/home-panel/config.json b/home-panel/config.json index 7110851..d3b4f76 100644 --- a/home-panel/config.json +++ b/home-panel/config.json @@ -30,15 +30,13 @@ "log_level": "info", "ssl": true, "certfile": "fullchain.pem", - "keyfile": "privkey.pem", - "config_file": "home-panel-config.json" + "keyfile": "privkey.pem" }, "schema": { "log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)", "ssl": "bool", "certfile": "str", - "keyfile": "str", - "config_file": "str" + "keyfile": "str" }, "environment": { "LOG_FORMAT": "{LEVEL}: {MESSAGE}" diff --git a/home-panel/rootfs/etc/cont-init.d/10-requirements.sh b/home-panel/rootfs/etc/cont-init.d/10-requirements.sh index 82f1c68..0455f33 100644 --- a/home-panel/rootfs/etc/cont-init.d/10-requirements.sh +++ b/home-panel/rootfs/etc/cont-init.d/10-requirements.sh @@ -5,10 +5,3 @@ # ============================================================================== # Check SSL settings bashio::config.require.ssl - -if ! bashio::config.has_value 'config_file'; then - bashio::log.fatal '' - bashio::log.fatal 'No configuration filename was specified.' - bashio::log.fatal 'This is required for the add-on to function.' - bashio::exit.nok -fi diff --git a/home-panel/rootfs/etc/cont-init.d/20-config.sh b/home-panel/rootfs/etc/cont-init.d/20-config.sh deleted file mode 100644 index ec5bfcd..0000000 --- a/home-panel/rootfs/etc/cont-init.d/20-config.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Community Hass.io Add-ons: Home Panel -# This copies the configs to their respective locations -# ============================================================================== -declare config_file - -config_file="/config/$(bashio::config 'config_file')" - -if ! bashio::fs.file_exists "${config_file}"; then - bashio::log.info "Config file does not exist. Creating.." - cp /etc/home-panel/home-panel-config.default.json "${config_file}" - bashio::log.info "Created. You should now edit this file at '${config_file}'" -fi diff --git a/home-panel/rootfs/etc/home-panel/default.json b/home-panel/rootfs/etc/home-panel/default.json new file mode 100644 index 0000000..743510e --- /dev/null +++ b/home-panel/rootfs/etc/home-panel/default.json @@ -0,0 +1,37 @@ +{ + "host": "localhost", + "port": 3234, + "public": "../public/", + "paginate": { + "default": 10, + "max": 50 + }, + "authentication": { + "secret": "API_AUTH_SECRET", + "strategies": ["jwt", "local"], + "path": "/authentication", + "service": "users", + "jwt": { + "header": { + "typ": "access" + }, + "audience": "https://timmo.dev/home-panel", + "subject": "anonymous", + "issuer": "feathers", + "algorithm": "HS256", + "expiresIn": "1d" + }, + "local": { + "entity": "user", + "usernameField": "username", + "passwordField": "password" + }, + "cookie": { + "enabled": true, + "name": "feathers-jwt", + "httpOnly": false, + "secure": false + } + }, + "nedb": "/data" + } diff --git a/home-panel/rootfs/etc/home-panel/home-panel-config.default.json b/home-panel/rootfs/etc/home-panel/home-panel-config.default.json deleted file mode 100644 index 9c23c61..0000000 --- a/home-panel/rootfs/etc/home-panel/home-panel-config.default.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "theme": { - "custom": [ - { - "name": "Midnight", - "base": "dark", - "overrides": { - "primary": "pink", - "backgrounds": { - "main": "#383c45", - "default": "#383c45", - "card": { - "on": "pink[600]", - "off": "#434954", - "disabled": "#7f848e", - "alarm": { - "home": "pink[600]", - "away": "pink[600]" - } - } - }, - "text": { - "light": "grey[50]", - "main": "grey[100]" - }, - "secondary": "pink" - } - }, - { - "name": "Forest", - "base": "light", - "overrides": { - "backgrounds": { - "main": "url(https://images.pexels.com/photos/4827/nature-forest-trees-fog.jpeg) no-repeat fixed center", - "card": { - "on": "lightGreen[700]", - "off": "rgba(160, 200, 160, 0.6)", - "alarm": { - "home": "lightGreen[700]", - "away": "lightGreen[700]" - } - } - } - } - } - ] - }, - "header": { - "left_outdoor_weather": { - "dark_sky_icon": "sensor.dark_sky_icon", - "condition": "sensor.pws_weather", - "data": [ - { - "entity_id": "sensor.pws_temp_c", - "unit_of_measurement": "°C" - }, - { - "entity_id": "sensor.pws_relative_humidity", - "unit_of_measurement": "%" - } - ] - }, - "right_indoor": [ - { - "label": "Living Room", - "data": [ - { - "entity_id": "sensor.dht22_01_temperature", - "unit_of_measurement": "°C" - }, - { - "entity_id": "sensor.dht22_01_humidity", - "unit_of_measurement": "%" - } - ] - } - ] - }, - "pages": [ - { - "name": "Home", - "icon": "home" - }, - { - "name": "Weather", - "icon": "weather-partlycloudy" - } - ], - "items": [ - { - "name": "Living Room", - "cards": [ - { - "entity_id": "light.tv_light", - "name": "TV", - "icon": "lightbulb" - } - ], - "page": 1, - "width": 2 - }, - { - "name": "Dining Room", - "cards": [ - { - "entity_id": "light.table_light", - "icon": "ceiling-light", - "name": "Table Light" - } - ], - "page": 1, - "width": 2 - }, - { - "name": "Weather", - "page": 2, - "width": 8, - "cards": [ - { - "type": "hass", - "name": "", - "entity_id": "weather.dark_sky", - "icon": "", - "width": 3, - "height": 2, - "size": { - "name": "", - "state": "", - "icon": "" - } - }, - { - "type": "iframe", - "name": "", - "entity_id": "", - "icon": "", - "width": 4, - "height": 4, - "size": { - "name": "", - "state": "", - "icon": "" - }, - "url": "https://embed.windy.com/embed2.html" - } - ] - } - ] -} diff --git a/home-panel/rootfs/etc/services.d/api/run b/home-panel/rootfs/etc/services.d/api/run index ca0bba6..368ed5e 100644 --- a/home-panel/rootfs/etc/services.d/api/run +++ b/home-panel/rootfs/etc/services.d/api/run @@ -9,8 +9,6 @@ cd /opt/api \ || bashio::exit.nok "Could not change into API directory" LOG_LEVEL=$(bashio::config 'log_level') -DB_PATH=/config/home-panel.db -CONFIG_PATH=/config/$(bashio::config 'config_file') if bashio::config.true 'ssl'; then SSL_PATH_CERT="/ssl/$(bashio::config 'certfile')" @@ -18,9 +16,7 @@ if bashio::config.true 'ssl'; then fi export LOG_LEVEL -export DB_PATH -export CONFIG_PATH export SSL_PATH_CERT export SSL_PATH_KEY -exec node index.js +exec node src/