mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 17:27:19 +00:00
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:
parent
2ae1440208
commit
4072708ca6
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user