fix gateway supervisor function for usb direct monitoring

This commit is contained in:
Alfonso Gamboa 2022-08-18 21:40:38 -07:00
parent 9212bd641d
commit 16c89dca72

View File

@ -59,23 +59,26 @@ wait_for_icamera() {
} }
gateway_supervisor() { gateway_supervisor() {
count=0 last=0
while [ true ]; do last2=0
if ! ping -c1 -W 2 `/opt/wz_mini/bin/busybox ip route | awk '/default/ { print $3 }'` >& /dev/null; then
echo "$1: Unable to reach default route via USB Direct Link, ifdown usb0..." while [[ 1 ]]; do
count=0 ping -c1 -W 2 `/opt/wz_mini/bin/busybox ip route | awk '/default/ { print $3 }'` >& /dev/null
ifconfig usb0 down status=$?
sleep 10 if [[ $status == 1 ]]; then
else echo "$1: $(date) Unable to reach default route via USB Direct Link..."
if [[ $count -ne 1 ]] if [[ $last == 1 && $last2 == 1 ]]; then
then echo "$1: $(date) USB Direct is Down, bring down usb0"
#echo "Connected." ifconfig usb0 down
count=1 status=0
sleep 5
fi fi
sleep 1
fi fi
last2=$last
last=$status
sleep 10
done done
} }