mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-14 11:31:51 +00:00
Fix failover
This commit is contained in:
parent
def4db4d46
commit
5dc4952622
1 changed files with 5 additions and 2 deletions
|
@ -4,14 +4,17 @@ SETROUTE=false
|
|||
set_route() {
|
||||
local multipath_config interface_gw interface_if
|
||||
INTERFACE=$1
|
||||
PREVINTERFACE=$2
|
||||
multipath_config=$(uci -q get "network.$INTERFACE.multipath" || echo "off")
|
||||
multipath_current_config=$(multipath $INTERFACE | grep deactivated)
|
||||
if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ] && [ "$multipath_current_config" = "" ]; then
|
||||
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ] && [ "$multipath_current_config" = "" ]; then
|
||||
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ]; then
|
||||
if [ "$multipath_config" != "off" ] &&[ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$SETROUTE" != true ]; then
|
||||
interface_gw=$(uci -q get "network.$INTERFACE.gateway")
|
||||
interface_if=$(uci -q get "network.$INTERFACE.ifname")
|
||||
_log "Replace default route by $interface_gw dev $interface_if"
|
||||
ip route replace default scope global nexthop via $interface_gw dev $interface_if && SETROUTE=true
|
||||
sleep `expr $RANDOM % 10`
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -34,7 +37,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
|
|||
multipath "$OMR_TRACKER_DEVICE" off
|
||||
if [ "$default_gw" = "$current_interface_gw" ] || [ "$default_gw" = "" ]; then
|
||||
config_load network
|
||||
config_foreach set_route interface
|
||||
config_foreach set_route interface $OMR_TRACKER_DEVICE
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue