Move init system detection from configure to resolvconf.
[openresolv] / unbound.in
index be70a9d89c8996f2ebd1521a0fe0ccb43c6691b6..a9e978ae139651f1693f39f5520bee224e78b924 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2009-2011 Roy Marples
+# Copyright (c) 2009-2014 Roy Marples
 # All rights reserved
 
 # unbound subscriber for resolvconf
@@ -37,15 +37,17 @@ 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
        dn="${d%%:*}"
        ns="${d#*:}"
-       if [ -n "$unbound_insecure" ]; then
-               newconf="$newconf${NL}domain-insecure: \"$dn\""
-       fi
+       case "$unbound_insecure" in
+       [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+               newconf="$newconf${NL}server:$NL"
+               newconf="$newconf       domain-insecure: \"$dn\"$NL"
+               ;;
+       esac
        newconf="$newconf${NL}forward-zone:$NL  name: \"$dn\"$NL"
        while [ -n "$ns" ]; do
                newconf="$newconf       forward-addr: ${ns%%,*}$NL"
@@ -68,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
@@ -75,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