diff --git a/easytether/README.md b/easytether/README.md new file mode 100644 index 0000000..d1fdd45 --- /dev/null +++ b/easytether/README.md @@ -0,0 +1,5 @@ +A script to automatically bring up/restart eastether'd USB phone. + +It was written specifically for the GL.Net AR750S-EXT router, but is generic enough to work elsewhere. + +Requires easytether to already be setup on the device. diff --git a/easytether/fixnet.sh b/easytether/fixnet.sh new file mode 100755 index 0000000..41ff07d --- /dev/null +++ b/easytether/fixnet.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +# Version +version=0.05 + +# A simple script that checks for connectivity (including working DNS resolution) +# If no connectivity, reset tethering +# +# Requires easytether-usb to be installed and already setup/working +# Manual (one time) setting of the USB device ID of the tether device (TETHERDEV). + +# Find the tethering device with lsusb. Example (Samsung/Verizon kids tablet): +# Bus 001 Device 013: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP) +TETHERDEV=04e8:6860 +# 04e8:6860 is for Samsung's USB identification (both Note 10 and kids tablet) + +# Some highly available website to check (www.google.com is backed by *lots* of servers) +CHECKWWW=www.google.com + +# How long before we check again? +SLEEPITOFF=60 + +while true; do + lsusb | grep $TETHERDEV > /dev/null + if (( $? )); then + echo "Tethering device not found! Sleeping..." + sleep 5s + else + echo "Tethering device present, continuing" + break + fi +done + +while true; do + curl --connect-timeout 10 $CHECKWWW > /dev/null 2>&1 + + if [ $? != 0 ]; then + # No internet + echo "Network down, Houston we have a problem!" # FIXME: For debugging + # Reset the USB device + usbreset $TETHERDEV + # Wait a few seconds for device to be ready again + sleep 5s + # (re)start easytether-usb to make a connection + easytether-usb + else + # Internet working + echo "Network up, all good in the hood!" # FIXME: For debugging + fi + sleep $SLEEPITOFF +done +