2 # Copyright (c) 2007-2009 Roy Marples
5 # named subscriber for resolvconf
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
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.
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.
29 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
30 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
31 [ -z "$named_zones" -a -z "$named_options" ] && exit 0
32 [ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
36 # Platform specific kludges
37 if [ -z "$named_service" -a -z "$named_restart" -a \
38 -d "@RCDIR@" -a ! -x "@RCDIR@"/named ]
40 if [ -x "@RCDIR@"/bind9 ]; then
41 # Debian and derivatives
45 : ${named_service:=named}
46 : ${named_restart:=@RESTARTCMD ${named_service}@}
47 newoptions="# Generated by resolvconf$NL"
48 newzones="$newoptions"
51 for n in $NAMESERVERS; do
54 *) forward="$forward$NL $n;";;
57 if [ -n "$forward" ]; then
58 newoptions="${newoptions}forward first;${NL}forwarders {$forward${NL}};$NL"
62 newzones="${newzones}zone \"${d%%:*}\" {$NL"
63 newzones="$newzones type forward;$NL"
64 newzones="$newzones forward first;$NL forwarders {$NL"
66 while [ -n "$ns" ]; do
67 newzones="$newzones ${ns%%,*};$NL"
68 [ "$ns" = "${ns#*,}" ] && break
71 newzones="$newzones };$NL};$NL"
74 # No point in changing files or reloading bind if the end result has not
77 if [ -n "$named_options" ]; then
78 if [ ! -f "$named_options" ] || \
79 [ "$(cat "$named_options")" != "$(printf %s "$newoptions")" ]
81 printf %s "$newoptions" >"$named_options"
85 if [ -n "$named_zones" ]; then
86 if [ ! -f "$named_zones" ] || \
87 [ "$(cat "$named_zones")" != "$(printf %s "$newzones")" ]
89 printf %s "$newzones" >"$named_zones"