Real example on addon configuration (#3189)

Inspired be mosquitto's `run.sh`. Hoping to ease the start for newbies like me.
This commit is contained in:
Christian Lasarczyk 2017-08-16 12:02:02 +02:00 committed by Fabian Affolter
parent 2ae1440208
commit 4072708ca6

View File

@ -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.