Updated fixnet.sh to check for presence of USB device before checking for connectivity
This commit is contained in:
parent
8efdeca1d4
commit
313684fe3e
1 changed files with 18 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
version=0.05
|
version=0.06
|
||||||
|
|
||||||
# A simple script that checks for connectivity (including working DNS resolution)
|
# A simple script that checks for connectivity (including working DNS resolution)
|
||||||
# If no connectivity, reset tethering
|
# If no connectivity, reset tethering
|
||||||
|
@ -21,22 +21,26 @@ CHECKWWW=www.google.com
|
||||||
SLEEPITOFF=60
|
SLEEPITOFF=60
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
lsusb | grep $TETHERDEV > /dev/null
|
while true; do
|
||||||
if (( $? )); then
|
# look for USB device
|
||||||
echo "Tethering device not found! Sleeping..."
|
lsusb | grep $TETHERDEV > /dev/null
|
||||||
sleep 5s
|
|
||||||
else
|
|
||||||
echo "Tethering device present, continuing"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
while true; do
|
# make sure there is a device connected before continuing
|
||||||
|
if (( $? )); then
|
||||||
|
echo "Tethering device not found! Sleeping 5s..."
|
||||||
|
sleep 5s
|
||||||
|
else
|
||||||
|
echo "Tethering device present, continuing with network check..."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# command to check for connectivity
|
||||||
curl --connect-timeout 10 $CHECKWWW > /dev/null 2>&1
|
curl --connect-timeout 10 $CHECKWWW > /dev/null 2>&1
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
# No internet
|
# No internet
|
||||||
echo "Network down, Houston we have a problem!" # FIXME: For debugging
|
echo "Network down, resetting USB and restarting easytether!"
|
||||||
# Reset the USB device
|
# Reset the USB device
|
||||||
usbreset $TETHERDEV
|
usbreset $TETHERDEV
|
||||||
# Wait a few seconds for device to be ready again
|
# Wait a few seconds for device to be ready again
|
||||||
|
@ -45,8 +49,9 @@ while true; do
|
||||||
easytether-usb
|
easytether-usb
|
||||||
else
|
else
|
||||||
# Internet working
|
# Internet working
|
||||||
echo "Network up, all good in the hood!" # FIXME: For debugging
|
echo "Network up!"
|
||||||
fi
|
fi
|
||||||
|
echo "Sleeping $SLEEPITOFF before rechecking"
|
||||||
sleep $SLEEPITOFF
|
sleep $SLEEPITOFF
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue