1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Test gateway before all

This commit is contained in:
Ycarus 2018-02-20 20:04:02 +01:00
parent 6dcc086948
commit f9adb2e523

View file

@ -79,7 +79,6 @@ _restart
while true; do
# setup tracker variables
OMR_TRACKER_DEVICE_IP=
OMR_TRACKER_DEVICE_GATEWAY=
OMR_TRACKER_STATUS="ERROR"
OMR_TRACKER_LATENCY=
OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
@ -90,24 +89,31 @@ while true; do
# execute specific tracker
if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
# setup loop variable
tries="$OMR_TRACKER_TRIES"
# loop until tries attempts have been reached
while [ "$tries" -gt 0 ]; do
ret=$(ping "$OMR_TRACKER_HOST" \
-I "$OMR_TRACKER_DEVICE_IP" \
-w "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q
) && echo "$ret" | grep -sq "0% packet loss" && {
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f4 | cut -d "." -f1)
_update_rto "$OMR_TRACKER_LATENCY"
OMR_TRACKER_STATUS="OK"
break
}
tries=$((tries - 1))
OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
done
retgw=$(ping "$OMR_TRACKER_DEVICE_GATEWAY" \
-I "$OMR_TRACKER_DEVICE_IP" \
-w 1 \
-c 1 \
-q
) && echo "$retgw" | grep -sq "0% packet loss" && {
# setup loop variable
tries="$OMR_TRACKER_TRIES"
# loop until tries attempts have been reached
while [ "$tries" -gt 0 ]; do
ret=$(ping "$OMR_TRACKER_HOST" \
-I "$OMR_TRACKER_DEVICE_IP" \
-w "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q
) && echo "$ret" | grep -sq "0% packet loss" && {
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f4 | cut -d "." -f1)
_update_rto "$OMR_TRACKER_LATENCY"
OMR_TRACKER_STATUS="OK"
break
}
tries=$((tries - 1))
OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
done
}
fi
fi