Allow interfaces to be Deprecated
[openresolv] / unbound.in
index 5752e6f2c41230e9e8ae8f8d7d044044b7516dd9..bdb7766573cdb09e2f6a8df95a1f369c057e331b 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2009-2014 Roy Marples
+# Copyright (c) 2009-2020 Roy Marples
 # All rights reserved
 
 # unbound subscriber for resolvconf
@@ -37,7 +37,6 @@ NL="
 
 : ${unbound_pid:=/var/run/unbound.pid}
 : ${unbound_service:=unbound}
-: ${unbound_restart:=@RESTARTCMD ${unbound_service}@}
 newconf="# Generated by resolvconf$NL"
 
 for d in $DOMAINS; do
@@ -45,7 +44,8 @@ for d in $DOMAINS; do
        ns="${d#*:}"
        case "$unbound_insecure" in
        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
-               newconf="$newconf${NL}domain-insecure: \"$dn\""
+               newconf="$newconf${NL}server:$NL"
+               newconf="$newconf       domain-insecure: \"$dn\"$NL"
                ;;
        esac
        newconf="$newconf${NL}forward-zone:$NL  name: \"$dn\"$NL"
@@ -70,6 +70,18 @@ else
        @SBINDIR@/resolvconf -D "$unbound_conf"
 fi
 
+restart_unbound()
+{
+       if [ -n "$unbound_restart" ]; then
+               eval $unbound_restart
+       elif [ -n "$RESTARTCMD" ]; then
+               set -- ${unbound_service}
+               eval "$RESTARTCMD"
+       else
+               @SBINDIR@/resolvconf -r ${unbound_service}
+       fi
+}
+
 if [ ! -f "$unbound_conf" ] || \
        [ "$(cat "$unbound_conf")" != "$(printf %s "$newconf")" ]
 then
@@ -77,9 +89,9 @@ then
        # If we can't sent a HUP then force a restart
        if [ -s "$unbound_pid" ]; then
                if ! kill -HUP $(cat "$unbound_pid") 2>/dev/null; then
-                       eval $unbound_restart
+                       restart_unbound
                fi
        else
-               eval $unbound_restart
+               restart_unbound
        fi
 fi