File: resolvconf

package info (click to toggle)
unbound 1.13.1-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 27,604 kB
  • sloc: ansic: 110,494; sh: 6,028; yacc: 3,391; python: 1,945; makefile: 1,689; awk: 161; perl: 158; xml: 36
file content (31 lines) | stat: -rw-r--r-- 661 bytes parent folder | download | duplicates (4)
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