From c7e241c223404ea07e95d10e5c8f4a0cd5feb39a Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 30 May 2023 21:48:16 -0500 Subject: [PATCH] update --- defaults.inc | 4 ++-- mm-scripts.sh | 48 ++++++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/defaults.inc b/defaults.inc index 8744cda..a30a7a2 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,13 +1,13 @@ #!/usr/bin/env bash -VERS='3.8.230-05292023' +VERS='3.8.232-05292023' MMFOLDER="/opt/idssys/mediamanager" TMPFOLDER="${MMFOLDER}/.tmp" LOGFOLDER="${MMFOLDER}/logs" [ ! -d ${TMPFOLDER} ] && mkdir ${TMPFOLDER} [ ! -d ${LOGFOLDER} ] && mkdir ${LOGFOLDER} -MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) +MMSRV=$(/bin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) AVAILSERVICES=bazarr,jackett,lidarr,ombi,snap.overseerr.daemon,qbittorrent,radarr,radarr3d,sonarr,snap.tautulli.tautulli UPDATESERVICES=bazarr,jackett,lidarr,ombi,organizr,qbittorrent,radarr,sonarr diff --git a/mm-scripts.sh b/mm-scripts.sh index faf423b..32e6cac 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -73,13 +73,13 @@ MMSTART(){ if [ "${1}" = "start" ] || [ "${1}" = "restart" ] || [ "${1}" = "" ]; then GOFORSTART=true; - elif [ "${1}" == "check" ] && [ "$(/sbin/ip link | grep "${VPN_INTERFACE}")" == "" ] && [ ! -f ${TMPFOLDER}/mm.vpn* ] && [ ! -f ${TMPFOLDER}/vpninfo.* ]; then + elif [ "${1}" == "check" ] && [ "$(/bin/ip link | grep "${VPN_INTERFACE}")" == "" ] && [ ! -f ${TMPFOLDER}/mm.vpn* ] && [ ! -f ${TMPFOLDER}/vpninfo.* ]; then GOFORSTART=true; SENDNOTICE "Starting Media Management Systems" "Fresh Startup" echo "$(date) - Starting Media Management system - (fresh start)" >> $logfile echo -e "${idsCL[LightCyan]}Fresh Startup${idsCL[Default]}" - elif [ "${1}" = "check" ] && [ "$(/sbin/ip link | grep "${VPN_INTERFACE}")" = "" ] && [ -f ${TMPFOLDER}/mm.vpn* ]; then + elif [ "${1}" = "check" ] && [ "$(/bin/ip link | grep "${VPN_INTERFACE}")" = "" ] && [ -f ${TMPFOLDER}/mm.vpn* ]; then GOFORSTART=true; echo "$(date) - Attempting to restart systems after VPN failure..." >> $logfile echo -e "${idsCL[LightCyan]}Attempting to restart systems after VPN failure...${idsCL[Default]}" @@ -93,7 +93,7 @@ MMSTART(){ if [ ${GOFORSTART} = true ]; then mmsv='Starting' echo - OUT=$(/sbin/ip link | grep "${VPN_INTERFACE}") + OUT=$(/bin/ip link | grep "${VPN_INTERFACE}") if [ ${#OUT} = 0 ]; then msg="Setting up the VPN Tunnel config" @@ -130,7 +130,7 @@ MMSTART(){ [ $VERBOSE = true ] && echo "$(date) - ${mmsv} VPN..." >> $logfile - OUT=$(/sbin/ip link | grep "$VPN_INTERFACE") + OUT=$(/bin/ip link | grep "$VPN_INTERFACE") if [ ${#OUT} = 0 ]; then if [ -f ${TMPFOLDER}/mm.vpn.fail ]; then echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}" @@ -168,7 +168,7 @@ MMSTART(){ [ "${1}" == "start" ] && rm -f mm.vpn.fail* - OUT=$(/sbin/ip link | grep "$VPN_INTERFACE") + OUT=$(/bin/ip link | grep "$VPN_INTERFACE") if [ ${#OUT} != 0 ]; then if [ ${GOFORSTART} = true ] || [ "${1}" == "check" ]; then echo -e "${idsCL[Green]}Done${idsCL[Default]}" @@ -192,8 +192,8 @@ MMSTART(){ exit 0 fi - zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) - defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3) + zerogw=$(/bin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) + defaultgw=$(/bin/ip route show | grep default | cut -d' ' -f 3) # if [ "${zerogw}" != "${defaultgw}" ]; then # if [ "${defaultgw}" != "${VPN_INTERFACE}" ]; then @@ -213,8 +213,8 @@ MMSTART(){ echo -e "${idsCL[Green]}Done${idsCL[Default]}" - zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) - defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3) + zerogw=$(/bin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) + defaultgw=$(/bin/ip route show | grep default | cut -d' ' -f 3) fi msg="Verifying default network routes" @@ -224,11 +224,19 @@ MMSTART(){ checked=false cc=0 + until [ "${checked}" = "" ]; do + zerogw=$(/bin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) + defaultgw=$(/bin/ip route show | grep default | cut -d' ' -f 3) if [ "${zerogw}" = "${defaultgw}" ]; then checked="" - fi - if [ "${checked}" == "false" ] && [ ${cc} -eq 10 ]; then + + elif [ "${checked}" == "false" ] && [ ${cc} -ge 2 ]; then + /bin/ip route del default + /bin/ip route add default dev ${VPN_INTERFACE} + SENDNOTICE "MM FIX" "Default route failure, default route re-added" + + elif [ "${checked}" == "false" ] && [ ${cc} -eq 10 ]; then echo -e "${idsCL[Red]}Could not confirm default routes, restarting system!${idsCL[Default]}" echo "$(date) - Could not confirm default routes, restarting system" >> $logfile SENDNOTICE "Network Failure" "Default route failure, will try and restart the VPN" 1 @@ -248,8 +256,7 @@ MMSTART(){ fi ((cc=${cc}+1)) sleep 1s - zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) - defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3) + done echo -e "${idsCL[Green]}Done${idsCL[Default]}" @@ -527,7 +534,7 @@ MMSTOP(){ checked=false until [ "${checked}" = "" ]; do - OUT=$(/sbin/ip link | grep "$VPN_INTERFACE") + OUT=$(/bin/ip link | grep "$VPN_INTERFACE") #OUT=`ip a show $VPN_INTERFACE up` >/dev/null 2>&1 if [ ${#OUT} = 0 ]; then checked="" @@ -541,7 +548,8 @@ MMSTOP(){ until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}" - [ "$(/sbin/ip route show | grep default | cut -d' ' -f 3)" != "10.10.0.1" ] && /bin/ip route add default via 10.10.0.1 && ip route del ${vpn_server_address} + [ "$(/bin/ip route show | grep default | cut -d' ' -f 3)" != "10.10.0.1" ] && /bin/ip route add default via 10.10.0.1 + /bin/ip route del ${vpn_server_address} [ $VERBOSE = true ] && echo "$(date) - Added default route back in" >> $logfile echo -e "${idsCL[Green]}Done${idsCL[Default]}" @@ -588,7 +596,7 @@ MMSTATUS(){ echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" fi - elif [ "${srvc}" == "wireguard" ] && [ "$(/sbin/ip link | grep $VPN_INTERFACE)" == "" ]; then + elif [ "${srvc}" == "wireguard" ] && [ "$(/bin/ip link | grep $VPN_INTERFACE)" == "" ]; then echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" else @@ -600,8 +608,8 @@ MMSTATUS(){ fi if [[ ${srvc} == *"vpn"* ]] || [[ ${srvc} == *"wireguard"* ]]; then - zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) - defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3) + zerogw=$(/bin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) + defaultgw=$(/bin/ip route show | grep default | cut -d' ' -f 3) vpnuptime=$(expr `date +%s` - $(stat -c %Y ${TMPFOLDER}/vpninfo)) msg=" |- ${idsCL[Default]}VPN/Services Uptime" @@ -646,8 +654,8 @@ MMSTATUS(){ c=0; spc=''; spc1=$((${cw_spc}-${#msg}+6)); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -e "${idsCL[White]}${msg}${spc}${idsCL[White]} : ${idsCL[Green]}$(SHOW_TIME ${vpnuptime})${idsCL[Default]}" - zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) - defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3) + zerogw=$(/bin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3) + defaultgw=$(/bin/ip route show | grep default | cut -d' ' -f 3) msg=" |- ${idsCL[Default]}0.0.0.0 Gateway" c=0; spc=''; spc1=$((${cw_spc}-${#msg}+6))