Skip to content

Commit

Permalink
If forwarders were specified on the command line, create an empty
Browse files Browse the repository at this point in the history
resolvconf.conf so that resolvconf won't replace the manually configured
forwarders with dynamically configured ones the next time the lease is
renewed.
  • Loading branch information
dag-erling committed Sep 16, 2015
1 parent 8d4b810 commit ae96779
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions usr.sbin/unbound/local-setup/local-unbound-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,18 @@ do_not_edit() {
# the libc resolver will try unbound first.
#
gen_resolvconf_conf() {
local style="$1"
do_not_edit
echo "resolv_conf=\"/dev/null\" # prevent updating ${resolv_conf}"
echo "unbound_conf=\"${forward_conf}\""
echo "unbound_pid=\"${pidfile}\""
echo "unbound_service=\"${service}\""
# resolvconf(8) likes to restart rather than reload
echo "unbound_restart=\"service ${service} reload\""
if [ "${style}" = "dynamic" ] ; then
echo "unbound_conf=\"${forward_conf}\""
echo "unbound_pid=\"${pidfile}\""
echo "unbound_service=\"${service}\""
# resolvconf(8) likes to restart rather than reload
echo "unbound_restart=\"service ${service} reload\""
else
echo "# Static DNS configuration"
fi
}

#
Expand Down Expand Up @@ -379,6 +384,9 @@ main() {
if [ -z "$forwarders" ] ; then
echo "Extracting forwarders from ${resolv_conf}."
forwarders=$(get_nameservers <"${resolv_conf}")
style=dynamic
else
style=static
fi

#
Expand Down Expand Up @@ -440,7 +448,7 @@ main() {
# instead of resolv.conf.
#
local tmp_resolvconf_conf=$(mktemp -u "${resolvconf_conf}.XXXXX")
gen_resolvconf_conf | unexpand >"${tmp_resolvconf_conf}"
gen_resolvconf_conf "${style}" | unexpand >"${tmp_resolvconf_conf}"
replace "${resolvconf_conf}" "${tmp_resolvconf_conf}"

#
Expand Down

0 comments on commit ae96779

Please sign in to comment.