Files
addons/dnsmasq/run.sh
Franck Nijhof fc839e76c7 dnsmasq: Refactor (#591)
* dnsmasq: Rewrite add-on onto Bashio

* dnsmasq: Removes debug statement from run.sh

* dnsmasq: Formats config.json

* dnsmasq: Adds README to add-on repository

* dnsmasq: Bumps version to 1.3, updates CHANGELOG
2019-06-02 13:34:59 +02:00

31 lines
798 B
Bash
Executable File

#!/usr/bin/env bashio
set -e
CONFIG="/etc/dnsmasq.conf"
bashio::log.info "Configuring dnsmasq..."
# Add default forward servers
for server in $(bashio::config 'defaults'); do
echo "server=${server}" >> "${CONFIG}"
done
# Create domain forwards
for forward in $(bashio::config 'forwards|keys'); do
DOMAIN=$(bashio::config "forwards[${forward}].domain")
SERVER=$(bashio::config "forwards[${forward}].server")
echo "server=/${DOMAIN}/${SERVER}" >> "${CONFIG}"
done
# Create static hosts
for host in $(bashio::config 'hosts|keys'); do
HOST=$(bashio::config "hosts[${host}].host")
IP=$(bashio::config "hosts[${host}].ip")
echo "address=/${HOST}/${IP}" >> "${CONFIG}"
done
# run dnsmasq
bashio::log.info "Starting dnsmasq..."
exec dnsmasq -C "${CONFIG}" -z < /dev/null