Update nodemgmt-scripts.sh

This commit is contained in:
2024-08-05 20:46:20 -05:00
parent d33d53746f
commit a46714e55e

View File

@@ -25,36 +25,40 @@ fi
[ -f ${NM_BACKUP_FOLDER}/templates/*.config ] && rm -f ${NM_BACKUP_FOLDER}/templates/*.config
OFFSITE_STATICROUTE_FIX(){
STSVPN_ADAPTER=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r | grep '10.5.0.0/20' | awk '{print $7}')
echo "'${STSVPN_ADAPTER}'"
if [ "$(CHECK_HOST_QC 10.10.0.1)" != "true" ]; then
if [ "$(CHECK_HOST_QC ${NM_OFFSITE_GW_IP})" != "false" ]; then
if [ "$(CHECK_HOST_QC 10.5.0.1)" != "false" ]; then
STSVPN_ADAPTER=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r | grep '10.5.0.0/20' | awk '{print $7}')
if [ "$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r | grep 10.10.0.0)" = "" ]; then
RUN=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r add 10.10.0.0/16 dev ${NM_OFFSITE_VPN_ADAPTER} 2>&1 >/dev/null)
if [ "${RUN}" == "" ]; then
SENDNOTICE "Static Route to Homesite Missing" "Re-added the static route onto the Offsite UniFi Gateway"
if [ ! -f ${NM_TMPFOLDER}/vpn-tunnel.down2 ]; then
if [ "$(CHECK_HOST_QC 10.10.0.1)" != "true" ]; then
if [ "$(CHECK_HOST_QC ${NM_OFFSITE_GW_IP})" != "false" ]; then
if [ "$(CHECK_HOST_QC 10.5.0.1)" != "false" ]; then
STSVPN_ADAPTER=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r | grep '10.5.0.0/20' | awk '{print $7}')
if [ "$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r | grep 10.10.0.0)" = "" ] && [ "${STSVPN_ADAPTER}" != "" ]; then
RUN=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${NM_OFFSITE_GW_IP} ip r add 10.10.0.0/16 dev ${STSVPN_ADAPTER} 2>&1 >/dev/null)
if [ "${RUN}" == "" ]; then
SENDNOTICE "Static Route to Homesite Missing" "Re-added the static route onto the Offsite UniFi Gateway"
else
SENDNOTICE "ERROR: Static Route to Homesite Missing" "Cannot add the static route onto the Offsite UniFi Gateway" 1
touch ${NM_TMPFOLDER}/vpn-tunnel.down
fi
else
SENDNOTICE "ERROR: Static Route to Homesite Missing" "Cannot add the static route onto the Offsite UniFi Gateway" 1
SENDNOTICE "ERROR: Static Route to Homesite" "The static route exists, but traffic is going nowhere homie" 1
touch ${NM_TMPFOLDER}/vpn-tunnel.down
fi
fi
else
if [ ! -f ${NM_TMPFOLDER}/vpn-tunnel.down ]; then
else
SENDNOTICE "VPN to Homesite Down" "VPN is down, fix your shit first, then I'll fix mine..." 1
touch ${NM_TMPFOLDER}/vpn-tunnel.down
elif [ $(expr `date +%s` - $(stat -c %Y ${NM_TMPFOLDER}/vpn-tunnel.down)) -ge 60 ] && [ ! -f ${NM_TMPFOLDER}/vpn-tunnel.down.sent ]; then
SENDNOTICE "VPN to Homesite Down" "VPN is down, fix your shit first, then I'll fix mine..."
touch ${NM_TMPFOLDER}/vpn-tunnel.down.sent
fi
fi
if [ -f ${NM_TMPFOLDER}/vpn-tunnel.down ] && [ $(expr `date +%s` - $(stat -c %Y ${NM_TMPFOLDER}/vpn-tunnel.down)) -ge 630 ]; then
mv ${NM_TMPFOLDER}/vpn-tunnel.down ${NM_TMPFOLDER}/vpn-tunnel.down2
fi
else
if [ -f ${NM_TMPFOLDER}/vpn-tunnel.down ]; then
SENDNOTICE "VPN to Homesite is Back Up" "VPN Tunnel is up"
rm -f ${NM_TMPFOLDER}/vpn-tunnel.down*
fi
fi
else
if [ -f ${NM_TMPFOLDER}/vpn-tunnel.down ]; then
SENDNOTICE "VPN to Homesite is Back Up" "VPN Tunnel is up"
rm -f ${NM_TMPFOLDER}/vpn-tunnel.down*
fi
elif [ $(expr `date +%s` - $(stat -c %Y ${NM_TMPFOLDER}/vpn-tunnel.down2)) -ge 3630 ]; then
rm -f ${NM_TMPFOLDER}/vpn-tunnel.down2
touch ${NM_TMPFOLDER}/vpn-tunnel.down
fi
}