If the sole non-option command line argument is "none", remove any
pre-existing forwarder configuration and set Unbound up to recurse. PR: 222902 MFC after: 1 week
This commit is contained in:
parent
bb2118ef40
commit
6a5d4fafb5
@ -252,6 +252,18 @@ gen_unbound_conf() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Rename a file we are about to replace.
|
||||||
|
#
|
||||||
|
backup() {
|
||||||
|
local file="$1"
|
||||||
|
if [ -f "${file}" ] ; then
|
||||||
|
local bkfile="${file}.${bkext}"
|
||||||
|
echo "Original ${file} saved as ${bkfile}"
|
||||||
|
mv "${file}" "${bkfile}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Replace one file with another, making a backup copy of the first,
|
# Replace one file with another, making a backup copy of the first,
|
||||||
# but only if the new file is different from the old.
|
# but only if the new file is different from the old.
|
||||||
@ -263,9 +275,7 @@ replace() {
|
|||||||
echo "${file} created"
|
echo "${file} created"
|
||||||
mv "${newfile}" "${file}"
|
mv "${newfile}" "${file}"
|
||||||
elif ! cmp -s "${file}" "${newfile}" ; then
|
elif ! cmp -s "${file}" "${newfile}" ; then
|
||||||
local oldfile="${file}.${bkext}"
|
backup "${file}"
|
||||||
echo "original ${file} saved as ${oldfile}"
|
|
||||||
mv "${file}" "${oldfile}"
|
|
||||||
mv "${newfile}" "${file}"
|
mv "${newfile}" "${file}"
|
||||||
else
|
else
|
||||||
echo "${file} not modified"
|
echo "${file} not modified"
|
||||||
@ -359,13 +369,20 @@ main() {
|
|||||||
# from resolv.conf.
|
# from resolv.conf.
|
||||||
#
|
#
|
||||||
forwarders="$@"
|
forwarders="$@"
|
||||||
if [ -z "$forwarders" ] ; then
|
case "${forwarders}" in
|
||||||
|
[Nn][Oo][Nn][Ee])
|
||||||
|
forwarders="none"
|
||||||
|
style=recursing
|
||||||
|
;;
|
||||||
|
"")
|
||||||
echo "Extracting forwarders from ${resolv_conf}."
|
echo "Extracting forwarders from ${resolv_conf}."
|
||||||
forwarders=$(get_nameservers <"${resolv_conf}")
|
forwarders=$(get_nameservers <"${resolv_conf}")
|
||||||
style=dynamic
|
style=dynamic
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
style=static
|
style=static
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate forward.conf.
|
# Generate forward.conf.
|
||||||
@ -377,6 +394,9 @@ main() {
|
|||||||
else
|
else
|
||||||
echo "unbound will recurse."
|
echo "unbound will recurse."
|
||||||
fi
|
fi
|
||||||
|
elif [ "${forwarders}" = "none" ] ; then
|
||||||
|
echo "Forwarding disabled, unbound will recurse."
|
||||||
|
backup "${forward_conf}"
|
||||||
else
|
else
|
||||||
local tmp_forward_conf=$(mktemp -u "${forward_conf}.XXXXX")
|
local tmp_forward_conf=$(mktemp -u "${forward_conf}.XXXXX")
|
||||||
gen_forward_conf ${forwarders} | unexpand >"${tmp_forward_conf}"
|
gen_forward_conf ${forwarders} | unexpand >"${tmp_forward_conf}"
|
||||||
|
Loading…
Reference in New Issue
Block a user