From b4eb67041915020dd9757a163fe8a2b4a7748dd4 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 5 Jun 2022 17:56:05 -0500 Subject: [PATCH] Update mm-scripts.sh --- mm-scripts.sh | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/mm-scripts.sh b/mm-scripts.sh index 6f089d2..a772729 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -97,7 +97,7 @@ MMSTART(){ echo "$(date) - Could not confirm default routes, restarting system" >> $logfile [ $SENDNOTICE = true ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net MMSTOP - sleep 1m + sleep 2m "${VPN_START[@]}" sleep 1m rm -f /opt/mm.stop @@ -110,8 +110,27 @@ MMSTART(){ echo -en "${idsCL[LightCyan]}Verifing traffic is routing through VPN... ${idsCL[Default]}" - scip=$(dig +short sc1.scity.us @ns1.scity.us) - mmip=$(dig +short myip.opendns.com @resolver1.opendns.com) + + scip="" + mmip="" + cc=0 + until [ "${scip}" != "" ] && [ "${mmip}" != "" ]; do + scip=$(dig +short sc1.scity.us @ns1.scity.us) + mmip=$(dig +short myip.opendns.com @resolver1.opendns.com) + if ([ "${scip}" = "" ] || [ "${mmip}" = "" ]) && [ ${cc} -eq 10 ]; then + echo -e "${idsCL[Red]}Cannot get an WAN address, restarting system!${idsCL[Default]}" + echo "$(date) - Cannot get an WAN address, restarting system scip(${scip}) mmip(${mmip})" >> $logfile + [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile + [ $SENDNOTICE = true ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net + MMSTOP + sleep 2m + "${VPN_START[@]}" + sleep 1m + rm -f /opt/mm.stop + exit 1 + fi + sleep 1s + done if [ "${scip}" != "${mmip}" ]; then echo -e "${idsCL[Green]} done${idsCL[Default]}" else @@ -120,7 +139,7 @@ MMSTART(){ [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile [ $SENDNOTICE = true ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net MMSTOP - sleep 1m + sleep 2m "${VPN_START[@]}" sleep 1m rm -f /opt/mm.stop @@ -250,7 +269,7 @@ MMSTATUS(){ echo echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" MMSTOP - sleep 10s + sleep 30s MMSTART start fi @@ -264,7 +283,7 @@ MMSTATUS(){ echo echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" MMSTOP - sleep 10s + sleep 30s MMSTART start fi