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

Change DNS when VPS is down and Pi-Hole used

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-08-09 17:20:12 +02:00
parent 3193f4ef70
commit 00ddf7b378
2 changed files with 31 additions and 0 deletions

View file

@ -184,6 +184,24 @@ del_server_route() {
ip route del default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE >/dev/null 2>&1
}
disable_pihole() {
local server=$1
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ];
uci -q batch <<-EOF >/dev/null
set dhcp.@dnsmasq[0].server='127.0.0.1#5353'
commit dhcp
EOF
fi
}
enable_pihole() {
local server=$1
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ];
_log "Restart openmptcprouter-vps..."
/etc/init.d/openmptcprouter-vps restart
fi
}
dns_flush() {
unbound-control flush-negative >/dev/null 2>&1
unbound-control flush-bogus >/dev/null 2>&1
@ -264,6 +282,8 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
/etc/init.d/shadowsocks-libev rules_up
fi
fi
config_load openmptcprouter
config_foreach disable_pihole server
fi
dns_flush
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.lc
@ -321,6 +341,8 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
fi
uci -q commit openmptcprouter
fi
config_load openmptcprouter
config_foreach enable_pihole server
#ubus call network reload
exit 0
fi