From: erik.kapfer Date: Sat, 24 Nov 2018 13:08:57 +0000 (+0100) Subject: unbound: Modified initscript to test custom forwarder. X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Funbound_forwarder;p=people%2Fummeegge%2Fipfire-2.x.git unbound: Modified initscript to test custom forwarder. Since unbound do not correctly work with USE_FORWRDER=0, the initscript has been modified to find the problem section. Initscript works now with DOT custom_forwarders configured via local.d and unbound sysconfig file without dropping into "local recursor" mode. custom_forwarder survives also reboots. --- diff --git a/src/initscripts/system/unbound b/src/initscripts/system/unbound index cc46c33c94..b98a797038 100644 --- a/src/initscripts/system/unbound +++ b/src/initscripts/system/unbound @@ -22,7 +22,7 @@ LOCAL_TTL=60 EDNS_DEFAULT_BUFFER_SIZE=4096 # Load optional configuration -[ -e "/etc/sysconfig/unbound" ] && . /etc/sysconfig/unbound +#[ -e "/etc/sysconfig/unbound" ] && . /etc/sysconfig/unbound function cidr() { local cidr nbits IFS; @@ -485,6 +485,27 @@ fix_time_if_dns_fail() { fi } +use_custom_forwarders() { + # Check if custom forwarders are presant via sysconfig and local.d + if grep -q "USE_FORWARDERS=0" /etc/sysconfig/unbound >/dev/null 2>&1; then + if grep -Rq "forward-zone:" /etc/unbound/local.d/* >/dev/null 2>&1; then + echo "Use Custom Forwarders in local.d" + write_tuning_conf + write_forward_conf + if ! pgrep unbound >/dev/null; then + boot_mesg "Starting Unbound DNS Proxy..." + loadproc /usr/sbin/unbound || exit $? + fi + #update_forwarders + unbound-control start >/dev/null + update_hosts + fix_time_if_dns_fail + unbound-control list_forwards + exit 0 + fi + fi +} + case "$1" in start) # Print a nicer messagen when unbound is already running @@ -500,6 +521,9 @@ case "$1" in unbound-control-setup -d /etc/unbound &>/dev/null fi + # Check if custom forwarders are presant + use_custom_forwarders + # Update configuration files write_tuning_conf write_forward_conf