1282431Sgjb#!/bin/sh 2282431Sgjb# Copyright (c) 2009-2011 Roy Marples 3282431Sgjb# All rights reserved 4282431Sgjb 5282431Sgjb# PowerDNS Recursor subscriber for resolvconf 6282431Sgjb 7282431Sgjb# Redistribution and use in source and binary forms, with or without 8282431Sgjb# modification, are permitted provided that the following conditions 9282431Sgjb# are met: 10282431Sgjb# * Redistributions of source code must retain the above copyright 11282431Sgjb# notice, this list of conditions and the following disclaimer. 12282431Sgjb# * Redistributions in binary form must reproduce the above 13282431Sgjb# copyright notice, this list of conditions and the following 14282431Sgjb# disclaimer in the documentation and/or other materials provided 15282431Sgjb# with the distribution. 16282431Sgjb# 17282431Sgjb# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18282431Sgjb# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19282431Sgjb# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20282431Sgjb# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21282431Sgjb# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22282431Sgjb# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23282431Sgjb# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24282431Sgjb# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25282431Sgjb# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26282431Sgjb# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27282431Sgjb# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28282431Sgjb 29282431Sgjb[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0 30282431Sgjb. "@SYSCONFDIR@/resolvconf.conf" || exit 1 31282431Sgjb[ -z "$pdns_zones" ] && exit 0 32282431Sgjb[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)" 33282431SgjbNL=" 34282431Sgjb" 35282431Sgjb 36282431Sgjb: ${pdns_service:=pdns_recursor} 37282431Sgjb 38282431Sgjbnewzones= 39282431Sgjb 40282431Sgjb# pds_recursor does not present support global forward servers, which 41282431Sgjb# does limit it's usefulness somewhat. 42282431Sgjb# If it did, the below code can be enabled, or something like it. 43282431Sgjb#for n in $NAMESERVERS; do 44282431Sgjb# newzones="$newzones${newzones:+,}$n" 45282431Sgjb#done 46282431Sgjb#[ -n "$newzones" ] && newzones=".=$newzones$NL" 47282431Sgjb 48282431Sgjbfor d in $DOMAINS; do 49282431Sgjb newns= 50282431Sgjb ns="${d#*:}" 51282431Sgjb while [ -n "$ns" ]; do 52282431Sgjb newns="$newns${newns:+,}${ns%%,*}" 53282431Sgjb [ "$ns" = "${ns#*,}" ] && break 54282431Sgjb ns="${ns#*,}" 55282431Sgjb done 56282431Sgjb [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns$NL" 57282431Sgjbdone 58282431Sgjb 59282431Sgjb# Try to ensure that config dirs exist 60282431Sgjbif type config_mkdirs >/dev/null 2>&1; then 61282431Sgjb config_mkdirs "$pdnsd_zones" 62282431Sgjbelse 63282431Sgjb @SBINDIR@/resolvconf -D "$pdnsd_zones" 64282431Sgjbfi 65282431Sgjb 66282431Sgjbif [ ! -f "$pdns_zones" ] || \ 67282431Sgjb [ "$(cat "$pdns_zones")" != "$(printf %s "$newzones")" ] 68282431Sgjbthen 69282431Sgjb printf %s "$newzones" >"$pdns_zones" 70313980Spfg if [ -n "$pdns_restart" ]; then 71313980Spfg eval $pdns_restart 72313980Spfg elif [ -n "$RESTARTCMD" ]; then 73313980Spfg set -- ${pdns_service} 74313980Spfg eval $RESTARTCMD 75313980Spfg else 76313980Spfg @SBINDIR@/resolvconf -r ${pdns_service} 77313980Spfg fi 78282431Sgjbfi 79