From 5d66366c0a62006a40a464b0f9e5647ffce16b5f Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 20 Jun 2017 15:20:57 +0200 Subject: [PATCH] Fix dnsmasq for resinos (#123) Fix dnsmasq for resinos --- dnsmasq/config.json | 13 ++++++------- dnsmasq/run.sh | 8 +++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dnsmasq/config.json b/dnsmasq/config.json index 4aa5cd1..c0b66c8 100644 --- a/dnsmasq/config.json +++ b/dnsmasq/config.json @@ -1,19 +1,17 @@ { "name": "Dnsmasq server", - "version": "0.1", + "version": "0.2", "slug": "dnsmasq", "description": "A simple dns server with benefits", "url": "https://home-assistant.io/addons/dnsmasq/", "startup": "before", "boot": "auto", - "ports": { - "53/udp": 53, - "53/tcp": 53 - }, + "host_network": true, "options": { "defaults": ["8.8.8.8", "8.8.4.4"], "forwards": [], - "hosts": [] + "hosts": [], + "interface": "eth0" }, "schema": { "defaults": ["str"], @@ -28,7 +26,8 @@ "host": "str", "ip": "str" } - ] + ], + "interface": "str" }, "image": "homeassistant/{arch}-addon-dnsmasq" } diff --git a/dnsmasq/run.sh b/dnsmasq/run.sh index aea908b..f91b909 100644 --- a/dnsmasq/run.sh +++ b/dnsmasq/run.sh @@ -6,6 +6,12 @@ CONFIG_PATH=/data/options.json DEFAULTS=$(jq --raw-output '.defaults[]' $CONFIG_PATH) FORWARDS=$(jq --raw-output '.forwards | length' $CONFIG_PATH) HOSTS=$(jq --raw-output '.hosts | length' $CONFIG_PATH) +INTERFACE=$(jq --raw-output '.interface' $CONFIG_PATH) + +# Bind to interface +if [ -z "$INTERFACE" ]; then + echo "interface=$INTERFACE" >> /etc/dnsmasq.conf +fi # Add default forward servers for line in $DEFAULTS; do @@ -29,4 +35,4 @@ for (( i=0; i < "$HOSTS"; i++ )); do done # run dnsmasq -exec dnsmasq -C /etc/dnsmasq.conf < /dev/null +exec dnsmasq -C /etc/dnsmasq.conf -z < /dev/null