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

@@ -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