mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Get previous device if device is not detected by OMR-Tracker
This commit is contained in:
parent
c5d7e934c6
commit
be703c65ad
1 changed files with 11 additions and 5 deletions
|
@ -24,6 +24,7 @@ export OMR_TRACKER_STATUS
|
|||
export OMR_TRACKER_STATUS_MSG
|
||||
export OMR_TRACKER_PREV_STATUS
|
||||
export OMR_TRACKER_DEVICE
|
||||
export OMR_TRACKER_PREV_DEVICE
|
||||
export OMR_TRACKER_DEVICE_IP
|
||||
export OMR_TRACKER_DEVICE_IP6
|
||||
export OMR_TRACKER_PREV_DEVICE_IP
|
||||
|
@ -306,6 +307,7 @@ while true; do
|
|||
}
|
||||
|
||||
if [ -n "$OMR_TRACKER_DEVICE" ] && [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
|
||||
OMR_TRACKER_PREV_DEVICE="$OMR_TRACKER_DEVICE"
|
||||
OMR_TRACKER_DEVICE_STATE=$(ip -j link show dev "$OMR_TRACKER_DEVICE" | jsonfilter -q -e '@[*].operstate' | tr -d '\n')
|
||||
if ([ "$(ifstatus $OMR_TRACKER_INTERFACE | jsonfilter -q -e '@.up')" == "true" ] && [ "$OMR_TRACKER_DEVICE_STATE" != "DOWN" ]) || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then
|
||||
# retrieve iface ip and gateway
|
||||
|
@ -343,7 +345,7 @@ while true; do
|
|||
fi
|
||||
fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_ROUTE=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep via | grep -v default | grep -v metric | grep -v / | awk '{print $1; exit}' | tr -d "\n")
|
||||
OMR_TRACKER_DEVICE_ROUTE=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep via | grep -v default | grep -v nexthop | grep -v metric | grep -v / | awk '{print $1; exit}' | tr -d "\n")
|
||||
fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep kernel | grep -v '.0/' | awk '/proto kernel/ {print $1;exit}' | tr -d "\n")
|
||||
|
@ -354,6 +356,10 @@ while true; do
|
|||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | awk '/via/ {print $3;exit}' | tr -d "\n")
|
||||
fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ] && [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ] && [ "$(uci -q get openvpn.omr.enabled)" = "1" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY="10.255.252.1"
|
||||
fi
|
||||
|
||||
fi
|
||||
if { [ "$OMR_TRACKER_IPV6" = "1" ] || [ "$OMR_TRACKER_IPV6" = "auto" ]; } && { [ "$OMR_TRACKER_FAMILY" = "ipv6" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]; }; then
|
||||
#OMR_TRACKER_DEVICE_IP6=$(ip -6 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
|
||||
|
@ -403,7 +409,7 @@ while true; do
|
|||
break
|
||||
elif [ "$OMR_TRACKER_TYPE" != "none" ]; then
|
||||
if ! $(exit $status); then
|
||||
OMR_TRACKER_STATUS_MSG="gateway down"
|
||||
OMR_TRACKER_STATUS_MSG="IPv4 gateway down"
|
||||
fi
|
||||
serverip_ping=false
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
|
@ -472,7 +478,7 @@ while true; do
|
|||
fi
|
||||
[ "$OMR_TRACKER_STATUS" = "OK" ] && break
|
||||
elif ! $(exit $status); then
|
||||
OMR_TRACKER_STATUS_MSG="gateway down"
|
||||
OMR_TRACKER_STATUS_MSG="IPv4 gateway down"
|
||||
fi
|
||||
tries=$((tries - 1))
|
||||
#_restart
|
||||
|
@ -507,7 +513,7 @@ while true; do
|
|||
break
|
||||
elif [ "$OMR_TRACKER_TYPE" != "none" ]; then
|
||||
if ! $(exit $status); then
|
||||
OMR_TRACKER_STATUS_MSG="gateway6 down"
|
||||
OMR_TRACKER_STATUS_MSG="IPv6 gateway down"
|
||||
fi
|
||||
serverip_ping=false
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
|
@ -577,7 +583,7 @@ while true; do
|
|||
fi
|
||||
[ "$OMR_TRACKER_STATUS" = "OK" ] && break
|
||||
elif ! $(exit $status); then
|
||||
OMR_TRACKER_STATUS_MSG="gateway down"
|
||||
OMR_TRACKER_STATUS_MSG="IPv6 gateway down"
|
||||
fi
|
||||
tries=$((tries - 1))
|
||||
#_restart
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue