1#!/bin/sh 2# Copyright (c) 2009-2011 Roy Marples 3# All rights reserved 4 5# PowerDNS Recursor subscriber for resolvconf 6 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# * Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# * Redistributions in binary form must reproduce the above 13# copyright notice, this list of conditions and the following 14# disclaimer in the documentation and/or other materials provided 15# with the distribution. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0 30. "@SYSCONFDIR@/resolvconf.conf" || exit 1 31[ -z "$pdns_zones" ] && exit 0 32[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)" 33NL=" 34" 35 36: ${pdns_service:=pdns_recursor} 37 38newzones= 39 40# pds_recursor does not present support global forward servers, which 41# does limit it's usefulness somewhat. 42# If it did, the below code can be enabled, or something like it. 43#for n in $NAMESERVERS; do 44# newzones="$newzones${newzones:+,}$n" 45#done 46#[ -n "$newzones" ] && newzones=".=$newzones$NL" 47 48for d in $DOMAINS; do 49 newns= 50 ns="${d#*:}" 51 while [ -n "$ns" ]; do 52 newns="$newns${newns:+,}${ns%%,*}" 53 [ "$ns" = "${ns#*,}" ] && break 54 ns="${ns#*,}" 55 done 56 [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns$NL" 57done 58 59# Try to ensure that config dirs exist 60if type config_mkdirs >/dev/null 2>&1; then 61 config_mkdirs "$pdnsd_zones" 62else 63 @SBINDIR@/resolvconf -D "$pdnsd_zones" 64fi 65 66if [ ! -f "$pdns_zones" ] || \ 67 [ "$(cat "$pdns_zones")" != "$(printf %s "$newzones")" ] 68then 69 printf %s "$newzones" >"$pdns_zones" 70 if [ -n "$pdns_restart" ]; then 71 eval $pdns_restart 72 elif [ -n "$RESTARTCMD" ]; then 73 set -- ${pdns_service} 74 eval $RESTARTCMD 75 else 76 @SBINDIR@/resolvconf -r ${pdns_service} 77 fi 78fi 79