From e557d23436209e9bf91c47a9a9c1adfff9cc64e3 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 3 Jun 2022 18:17:06 -0500 Subject: [PATCH] Update mm-scripts.sh --- mm-scripts.sh | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/mm-scripts.sh b/mm-scripts.sh index 275cb97..c9756b2 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -102,7 +102,8 @@ MMSTART(){ checked="" fi if [ "${checked}" == "false" ] && [ ${cc} -eq 10 ]; then - echo -e "${idsCL[Red]}Could not confirm default routes using the VPN only!${idsCL[Default]}" + echo -e "${idsCL[Red]}Could not confirm default routes, shutting down!${idsCL[Default]}" + echo "$(date) - Could not confirm default routes, shutting down" >> $logfile MMSTOP exit 1 fi @@ -111,6 +112,28 @@ MMSTART(){ done echo -e "${idsCL[Green]} done${idsCL[Default]}" + + echo -en "${idsCL[LightCyan]}Verifing traffic is routing through VPN... ${idsCL[Default]}" + checked=false + cc=0 + until [ "${checked}" = "" ]; do + scip=$(dig +short sc1.scity.us @ns1.scity.us) + mmip=$(dig +short myip.opendns.com @resolver1.opendns.com) + if [ "${scip}" != "${mmip}" ]; then + checked="" + fi + if [ "${checked}" == "false" ] && [ ${cc} -eq 10 ]; then + echo -e "${idsCL[Red]}Traffic is not routing through VPN!${idsCL[Default]}" + echo "$(date) - Traffic is not routing through VPN, shutting down" >> $logfile + MMSTOP + exit 1 + fi + ((cc=${cc}+1)) + sleep 1s + done + echo -e "${idsCL[Green]} done${idsCL[Default]}" + + echo echo -en "${idsCL[LightCyan]}${mmsv} Services... ${idsCL[Default]}" for srvc in "${SERVICES_CHECK[@]}"; do @@ -133,13 +156,14 @@ MMSTART(){ echo -e "${idsCL[Red]} failed${idsCL[Default]}" echo echo -e "${idsCL[Red]}Could not start the VPN, fix your shit...${idsCL[Default]}" + echo "$(date) - Could not start the VPN, fix your shit..." >> $logfile fi echo } MMSTOP(){ if [ -f /opt/mm.stop ]; then - echo -e "${idsCL[Yellow]}The system is already stopped, will verify anyway,..${idsCL[Default]}" + echo -e "${idsCL[Yellow]}The system is already stopped, will verify anyway...${idsCL[Default]}" else echo -e "${idsCL[Green]}Stopping System...${idsCL[Default]}" echo @@ -158,17 +182,17 @@ MMSTOP(){ if ! lsof -Pi :5656 -sTCP:LISTEN -t >/dev/null; then #sonarr if ! lsof -Pi :5858 -sTCP:LISTEN -t >/dev/null; then #qbittorrent if ! lsof -Pi :8181 -sTCP:LISTEN -t >/dev/null; then #tautulli - if ! lsof -Pi :8686 -sTCP:LISTEN -t >/dev/null; then #jackett + if ! lsof -Pi :8686 -sTCP:LISTEN -t >/dev/null; then #lidarr if ! lsof -Pi :9117 -sTCP:LISTEN -t >/dev/null; then #jackett checked="" - fi - fi - fi - fi - fi - fi - fi - fi + fi #/jackett + fi #/lidarr + fi #/tautulli + fi #/qbittorrent + fi #/sonarr + fi #/radarr3d + fi #/radarr + fi #/ombi done echo -e "${idsCL[Green]} done${idsCL[Default]}"