Add support for pdnsd.
[openresolv] / named.in
index 04db23b30bc6d07398ff35568f2e3b571c6b709d..9d88910a7eed59080a999268cb03608983a07e71 100644 (file)
--- a/named.in
+++ b/named.in
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright 2007-2009 Roy Marples <roy@marples.name>
+# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
 # All rights reserved
 
 # named subscriber for resolvconf
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "${named_zones}" -o -z "${named_options}" ] && exit 0
-eval "$("${RESOLVCONF:-resolvconf}" -v)"
+[ -z "$named_zones" -a -z "$named_options" ] && exit 0
+[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
 
+: ${named_restart:=@RESTARTCMD named@}
 newoptions="# Generated by resolvconf\n"
-newzones="${newoptions}"
+newzones="$newoptions"
+
 forward=
-for n in ${NAMESERVERS}; do
-       case "${forward}" in
-       *"\n\t${n};"*);;
-       *) forward="${forward}\n\t${n};";;
+for n in $NAMESERVERS; do
+       case "$forward" in
+       *"\n\t$n;"*);;
+       *) forward="$forward\n\t$n;";;
        esac
 done
-if [ -n "${forward}" ]; then
-       newoptions="${newoptions}forward first;\nforwarders {${forward}\n};\n"
+if [ -n "$forward" ]; then
+       newoptions="${newoptions}forward first;\nforwarders {$forward\n};\n"
 fi
 
-for d in ${DOMAINS}; do
+for d in $DOMAINS; do
        newzones="${newzones}zone \"${d%%:*}\" {\n"
-       newzones="${newzones}\ttype forward;\n"
-       newzones="${newzones}\tforward first;\n\tforwarders {\n"
+       newzones="$newzones\ttype forward;\n"
+       newzones="$newzones\tforward first;\n\tforwarders {\n"
        ns="${d#*:}"
-       while [ -n "${ns}" ]; do
-               newzones="${newzones}\t\t${ns%%,*};\n"
-               [ "${ns}" = "${ns#*,}" ] && break
+       while [ -n "$ns" ]; do
+               newzones="$newzones\t\t${ns%%,*};\n"
+               [ "$ns" = "${ns#*,}" ] && break
                ns="${ns#*,}"
        done
-       newzones="${newzones}\t};\n};\n"
+       newzones="$newzones\t};\n};\n"
 done
 
 # No point in changing files or reloading bind if the end result has not
 # changed
 changed=false
-if [ ! -f "${named_options}" ] || \
-       [ "$(cat "${named_options}")" != "$(printf "${newoptions}")" ]
-then
-       printf "${newoptions}" > "${named_options}"
-       changed=true
+if [ -n "$named_options" ]; then
+       if [ ! -f "$named_options" ] || \
+               [ "$(cat "$named_options")" != "$(printf "$newoptions")" ]
+       then
+               printf "$newoptions" >"$named_options"
+               changed=true
+       fi
 fi
-if [ ! -f "${named_zones}" ] || \
-       [ "$(cat "${named_zones}")" != "$(printf "${newzones}")" ]
-then
-       printf "${newzones}" > "${named_zones}"
-       changed=true
+if [ -n "$named_zones" ]; then
+       if [ ! -f "$named_zones" ] || \
+               [ "$(cat "$named_zones")" != "$(printf "$newzones")" ]
+       then
+               printf "$newzones" >"$named_zones"
+               changed=true
+       fi
 fi
 
-${changed} && resolvconf -s named restart
-exit 0
+if $changed; then
+       eval $named_restart
+fi