Package: unbound
Severity: wishlist
Tags: patch

Signed-off-by: martin f. krafft <madd...@debian.org>
---
 contrib/resolvconf-update-script.sh               |   42 +++++++++++++++++++++
 debian/patches/30_example_conf_resolvconf_include |   14 +++++++
 debian/patches/series                             |    1 +
 debian/rules                                      |    2 +
 debian/unbound.dirs                               |    2 +
 5 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100755 contrib/resolvconf-update-script.sh
 create mode 100644 debian/patches/30_example_conf_resolvconf_include

diff --git a/contrib/resolvconf-update-script.sh 
b/contrib/resolvconf-update-script.sh
new file mode 100755
index 0000000..fae4438
--- /dev/null
+++ b/contrib/resolvconf-update-script.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Script to inform unbound about upstream resolvers.
+#
+# Copyright © 2010 martin f. krafft <madd...@debian.org>
+# based on similar scripts by Thomas Hood
+#
+set -eux
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+UNBOUND_CONF=/var/cache/unbound/resolvconf_resolvers.conf
+
+[ -x /usr/sbin/unbound ] || exit 0
+[ -x /lib/resolvconf/list-records ] || exit 1
+
+exec >$UNBOUND_CONF
+
+RESOLVCONF_FILES="$(/lib/resolvconf/list-records)"
+[ -n "$RESOLVCONF_FILES" ] || exit 0
+
+NS_IPS="$(sed -rne 's/^[[:space:]]*nameserver[[:space:]]+//p' 
$RESOLVCONF_FILES \
+  | egrep -v '^(127\.|::1)')"
+[ -n "$NS_IPS" ] || exit 0
+
+MD5SUM=$(test -f $UNBOUND_CONF && md5sum $UNBOUND_CONF || :)
+
+cat <<_eof
+server:
+       forward-zone:
+               name: "."
+_eof
+
+echo "$NS_IPS" | sort -u | while read ip; do
+    echo "             forward-addr: $ip"
+  done
+
+exec >/dev/null
+
+if ! echo "$MD5SUM" | md5sum -c 2>&1; then
+  invoke-rc.d unbound force-reload
+fi
diff --git a/debian/patches/30_example_conf_resolvconf_include 
b/debian/patches/30_example_conf_resolvconf_include
new file mode 100644
index 0000000..869ee6f
--- /dev/null
+++ b/debian/patches/30_example_conf_resolvconf_include
@@ -0,0 +1,14 @@
+Index: unbound-1.4.1/doc/example.conf.in
+===================================================================
+--- unbound-1.4.1.orig/doc/example.conf.in     2010-02-01 11:42:32.455770227 
+1300
++++ unbound-1.4.1/doc/example.conf.in  2010-02-01 11:42:35.791768659 +1300
+@@ -484,3 +484,9 @@
+ # forward-zone:
+ #     name: "example.org"
+ #     forward-host: fwd.example.com
++
++# Resolvconf integration
++# If you have the resolvconf package installed, you can uncomment the
++# following to let unbound forward queries to the DNS resolvers discovered by
++# resolvconf (e.g. from DHCP or static entries in /etc/network/interfaces).
++# include: "/var/cache/unbound/resolvconf_resolvers.conf"
diff --git a/debian/patches/series b/debian/patches/series
index a450590..3957a6e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 20_example_conf_default_chroot
 10_libev_library
+30_example_conf_resolvconf_include
diff --git a/debian/rules b/debian/rules
index ad1025f..f36201c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -26,6 +26,8 @@ install: build
        dh_installinit --error-handler=true --restart-after-upgrade
        dh install --after dh_installinit
        install -m 0644 doc/example.conf debian/unbound/etc/unbound/unbound.conf
+       install -m 0755 contrib/resolvconf-update-script.sh \
+               debian/unbount/etc/resolvconf/update.d/unbound
 
 binary-arch: install
        dh binary-arch
diff --git a/debian/unbound.dirs b/debian/unbound.dirs
index 494bf88..a94bbaf 100644
--- a/debian/unbound.dirs
+++ b/debian/unbound.dirs
@@ -4,3 +4,5 @@ usr/sbin
 usr/share/man/man5
 usr/share/man/man8
 var/lib/unbound
+var/cache/unbound
+etc/resolvconf/update.d
-- 
1.6.6




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to