Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / openresolv / dist / unbound.in
blob6d8547a8877de229ad622f1e5d9e5d893c987a52
1 #!/bin/sh
2 # Copyright (c) 2009 Roy Marples
3 # All rights reserved
5 # unbound subscriber for resolvconf
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.
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 "$unbound_conf" ] && exit 0
32 [ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
34 : ${unbound_pid:=/var/run/unbound.pid}
35 : ${unbound_restart:=@RESTARTCMD unbound@}
36 newconf="# Generated by resolvconf\n"
38 for d in $DOMAINS; do
39 dn="${d%%:*}"
40 ns="${d#*:}"
41 newconf="${newconf}\nforward-zone:\n\tname: \"$dn\"\n"
42 while [ -n "$ns" ]; do
43 newconf="${newconf}\tforward-addr: ${ns%%,*}\n"
44 [ "$ns" = "${ns#*,}" ] && break
45 ns="${ns#*,}"
46 done
47 done
49 if [ -n "$NAMESERVERS" ]; then
50 newconf="${newconf}\nforward-zone:\n\tname: \".\"\n"
51 for n in $NAMESERVERS; do
52 newconf="${newconf}\tforward-addr: $n\n"
53 done
56 if [ ! -f "$unbound_conf" ] || \
57 [ "$(cat "$unbound_conf")" != "$(printf "$newconf")" ]
58 then
59 printf "$newconf" >"$unbound_conf"
60 # If we can't sent a HUP then force a restart
61 if [ -s "$unbound_pid" ]; then
62 if ! kill -HUP $(cat "$unbound_pid") 2>/dev/null; then
63 eval $unbound_restart
65 else
66 eval $unbound_restart