Add support for the unbound nameserver - http://www.unbound.net/
authorRoy Marples <roy@marples.name>
Sun, 15 Nov 2009 20:20:56 +0000 (20:20 +0000)
committerRoy Marples <roy@marples.name>
Sun, 15 Nov 2009 20:20:56 +0000 (20:20 +0000)
Makefile
resolvconf.conf.5.in
unbound.in [new file with mode: 0644]

index 92f7f166d9afccba363c55f8f51ae3c603cb7805..d83d91f477751017497c1ad3c7731687e4ca9b80 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ VARDIR?=      ${VARBASE}/run/resolvconf
 MANDIR?=       ${MANPREFIX}/man
 
 RESOLVCONF=    resolvconf resolvconf.8 resolvconf.conf.5
-SUBSCRIBERS=   libc dnsmasq named
+SUBSCRIBERS=   libc dnsmasq named unbound
 TARGET=                ${RESOLVCONF} ${SUBSCRIBERS}
 
 # Try to embed correct service restart commands
index d3845d4dd6398d9f255ea25eba365835de7a2ba3..bef8f41fa369918592cb02ca438342c2aa26c797 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 12, 2009
+.Dd November 15, 2009
 .Dt RESOLVCONF.CONF 5 SMM
 .Os
 .Sh NAME
@@ -84,10 +84,11 @@ without any alteration.
 .El
 .Sh SUBSCRIBER OPTIONS
 openresolv ships with subscribers for the name servers
-.Xr dnsmasq 8
+.Xr dnsmasq 8 ,
+.Xr named 8
 and
-.Xr named 8 .
-These subscribers take two options each which instruct openresolv where
+.Xr unbound 8 .
+These subscribers have options which instruct openresolv where
 to write the configuration files for the name server to include.
 .Bl -tag -width indent
 .It Sy dnsmasq_conf
@@ -106,11 +107,14 @@ This file tells named which nameservers to use for global lookups.
 .It Sy named_zones
 Include this file in the named global scope, after the options block.
 This file tells named which nameservers to use for specific domains.
+.It Sy unbound_conf
+Include this file anywhere in the unbound configuration.
+This file tells unbound about specific and global nameservers.
 .El
 .Sh SEE ALSO
-.Xr resolv.conf 5 ,
-.Xr resolvconf 8 ,
-.Xr named.conf 5
+.Xr resolv.conf 5
+and
+.Xr resolvconf 8 .
 .Sh AUTHORS
 .An Roy Marples Aq roy@marples.name
 .Sh BUGS
diff --git a/unbound.in b/unbound.in
new file mode 100644 (file)
index 0000000..2f44dea
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Copyright (c) 2009 Roy Marples
+# All rights reserved
+
+# unbound subscriber for resolvconf
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
+. "@SYSCONFDIR@/resolvconf.conf" || exit 1
+[ -z "$unbound_conf" ] && exit 0
+[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
+
+: ${unbound_pid:=/var/run/unbound.pid}
+: ${unbound_restart:=@RESTARTCMD unbound@}
+newconf="# Generated by resolvconf\n"
+
+for d in $DOMAINS; do
+       dn="${d%%:*}"
+       ns="${d#*:}"
+       newconf="\n${newconf}forward-zone:\n\tname: \"$dn\"\n"
+       while [ -n "$ns" ]; do
+               newconf="${newconf}\tforward-addr: ${ns%%,*}\n"
+               [ "$ns" = "${ns#*,}" ] && break
+               ns="${ns#*,}"
+       done
+done
+
+if [ -n "$NAMESERVERS" ]; then
+       newconf="\n${newconf}forward-zone:\n\tname: \".\"\n"
+       for n in $NAMESERVERS; do
+               newconf="${newconf}\tforward-addr: $n\n"
+       done
+fi
+
+if [ ! -f "$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
+               eval $unbound_restart
+       #fi
+fi