From 4072708ca6ac43b5cece0fcd15253696c301f014 Mon Sep 17 00:00:00 2001 From: Christian Lasarczyk Date: Wed, 16 Aug 2017 12:02:02 +0200 Subject: [PATCH] Real example on addon configuration (#3189) Inspired be mosquitto's `run.sh`. Hoping to ease the start for newbies like me. --- source/developers/hassio/addon_config.markdown | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/developers/hassio/addon_config.markdown b/source/developers/hassio/addon_config.markdown index 5de31e29c47..639f579350e 100644 --- a/source/developers/hassio/addon_config.markdown +++ b/source/developers/hassio/addon_config.markdown @@ -26,12 +26,20 @@ As with every Docker container, you will need a script to run when the container When developing your script: - `/data` is a volume for persistent storage. - - `/data/options.json` contains the user configuration. You can use `jq` inside your shell script to parse this data. + - `/data/options.json` contains the user configuration. You can use `jq` inside your shell script to parse this data. However you might have to install `jq` as a separate package in your container (see `Dockerfile` below). ```bash -echo '{ "target": "beer" }' | jq -r ".target" +CONFIG_PATH=/data/options.json + +TARGET=$(jq --raw-output ".target" $CONFIG_PATH) ``` +So if your `options`contain +```json +{ "target": "beer" } +``` +then there will be a variable `TARGET`containing `beer` in the environment of your bash file afterwards. + ## {% linkable_title Add-on Docker file %} All add-ons are based on Alpine Linux 3.6. Hass.io will automatically substitute the right base image based on the machine architecture. Add `tzdata` if you need run in correct timezone, but that is already add in our base images.