From 03716923832c1d436f6e4693f535cdaa5c5f35ac Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 22 Apr 2023 21:48:27 -0500 Subject: [PATCH] Update mm-scripts.sh --- mm-scripts.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/mm-scripts.sh b/mm-scripts.sh index 80e8ae3..9fc6fe2 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -13,6 +13,8 @@ source /opt/idssys/defaults/colors.inc source /opt/idssys/defaults/default.inc source /opt/idssys/mediamanager/settings.conf source /opt/idssys/mediamanager/defaults.inc +[ -f ${MMFOLDER}/realwanip ] && source ${MMFOLDER}/realwanip + if [ "${2}" == "q" ]; then unset idsCL idsBG idsST @@ -112,6 +114,9 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}" + echo "REALWANIP=\"$(/usr/bin/dig +short +time=2 myip.opendns.com @208.67.222.222)\"" > ${MMFOLDER}/realwanip + source ${MMFOLDER}/realwanip + "${VPN_START[@]}" >/dev/null 2>&1 sleep 5s else @@ -232,17 +237,15 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}" - scip="" mmip="" cc=0 - until [ "${scip}" != "" ] && [ "${mmip}" != "" ] && [[ "${scip}" != *"connection timed out"* ]] && [[ "${mmip}" != *"connection timed out"* ]]; do - scip=$(/usr/bin/dig +short +time=2 sc1.scity.us @10.10.10.5 -p 5053) + until [ "${REALWANIP}" != "" ] && [ "${mmip}" != "" ] && [[ "${REALWANIP}" != *"connection timed out"* ]] && [[ "${mmip}" != *"connection timed out"* ]]; do # mmip=$(/usr/bin/dig +short myip.opendns.com @resolver1.opendns.com) mmip=$(/usr/bin/dig +short +time=2 myip.opendns.com @208.67.222.222) if [ ${cc} -eq 10 ]; then echo 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 + echo "$(date) - Cannot get an WAN address, restarting system! wanip(${REALWANIP}) vpnip(${mmip})" >> $logfile [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile SENDNOTICE "Network Failure" "Cannot get an WAN address, will try and restart the VPN" 1 touch ${MMFOLDER}/mm.vpn.fail @@ -257,13 +260,13 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf ((cc=${cc}+1)) sleep 1s done - if [ "${scip}" != "${mmip}" ]; then + if [ "${REALWANIP}" != "${mmip}" ]; then echo -e "${idsCL[Green]}Done${idsCL[Default]}" [ $VERBOSE = true ] && echo "$(date) - WAN Address: ${mmip} - GW Address: ${defaultgw}" >> $logfile else echo echo -e "${idsCL[Red]}Traffic is not routing through VPN, restarting system!${idsCL[Default]}" - echo "$(date) - Traffic is not routing through VPN, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile + echo "$(date) - Traffic is not routing through VPN, restarting system! wanip(${REALWANIP}) vpnip(${mmip})" >> $logfile [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile SENDNOTICE "Network Failure" "Traffic route failure, will try and restart the VPN" 1 touch ${MMFOLDER}/mm.vpn.fail @@ -516,6 +519,7 @@ MMSTOP(){ echo -e "${idsCL[Green]}Done${idsCL[Default]}" rm -f ${MMFOLDER}/vpninfo* + rm -f ${MMFOLDER}/realwanip rm -f ${MMFOLDER}/mm.noservices* rm -f ${MMFOLDER}/mm.plexmount.fail* rm -f ${MMFOLDER}/mm.stop.checking @@ -629,10 +633,9 @@ MMSTATUS(){ until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[White]}${msg}${spc}${idsCL[White]} : ${idsCL[Default]}" - scip=$(/usr/bin/dig +short sc1.scity.us @10.10.10.5 -p 5053) # mmip=$(/usr/bin/dig +short myip.opendns.com @resolver1.opendns.com) mmip=$(/usr/bin/dig +short +time=2 myip.opendns.com @208.67.222.222) - if [ "${scip}" != "${mmip}" ]; then + if [ "${REALWANIP}" != "${mmip}" ]; then echo -e "${idsCL[Green]}Good${idsCL[Default]}" else echo -e "${idsCL[Red]}Not Routing${idsCL[Default]}" @@ -650,6 +653,12 @@ MMSTATUS(){ fi fi + msg=" |- ${idsCL[Default]}Real WAN Address" + c=0; spc=''; spc1=$((${cw_spc}-${#msg}+6)) + until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + echo -en "${idsCL[White]}${msg}${spc}${idsCL[White]} : ${idsCL[Default]}" + echo -e "${idsCL[Green]}${mmip}${idsCL[Default]}" + msg=" |- ${idsCL[Default]}VPN WAN Address" c=0; spc=''; spc1=$((${cw_spc}-${#msg}+6)) until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done