6 # PROVIDE: local_unbound
7 # REQUIRE: FILESYSTEMS netif resolv
13 desc="local caching forwarding resolver"
14 rcvar="local_unbound_enable"
16 command="/usr/sbin/unbound"
17 extra_commands="anchor configtest reload setup"
18 start_precmd="local_unbound_prestart"
19 reload_precmd="local_unbound_configtest"
20 anchor_cmd="local_unbound_anchor"
21 configtest_cmd="local_unbound_configtest"
22 setup_cmd="local_unbound_setup"
23 pidfile="/var/run/${name}.pid"
25 : ${local_unbound_workdir:=/var/unbound}
26 : ${local_unbound_config:=${local_unbound_workdir}/unbound.conf}
27 : ${local_unbound_flags:=-c${local_unbound_config}}
28 : ${local_unbound_forwardconf:=${local_unbound_workdir}/forward.conf}
29 : ${local_unbound_controlconf:=${local_unbound_workdir}/control.conf}
30 : ${local_unbound_anchor:=${local_unbound_workdir}/root.key}
31 : ${local_unbound_forwarders:=}
37 echo "$@" | su -m unbound
41 # Retrieve or update the DNSSEC root anchor
43 local_unbound_anchor()
45 do_as_unbound /usr/sbin/unbound-anchor -a ${local_unbound_anchor}
46 # we can't trust the exit code - check if the file exists
47 [ -f ${local_unbound_anchor} ]
51 # Check the unbound configuration file
53 local_unbound_configtest()
55 do_as_unbound /usr/sbin/unbound-checkconf ${local_unbound_config}
59 # Create the unbound configuration file and update resolv.conf to
64 echo "Performing initial setup."
65 /usr/sbin/local-unbound-setup -n \
67 -w ${local_unbound_workdir} \
68 -c ${local_unbound_config} \
69 -f ${local_unbound_forwardconf} \
70 -o ${local_unbound_controlconf} \
71 -a ${local_unbound_anchor} \
72 ${local_unbound_forwarders}
76 # Before starting, check that the configuration file and root anchor
77 # exist. If not, attempt to generate them.
79 local_unbound_prestart()
81 # Create configuration file
82 if [ ! -f ${local_unbound_config} ] ; then
86 # Retrieve DNSSEC root key
87 if [ ! -f ${local_unbound_anchor} ] ; then