1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Fix pihole DNS change

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-08-09 17:44:34 +02:00
parent fd33962c9d
commit d5b3a36442
2 changed files with 45 additions and 32 deletions

View file

@ -186,7 +186,7 @@ del_server_route() {
disable_pihole() {
local server=$1
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ];
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ]; then
uci -q batch <<-EOF >/dev/null
set dhcp.@dnsmasq[0].server='127.0.0.1#5353'
commit dhcp
@ -196,9 +196,9 @@ disable_pihole() {
enable_pihole() {
local server=$1
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ];
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ] && [ "$(uci -q dhcp.@dnsmasq[0].server)" != "127.0.0.1#5353" ]; then
_log "Restart openmptcprouter-vps..."
/etc/init.d/openmptcprouter-vps restart
/etc/init.d/openmptcprouter-vps set_pihole
fi
}

View file

@ -6,6 +6,8 @@ START=99
USE_PROCD=1
EXTRA_COMMANDS="set_pihole"
_parse_result() {
result=$("echo $1 | jsonfilter -q -e '@.result'")
echo $result
@ -174,17 +176,6 @@ _get_vps_config() {
EOF
vpn="$(uci -q get openmptcprouter.settings.vpn)"
pihole="$(echo "$vps_config" | jsonfilter -q -e '@.pihole.state')"
if [ "$pihole" = "true" ]; then
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.pihole='1'
EOF
else
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.pihole='0'
EOF
fi
glorytun_state=0
glorytun_change=0
if [ "$vpn" = "glorytun_tcp" ]; then
@ -223,16 +214,6 @@ _get_vps_config() {
glorytun_change=1
fi
fi
if [ "$pihole" = "true" ] && [ "$(uci -q get dhcp.@dnsmasq[0].server)" != "$host_ip#53" ]; then
uci -q batch <<-EOF >/dev/null
delete dhcp.@dnsmasq[0].server
add_list dhcp.@dnsmasq[0].server="$host_ip#53"
set dhcp.@dnsmasq[0].rebind_protection='0'
commit dhcp
EOF
logger -t "OMR-VPS" "Restart dnsmasq..."
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
fi
if [ "$vpn" = "glorytun_udp" ]; then
glorytun_state=1
@ -270,6 +251,45 @@ _get_vps_config() {
glorytun_change=1
fi
fi
fi
if [ "$glorytun_change" != "0" ]; then
logger -t "OMR-VPS" "Restart glorytun..."
uci -q batch <<-EOF >/dev/null
commit glorytun
EOF
/etc/init.d/glorytun restart >/dev/null 2>&1
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
fi
}
set_pihole() {
[ -z "$vps_config" ] && vps_config=$(_get_json "config")
[ -z "$vps_config" ] && return
vpn="$(uci -q get openmptcprouter.settings.vpn)"
pihole="$(echo "$vps_config" | jsonfilter -q -e '@.pihole.state')"
if [ "$pihole" = "true" ]; then
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.pihole='1'
EOF
else
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.pihole='0'
EOF
fi
if [ "$vpn" = "glorytun_tcp" ]; then
if [ "$pihole" = "true" ] && [ "$(uci -q get dhcp.@dnsmasq[0].server)" != "$host_ip#53" ]; then
uci -q batch <<-EOF >/dev/null
delete dhcp.@dnsmasq[0].server
add_list dhcp.@dnsmasq[0].server="$host_ip#53"
set dhcp.@dnsmasq[0].rebind_protection='0'
commit dhcp
EOF
logger -t "OMR-VPS" "Restart dnsmasq..."
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
fi
if [ "$vpn" = "glorytun_udp" ]; then
if [ "$pihole" = "true" ] && [ "$(uci -q get dhcp.@dnsmasq[0].server)" != "$host_ip#53" ]; then
uci -q batch <<-EOF >/dev/null
delete dhcp.@dnsmasq[0].server
@ -320,14 +340,6 @@ _get_vps_config() {
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
fi
if [ "$glorytun_change" != "0" ]; then
logger -t "OMR-VPS" "Restart glorytun..."
uci -q batch <<-EOF >/dev/null
commit glorytun
EOF
/etc/init.d/glorytun restart >/dev/null 2>&1
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
fi
}
_set_redirect_ports_from_vps() {
@ -666,6 +678,7 @@ _config_service() {
}
fi
uci -q set openmptcprouter.settings.firstboot=0
set_pihole
config_load shadowsocks-libev
config_foreach _set_ss_server_vps server