From 052974a75002fca515100efca182916f159ba649 Mon Sep 17 00:00:00 2001 From: Paul Sinclair Date: Sun, 28 Jul 2019 09:51:31 -0400 Subject: [PATCH] :ok_hand: Change SSL config to boolean Also make config optional --- README.md | 9 +++++---- glances/config.json | 5 ++--- glances/rootfs/etc/cont-init.d/glances.sh | 8 +++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 61c3b7c..db0d1b3 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Example add-on configuration: "database": "glances", "prefix": "localhost", "interval": 60, - "protocol": "http" + "ssl": false } } ``` @@ -174,10 +174,11 @@ The hostname to append for exported data. Defines the interval (in seconds) on how often Glances exports data to InfluxDB. -#### Option `influxdb`: `protocol` +#### Option `influxdb`: `ssl` -Use `http` or `https` to connect to InfluxDB. Set to `http` if using the -Community InfluxDB add-on +Adding this option will allow SSL to be used on the InfluxDB connection. If not +set will default to `false` which is the required setting for the Community +InfluxDB add-on. ## Adding Glances as a sensor into Home Assistant diff --git a/glances/config.json b/glances/config.json index 00e61c3..bf29883 100755 --- a/glances/config.json +++ b/glances/config.json @@ -53,8 +53,7 @@ "password": "", "database": "glances", "prefix": "localhost", - "interval": 60, - "protocol": "http" + "interval": 60 } }, "schema": { @@ -73,7 +72,7 @@ "database": "str", "prefix": "str", "interval": "int", - "protocol": "match(^(http|https)$)" + "ssl": "bool?" }, "leave_front_door_open": "bool?" }, diff --git a/glances/rootfs/etc/cont-init.d/glances.sh b/glances/rootfs/etc/cont-init.d/glances.sh index de798de..795eb87 100644 --- a/glances/rootfs/etc/cont-init.d/glances.sh +++ b/glances/rootfs/etc/cont-init.d/glances.sh @@ -3,6 +3,7 @@ # Community Hass.io Add-ons: Glances # Configures Glances # ============================================================================== +declare protocol bashio::require.unprotected # Ensure the configuration exists @@ -18,6 +19,11 @@ fi # Export Glances data to InfluxDB if bashio::config.true 'influxdb.enabled'; then + if bashio::config.true 'influxdb.ssl'; then + protocol='https' + else + protocol='http' + fi # Modify the configuration { echo "[influxdb]" @@ -27,6 +33,6 @@ if bashio::config.true 'influxdb.enabled'; then echo "password=$(bashio::config 'influxdb.password')" echo "db=$(bashio::config 'influxdb.database')" echo "prefix=$(bashio::config 'influxdb.prefix')" - echo "protocol=$(bashio::config 'influxdb.protocol')" + echo "protocol=${protocol}" } >> /etc/glances.conf fi