File: resolvconf

package info (click to toggle)
unbound 1.6.0-2~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 20,444 kB
  • sloc: ansic: 79,862; sh: 5,040; yacc: 1,900; makefile: 1,315; python: 1,302; perl: 141
file content (31 lines) | stat: -rw-r--r-- 661 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh -e

PATH=/usr/sbin:/usr/bin:/sbin:/bin

if [ ! -x /usr/sbin/unbound ]; then
    exit 0
fi

if [ ! -f /etc/unbound/unbound_control.key ]; then
    exit 0
fi

if [ ! -x /lib/resolvconf/list-records ]; then
    exit 1
fi

RESOLVCONF_FILES="$(/lib/resolvconf/list-records)"

if [ -n "$RESOLVCONF_FILES" ]; then
    NS_IPS="$(sed -rne 's/^[[:space:]]*nameserver[[:space:]]+//p' $RESOLVCONF_FILES \
        | egrep -v '^(127\.|::1)' | sort -u)"
else
    NS_IPS=""
fi

if [ -n "$NS_IPS" ]; then
    FWD="$(echo $NS_IPS | tr '\n' ' ')"
    unbound-control forward $FWD 1>/dev/null 2>&1 || true
else
    unbound-control forward off 1>/dev/null 2>&1 || true
fi