openresolv no longer applies any semantics to resolv.conf for
[openresolv] / named.in
index 64eb049196d40e9576cd1b59c5182d241fd290ae..0a3f8f197ca6531df1453e2fdf5f4f7583c9afd0 100755 (executable)
--- a/named.in
+++ b/named.in
@@ -48,8 +48,7 @@
 #echo "nameserver 127.0.0.1" > /usr/local/etc/resolvconf/resolv.conf.d/base
 
 # Load our variables from resolvconf
-VARS="$(resolvconf -v)"
-eval "${VARS}"
+eval "$(resolvconf -v)"
 
 # If our dir doesn't exist then don't do anything
 NAMEDB=/etc/namedb
@@ -59,44 +58,30 @@ NAMEDB=/etc/namedb
 NAMEDOPTIONS="${NAMEDB}/resolvconf-options.conf"
 NAMEDZONES="${NAMEDB}/resolvconf-zones.conf"
 
-# If we only have domain information then put it in search too
-[ -z "${NEWSEARCH}" -a -z "${NEWNS}" ] && NEWSEARCH="${NEWDOMAIN}"
-
 NEWOPTIONS="# Generated by resolvconf\n"
 NEWZONES="${NEWOPTIONS}"
 FORWARD=
-for N in ${NEWSEARCH}; do
-       case "${FORWARD}" in
-               *"\n\t${N#*,};"*);;
-               *) FORWARD="${FORWARD}\n\t${N#*,};";;
-       esac
-done
-for N in ${NEWNS}; do
+for N in ${NAMESERVERS}; do
        case "${FORWARD}" in
                *"\n\t${N};"*);;
                *) FORWARD="${FORWARD}\n\t${N};";;
        esac
 done
 if [ -n "${FORWARD}" ]; then
-       NEWOPTIONS="${NEWOPTIONS}\nforward first;\nforwarders {${FORWARD}\n};\n"
+       NEWOPTIONS="${NEWOPTIONS}forward first;\nforwarders {${FORWARD}\n};\n"
 fi
 
-LASTDN=
-ZONES=
-for DN in $(printf "%s\n" ${NEWDOMAIN} | sort -u); do
-       case "${LASTDN}" in
-               "${DN%,*}");;
-               *)
-               [ -n "${ZONES}" ] && ZONES="${NEWZONES}\n\t};\n};\n"
-               ZONES="${ZONES}\nzone \"${DN%,*}\" {\n"
-               ZONES="${ZONES}\ttype forward;\n"
-               ZONES="${ZONES}\tforward first;\n"
-               ZONES="${ZONES}\tforwarders {"
-               ;;
-       esac
-       ZONES="${ZONES}\n\t\t${DN#*,};"
+for D in ${DOMAINS}; do
+       NEWZONES="${NEWZONES}zone \"${D%%:*}\" {\n"
+       NEWZONES="${NEWZONES}\ttype forward;\n\tforward first;\n\tforwarders {\n"
+       NS="${D#*:}"
+       while [ -n "${NS}" ]; do
+               NEWZONES="${NEWZONES}\t\t${NS%%,*};\n"
+               [ "${NS}" = "${NS#*,}" ] && break
+               NS="${NS#*,}"
+       done
+       NEWZONES="${NEWZONES}\t};\n};\n"
 done
-[ -n "${ZONES}" ] && NEWZONES="${NEWZONES}${ZONES}\n\t};\n};\n"
 
 # No point in changing files or reloading bind if the end result has not
 # changed