From 612e66d515fbc5c1a2625f9fe6de23b9ba0bcfc5 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 3 May 2021 06:40:02 +0200 Subject: [PATCH] Allow code for multiple dns in options --- .../rootfs/etc/cont-init.d/90-dns_set.sh | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/qbittorrent/rootfs/etc/cont-init.d/90-dns_set.sh b/qbittorrent/rootfs/etc/cont-init.d/90-dns_set.sh index 281619828..22ebda395 100644 --- a/qbittorrent/rootfs/etc/cont-init.d/90-dns_set.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/90-dns_set.sh @@ -4,9 +4,23 @@ # DNS SETTING # ############### -DNS="# Avoid usage of local dns such as adguard home or pihole\n" -DNS="${DNS}nameserver 8.8.8.8\n" -DNS="${DNS}nameserver 1.1.1.1" -printf "${DNS}" > /etc/resolv.conf -chmod 644 /etc/resolv.conf +# 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 DNSSERVER in ${DNS_server//,/ } # Separate comma separated values + do + DNS="${DNS}nameserver $DNSSERVER\n" + DNSLIST="$DNSSERVER $DNSLIST" + done + + # Write resolv.conf + printf "${DNS}" > /etc/resolv.conf + chmod 644 /etc/resolv.conf + bashio::log.info 'DNS SERVERS set to $DNSLIST' +fi