.. and of course I send in the patch backwards, sorry.  here's the right
way.




On Wed, Feb 26, 2014 at 1:03 PM, Matt Gleeson <m...@gleeson.org> wrote:

> I just ran into this problem and this patch seems to work for me.  I just
> tried to update Thomas's script from the old resolvconf release.
>
>
>
>
diff --git a/debian/bind9.dirs b/debian/bind9.dirs
index 01abd6d..5ccd399 100644
--- a/debian/bind9.dirs
+++ b/debian/bind9.dirs
@@ -10,3 +10,4 @@ etc/ppp/ip-up.d
 etc/ppp/ip-down.d
 etc/network/if-up.d
 etc/network/if-down.d
+etc/resolvconf/update.d
diff --git a/debian/resolvconf-update-bind9 b/debian/resolvconf-update-bind9
new file mode 100644
index 0000000..ad5ce4a
--- /dev/null
+++ b/debian/resolvconf-update-bind9
@@ -0,0 +1,93 @@
+#!/bin/bash
+# Need bash because we use ${foo//bar/baz}
+#
+# Example script illustrating how to write a dynamic BIND named
+# options file containing an up-to-date fowarders list.
+#
+# To use the dynamically generated file, include it from
+# named.conf.options like:
+#
+# options {
+# 	directory "/var/cache/bind";
+#       ...
+#       include "/var/run/named/named.options";
+#       ...
+# };
+# 
+# Assumption: On entry, PWD contains the resolv.conf-type files.
+#
+# Written by Thomas Hood <jdth...@gmail.com>
+# Updated for bind9 by Matt Gleeson <m...@gleeson.org>
+#
+# Licensed under the GNU GPL.  See /usr/share/doc/resolvconf/copyright.
+
+set -e
+PATH=/sbin:/bin
+
+[ -x /usr/sbin/named ] || exit 0
+[ -x /lib/resolvconf/list-records ] || exit 0
+[ -f /etc/bind/named.conf.options ] || exit 0
+
+# Defaults
+NAMED_RUN_DIR=/var/run/named
+
+# Defaults overrides
+[ -r /etc/default/resolvconf ] && . /etc/default/resolvconf
+
+[ "$NAMED_RUN_DIR" ] || exit 0
+[ -d "$NAMED_RUN_DIR" ] || mkdir --parents --mode=0755 "$NAMED_RUN_DIR"
+
+DYNAMIC_OPTS_FILE=named.options
+
+# Stores arguments (minus duplicates) in RSLT, separated by spaces
+# Doesn't work properly if an argument itself contains whitespace
+uniquify()
+{
+	RSLT=""
+	while [ "$1" ] ; do
+		for E in $RSLT ; do
+			[ "$1" = "$E" ] && { shift ; continue 2 ; }
+		done
+		RSLT="${RSLT:+$RSLT }$1"
+		shift
+	done
+}
+
+# Get list of records, excluding all those for the loopback interface
+echo "DEBUG: running list-records in $PWD: $(ls .)"
+RSLVCNFFILES="$(/lib/resolvconf/list-records | sed -e '/^lo$/d' -e '/^lo[.]/d')"
+ 
+### Compile semicolon-separated list nameservers ###
+NMSRVRS=""
+if [ "$RSLVCNFFILES" ] ; then
+	uniquify $(sed -n -e 's/^[[:space:]]*nameserver[[:space:]]\+//p' $RSLVCNFFILES)
+	[ "$RSLT" ] && NMSRVRS="${RSLT// /; }; "
+fi
+
+# N.B.: After changing directory we no longer have access to the resolv.conf-type files
+cd "$NAMED_RUN_DIR"
+
+TMP_FILE="${DYNAMIC_OPTS_FILE}_new.$$"
+clean_up() { rm -f "${NAMED_RUN_DIR}/$TMP_FILE" ; }
+trap clean_up EXIT
+rm -f "$TMP_FILE"
+
+echo "// named.conf fragment automatically generated by $0" > "$TMP_FILE"
+echo "// DO NOT EDIT THIS FILE.  Instead edit /etc/bind/named.conf.options ." >> "$TMP_FILE"
+if [ ! -z "$NMSRVRS" ]; then
+        echo "forwarders {" >> "$TMP_FILE"
+        echo "    ${NMSRVRS}" >> "$TMP_FILE"
+        echo "};" >> "$TMP_FILE"
+fi
+
+chown root:bind "$TMP_FILE"
+
+# Reload named unless we know its options haven't changed
+if [ -x /usr/bin/diff ] && [ -f "$DYNAMIC_OPTS_FILE" ] && /usr/bin/diff -q "$DYNAMIC_OPTS_FILE" "$TMP_FILE" > /dev/null ; then
+	# No change
+	rm -f "$TMP_FILE"
+else
+	mv -f "$TMP_FILE" "$DYNAMIC_OPTS_FILE"
+	[ -x /etc/init.d/bind9 ] && /etc/init.d/bind9 reload > /dev/null 2>&1 || :
+fi
+
diff --git a/debian/rules b/debian/rules
index f1130d2..e6649f8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -111,6 +111,7 @@ install: build
 	install debian/ip-up.d debian/bind9/etc/network/if-up.d/bind9
 	install debian/ip-down.d debian/bind9/etc/network/if-down.d/bind9
 	install -m644 debian/bind9.ufw.profile debian/bind9/etc/ufw/applications.d/bind9
+	install debian/resolvconf-update-bind9 debian/bind9/etc/resolvconf/update.d/bind9
 
 # Build architecture-independent files here.
 binary-indep: build install

Reply via email to