dnsforwarder: fix dnsmasq configuration modification logic

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
badgv 2021-04-14 13:34:43 +08:00 committed by Tianling Shen
parent 01b72fdea1
commit 1687ea5cfc
No known key found for this signature in database
GPG Key ID: 6850B6345C862176

View File

@ -196,6 +196,12 @@ start()
uci commit dhcp
/etc/init.d/dnsmasq restart
fi
local dnsmasq_server_addr=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ -n "${dnsmasq_server_addr}" ]; then
uci set dhcp.@dnsmasq[0].noresolv=1
uci commit dhcp
/etc/init.d/dnsmasq restart
fi
add_cron
}
@ -204,8 +210,11 @@ stop()
del_cron
logger -t stopping dnsforwarder
local addr=$(uci get dnsforwarder.@arguments[0].addr 2>/dev/null)
local dnsmasq=$(uci get dnsforwarder.@arguments[0].dnsmasq 2>/dev/null)
addr=${addr/:/#}
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
if [ "${dnsmasq}" = "1" ]; then
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
fi
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto 2>/dev/null
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
uci delete dhcp.@dnsmasq[0].serversfile 2>/dev/null