This commit is contained in:
2023-03-04 23:03:47 -06:00
parent bc21928e65
commit 05e41b82a3
2 changed files with 66 additions and 94 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERS='2.02252023'
VERS='2.03042023'
MMFOLDER="/opt/idssys/mediamanager"
MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
@@ -8,7 +8,6 @@ MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
noheader=' check noup stop '
declare -A NM_SERVICES
NM_SERVICES['nordvpn']='NordVPN (VPN Tunnel)'
NM_SERVICES['openvpn']='OpenVPN (TorGuard VPN Tunnel)'
NM_SERVICES['wireguard']='WireGuard (TorGuard VPN Tunnel)'
NM_SERVICES['lidarr']='Lidarr (Music Manager)'
@@ -21,19 +20,14 @@ NM_SERVICES['qbittorrent']='qBittorrent (Torrent Downloader)'
NM_SERVICES['snap.tautulli.tautulli']='Tautulli (Plex Stats)'
NM_SERVICES['ombi']='Ombi (Download Requester)'
#if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"10.10.1.24"* ]]; then
if [ "${VPN_INTERFACE}" = "nordlynx" ]; then
if [ "${VPN_INTERFACE}" = "tun0" ]; then #openvpn
VPN_START=(/bin/systemctl start openvpn)
VPN_STOP=(/bin/systemctl stop openvpn)
else #default wireguard
VPN_START=(/usr/bin/wg-quick up ${VPN_INTERFACE})
VPN_STOP=(/usr/bin/wg-quick down ${VPN_INTERFACE})
# VPN_START=(/usr/bin/nordvpn connect United_States Chicago)
# VPN_START=(/usr/bin/nordvpn connect us9316)
VPN_START=(/usr/bin/nordvpn c double_vpn)
VPN_STOP=(/usr/bin/nordvpn disconnect)
else
#VPN_START=(/bin/systemctl start openvpn)
#VPN_STOP=(/bin/systemctl stop openvpn)
VPN_START=(/usr/bin/wg-quick up wg-torguard)
VPN_STOP=(/usr/bin/wg-quick down wg-torguard)
fi
DEBUGLOGSTOP(){

View File

@@ -380,12 +380,6 @@ MMSTOP(){
}
MMSTATUS(){
# if [[ ${MMSRV} == *"10.10.1.24"* ]]; then
# statusArray=("nordvpn")
# else
# statusArray=("openvpn")
# fi
#statusArray=(nordvpn openvpn)
statusArray=(wireguard)
statusArray+=(${SERVICES_CHECK[@]})
echo
@@ -395,86 +389,70 @@ MMSTATUS(){
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${NM_SERVICES[${srvc}]}$spc: "
# if [[ ${MMSRV} == *"10.10.1.24"* ]] && [ "${srvc}" = "nordvpn" ]; then
if [ "${srvc}" = "nordvpn" ]; then
if [[ "$(nordvpn status)" == *"Status: Disconnected"* ]]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
else
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
DIVIDER . lightBlue
nordvpn status
DIVIDER . lightBlue
echo ""
fi
if [ "$(systemctl is-active ${srvc})" != "active" ] && [ "${srvc}" != "wireguard" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
elif [ "${srvc}" == "wireguard" ] && [ "$(ip link | grep $VPN_INTERFACE)" == "" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
else
if [ "$(systemctl is-active ${srvc})" != "active" ] && [ "${srvc}" != "wireguard" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
#OUT=$(ip link | grep "$VPN_INTERFACE")
#if [ ${#OUT} = 0 ]; then
elif [ "${srvc}" == "wireguard" ] && [ "$(ip link | grep $VPN_INTERFACE)" == "" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
else
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
if [[ ${srvc} == *"vpn"* ]] || [[ ${srvc} == *"wireguard"* ]]; then
zerogw=$(ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
echo -e " |- 0.0.0.0 gateway : ${idsCL[Green]}$zerogw${idsCL[Default]}"
echo -en " |- DEFAULT gateway : "
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
if [ ! -f ${MMFOLDER}/mm.stop ]; then
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
if [[ ${srvc} == *"vpn"* ]] || [[ ${srvc} == *"wireguard"* ]]; then
zerogw=$(ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
echo -e " |- 0.0.0.0 gateway : ${idsCL[Green]}$zerogw${idsCL[Default]}"
echo -en " |- DEFAULT gateway : "
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
if [ ! -f ${MMFOLDER}/mm.stop ]; then
echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP
echo -en "${idsCL[LightCyan]}Pausing for 30secs... ${idsCL[Default]}"
sleep 30s
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
MMSTART
echo -e " ${NM_SERVICES[wireguard]} : ${idsCL[Green]}Running${idsCL[Default]}"
zerogw=$(ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
echo -e " |- 0.0.0.0 gateway : ${idsCL[Green]}$zerogw${idsCL[Default]}"
echo -en " |- DEFAULT gateway : "
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP
echo -en "${idsCL[LightCyan]}Pausing for 30secs... ${idsCL[Default]}"
sleep 30s
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
MMSTART
echo -e " ${NM_SERVICES[wireguard]} : ${idsCL[Green]}Running${idsCL[Default]}"
zerogw=$(ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
echo -e " |- 0.0.0.0 gateway : ${idsCL[Green]}$zerogw${idsCL[Default]}"
echo -en " |- DEFAULT gateway : "
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
echo
if [ ! -f ${MMFOLDER}/mm.checking ]; then
echo -e "${idsCL[LightCyan]}Shutting down system... fix yo shit${idsCL[Default]}"
MMSTOP
fi
if [ ! -f ${MMFOLDER}/mm.checking ]; then
echo -e "${idsCL[LightCyan]}Shutting down system... fix yo shit${idsCL[Default]}"
MMSTOP
fi
fi
fi
echo -en " |- Verify routing through VPN : "
scip=$(dig +short sc1.scity.us @9.9.9.9)
mmip=$(dig +short myip.opendns.com @resolver1.opendns.com)
if [ "${scip}" != "${mmip}" ]; then
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not Good${idsCL[Default]}"
if [ ! -f ${MMFOLDER}/mm.stop ] && [ ! -f ${MMFOLDER}/mm.checking ]; then
echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP
echo -en "${idsCL[LightCyan]}Pausing for 30secs... ${idsCL[Default]}"
sleep 30s
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
MMSTART
fi
fi
echo
fi
echo -en " |- Verify routing through VPN : "
scip=$(dig +short sc1.scity.us @9.9.9.9)
mmip=$(dig +short myip.opendns.com @resolver1.opendns.com)
if [ "${scip}" != "${mmip}" ]; then
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not Good${idsCL[Default]}"
if [ ! -f ${MMFOLDER}/mm.stop ] && [ ! -f ${MMFOLDER}/mm.checking ]; then
echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP
echo -en "${idsCL[LightCyan]}Pausing for 30secs... ${idsCL[Default]}"
sleep 30s
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
MMSTART
fi
fi
echo
fi
fi