]> git.ipfire.org Git - people/ummeegge/ipfire-2.x.git/blobdiff - src/initscripts/system/unbound
unbound: Modified initscript to test custom forwarder.
[people/ummeegge/ipfire-2.x.git] / src / initscripts / system / unbound
index cc46c33c9425cc85d95b1d7412a9db3e146fea4b..b98a797038c0e6f2532fb8610f168f06db2f3e61 100644 (file)
@@ -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