SIGHUP can restart unbound nicely. If that fails, restat the service.
authorRoy Marples <roy@marples.name>
Fri, 4 Dec 2009 10:13:09 +0000 (10:13 +0000)
committerRoy Marples <roy@marples.name>
Fri, 4 Dec 2009 10:13:09 +0000 (10:13 +0000)
unbound.in

index 2f44dea252aa502e818d0b68af3b810255931bbf..6d8547a8877de229ad622f1e5d9e5d893c987a52 100644 (file)
@@ -38,7 +38,7 @@ newconf="# Generated by resolvconf\n"
 for d in $DOMAINS; do
        dn="${d%%:*}"
        ns="${d#*:}"
 for d in $DOMAINS; do
        dn="${d%%:*}"
        ns="${d#*:}"
-       newconf="\n${newconf}forward-zone:\n\tname: \"$dn\"\n"
+       newconf="${newconf}\nforward-zone:\n\tname: \"$dn\"\n"
        while [ -n "$ns" ]; do
                newconf="${newconf}\tforward-addr: ${ns%%,*}\n"
                [ "$ns" = "${ns#*,}" ] && break
        while [ -n "$ns" ]; do
                newconf="${newconf}\tforward-addr: ${ns%%,*}\n"
                [ "$ns" = "${ns#*,}" ] && break
@@ -47,7 +47,7 @@ for d in $DOMAINS; do
 done
 
 if [ -n "$NAMESERVERS" ]; then
 done
 
 if [ -n "$NAMESERVERS" ]; then
-       newconf="\n${newconf}forward-zone:\n\tname: \".\"\n"
+       newconf="${newconf}\nforward-zone:\n\tname: \".\"\n"
        for n in $NAMESERVERS; do
                newconf="${newconf}\tforward-addr: $n\n"
        done
        for n in $NAMESERVERS; do
                newconf="${newconf}\tforward-addr: $n\n"
        done
@@ -57,11 +57,12 @@ if [ ! -f "$unbound_conf" ] || \
        [ "$(cat "$unbound_conf")" != "$(printf "$newconf")" ]
 then
        printf "$newconf" >"$unbound_conf"
        [ "$(cat "$unbound_conf")" != "$(printf "$newconf")" ]
 then
        printf "$newconf" >"$unbound_conf"
-       #if [ -s "$unbound_pid" ] && \
-       #       kill -0 $(cat "$unbound_pid") 2>/dev/null
-       #then
-       #       unbound-control reload
-       #else
+       # 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
+               fi
+       else
                eval $unbound_restart
                eval $unbound_restart
-       #fi
+       fi
 fi
 fi