Add a subcriber for the PowerDNS Recursor
authorRoy Marples <roy@marples.name>
Tue, 21 Apr 2009 12:31:25 +0000 (12:31 +0000)
committerRoy Marples <roy@marples.name>
Tue, 21 Apr 2009 12:31:25 +0000 (12:31 +0000)
Makefile
pdns-recursor.in [new file with mode: 0755]
resolvconf.conf.5.in

index 0543925c52bfcb3ac41fafad2fd272feb8214f81..0457cee505cec31b5922dccda4352ff12abb7fe7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ VARDIR?=      ${VARBASE}/run/resolvconf
 MANDIR?=       ${MANPREFIX}/man
 
 RESOLVCONF=    resolvconf resolvconf.8 resolvconf.conf.5
-SUBSCRIBERS=   libc dnsmasq named
+SUBSCRIBERS=   libc dnsmasq named pdns-recursor
 TARGET=                ${RESOLVCONF} ${SUBSCRIBERS}
 
 .SUFFIXES: .in
diff --git a/pdns-recursor.in b/pdns-recursor.in
new file mode 100755 (executable)
index 0000000..5e5f7f4
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Copyright 2009 Roy Marples
+# All rights reserved
+
+# PowerDNS Recursor 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 "$pdns_zones" ] && exit 0
+: ${RESOLVCONF:=resolvconf}
+eval "$("$RESOLVCONF" -v)"
+
+newzones=
+for n in $NAMESERVERS; do
+       newzones="$newzones${newzones:+,}$n"
+done
+[ -n "$newzones" ] && newzones=".=$newzones\n"
+
+dbusdest=
+for d in $DOMAINS; do
+       newns=
+       ns="${d#*:}"
+       while [ -n "$ns" ]; do
+               newns="$newns${newns:+,}${ns%%,*}"
+               [ "$ns" = "${ns#*,}" ] && break
+               ns="${ns#*,}"
+       done
+       [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns\n"
+done
+
+changed=false
+if [ ! -f "$pdns_zones" ] || \
+       [ "$(cat "$pdns_zones")" != "$(printf "$newzones")" ]
+then
+       changed=true
+       printf "$newzones" >"$pdns_zones"
+fi
+
+$changed && $RESOLVCONF -s pdns_recursor restart
\ No newline at end of file
index f26a58bdc94a540b1a40c894fc3c3c5eb320acfa..e0cba996ac70542e7e5e8fa628a2d182bade1d9d 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 26, 2009
+.Dd April 21, 2009
 .Dt RESOLVCONF.CONF 5 SMM
 .Os
 .Sh NAME
@@ -75,7 +75,8 @@ without any alteration.
 .El
 .Sh SUBSCRIBER OPTIONS
 openresolv ships with subscribers for the name servers
-.Xr dnsmasq 8
+.Xr dnsmasq 8 ,
+.Xr pdns_recursor 8
 and
 .Xr named 8 .
 These subscribers take two options each which instruct openresolv where
@@ -89,6 +90,10 @@ points to.
 Set this to the same file that the dnsmasq configuaration option
 .Sy resolv-file
 points to.
+.It Sy pdns_zones
+Set this to the same file that the pdns_recursor configuration option
+.Sy forward-zones-file
+points to.
 .It Sy named_options
 Include this file in the named options block.
 .It Sy named_zones