From c56ed215fbbf99d2f2c85715f79c38a61c078c8a Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 5 Dec 2021 19:15:07 +0100 Subject: [PATCH] Create 90-dns_set.sh --- webtop/root/etc/cont-init.d/90-dns_set.sh | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 webtop/root/etc/cont-init.d/90-dns_set.sh diff --git a/webtop/root/etc/cont-init.d/90-dns_set.sh b/webtop/root/etc/cont-init.d/90-dns_set.sh new file mode 100644 index 000000000..dd80ef417 --- /dev/null +++ b/webtop/root/etc/cont-init.d/90-dns_set.sh @@ -0,0 +1,28 @@ +#!/usr/bin/with-contenv bashio + +############### +# DNS SETTING # +############### + +# Avoid usage of local dns such as adguard home or pihole\n" + +if bashio::config.has_value 'DNS_server'; then + # Define variables + DNSSERVER=$(bashio::config 'DNS_server') + DNS="" + DNSLIST="" + + # Get DNS servers + for server in ${DNSSERVER//,/ } # Separate comma separated values + do + DNS="${DNS}nameserver $server\n" + DNSLIST="$server $DNSLIST" + done + + # Write resolv.conf + printf "${DNS}" > /etc/resolv.conf + chmod 644 /etc/resolv.conf + bashio::log.info "DNS SERVERS set to $DNSLIST" +else + bashio::log.info "DNS Servers option empty. Using default router (or HA) dns servers." +fi