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

Put all functions used in OMR-Tracker Post Tracking in a lib separate file

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-11-15 09:29:00 +01:00
parent 7e56a0f417
commit 857c7503be
3 changed files with 727 additions and 709 deletions

View file

@ -10,20 +10,7 @@
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
disable_pihole() {
local server=$1
if [ -n "$(uci -q get dhcp.@dnsmasq[0].server | grep '#53' | grep '10.255.25')" ]; then
_log "Disable Pi-Hole..."
uci -q del_list dhcp.@dnsmasq[0].server="$(uci -q get dhcp.@dnsmasq[0].server | tr ' ' '\n' | grep '#53' | grep '10.255.25')"
if [ -z "$(uci -q get dhcp.@dnsmasq[0].server | grep '127.0.0.1#5353')" ]; then
uci -q batch <<-EOF >/dev/null
add_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
commit dhcp
EOF
fi
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
}
. /usr/share/omr/lib/common-post-tracking.sh
# An interface in error will never be used in MPTCP
if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || { [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$interface_up" != "true" ]; }; then
@ -159,6 +146,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || { [ "$OMR_TRACKER_INTERFACE" != "omrvp
fi
if [ -n "$OMR_TRACKER_INTERFACE" ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='down'
env -i ACTION="disconnecting" INTERFACE="$INTERFACE" DEVICE="$DEVICE" /sbin/hotplug-call iface
fi
#if [ "$(sysctl -n net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ]; then
# multipath "$OMR_TRACKER_DEVICE" off > /dev/null 2>&1
@ -196,9 +184,11 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || { [ "$OMR_TRACKER_INTERFACE" != "omrvp
config_foreach set_route6 interface $OMR_TRACKER_INTERFACE
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "New routes $(ip r)"
elif [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath)" = "master" ]; then
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Default gw: $default_gw - Set routes (current: $(ip r) )"
config_load network
config_foreach set_route interface $OMR_TRACKER_INTERFACE "no"
config_foreach set_route6 interface $OMR_TRACKER_INTERFACE "no"
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "New routes $(ip r)"
elif [ -n "$OMR_TRACKER_DEVICE" ] && [ -n "$(ip r show table 991337 | grep "$OMR_TRACKER_DEVICE ")" ]; then
config_load network
config_foreach set_route interface $OMR_TRACKER_INTERFACE "no"
@ -281,7 +271,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || { [ "$OMR_TRACKER_INTERFACE" != "omrvp
/etc/init.d/openvpn restart omr >/dev/null 2>&1
fi
config_load openmptcprouter
config_foreach disable_pihole server
if [ "$(uci -q get openmptcprouter.settings.pihole_auto_conf)" != "0" ] && config_foreach disable_pihole server
#if [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ] || [ "$(uci -q get openmptcprouter.settings.vpn)" = "mlvpn" ]; then
if [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
config_foreach set_server_default_route server