Update mm-scripts.sh

This commit is contained in:
2022-12-31 16:37:42 -06:00
parent dfafb4bc99
commit 974ef8a143

View File

@@ -4,7 +4,6 @@
action="$1"
VERBOSE=true
SENDNOTICE=true
if [ -f /opt/idssys/settings/mediamanager.conf ]; then
mv /opt/idssys/settings/mediamanager.conf /opt/idssys/mediamanager/settings.conf
@@ -37,6 +36,7 @@ MMSTART(){
GOFORSTART=true;
elif [ "${1}" = "check" ] && [ "$(systemctl is-active openvpn)" != "active" ]; then
GOFORSTART=true;
[ "${EMAIL_NOTICE}" != "" ] && echo "2nd Failure, will try and restart the VPN" | mail -s "Media Management systems started" ${EMAIL_NOTICE}
else
GOFORSTART=false;
fi
@@ -63,7 +63,7 @@ MMSTART(){
if [ -f /opt/mm.vpn.fail ]; then
echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}"
echo "$(date) - VPN Failure #2 - restarting system" >> $logfile
[ $SENDNOTICE = true ] && echo "2nd Failure, will try and restart the VPN" | mail -s "VPN Failure" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "2nd Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail2
rm -f /opt/mm.vpn.fail
MMSTOP
@@ -75,14 +75,14 @@ MMSTART(){
exit 1
elif [ -f /opt/mm.vpn.fail2 ]; then
echo "$(date) - VPN Failure #3 - Shutting down Media Management systems" >> $logfile
[ $SENDNOTICE = true ] && echo "Final Failure, shutting down system" | mail -s "VPN Failure" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "Final Failure, shutting down system" | mail -s "VPN Failure" ${EMAIL_NOTICE}
MMSTOP
[ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1
else
echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}"
echo "$(date) - VPN Failure #1 - restarting system" >> $logfile
[ $SENDNOTICE = true ] && echo "1st Failure, will try and restart the VPN" | mail -s "VPN Failure" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "1st Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail
MMSTOP
sleep 30s
@@ -117,7 +117,7 @@ MMSTART(){
if [ "${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 = true ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail
MMSTOP
sleep 2m
@@ -145,7 +145,7 @@ MMSTART(){
echo -e "${idsCL[Red]}Cannot get an WAN address, restarting system!${idsCL[Default]}"
echo "$(date) - Cannot get an WAN address, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile
[ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
[ $SENDNOTICE = true ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail
MMSTOP
sleep 2m
@@ -165,7 +165,7 @@ MMSTART(){
echo -e "${idsCL[Red]}Traffic is not routing through VPN, restarting system!${idsCL[Default]}"
echo "$(date) - Traffic is not routing through VPN, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile
[ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
[ $SENDNOTICE = true ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail
MMSTOP
sleep 2m
@@ -188,7 +188,7 @@ MMSTART(){
fi
if [ -f /opt/mm.vpn.fail* ]; then
echo "$(date) - VPN issue has been fixed" >> $logfile
[ $SENDNOTICE = true ] && echo "VPN issue has been fixed" | mail -s "Services Restored" 9208839613@mms.att.net
[ "${EMAIL_NOTICE}" != "" ] && echo "VPN issue has been fixed" | mail -s "Services Restored" ${EMAIL_NOTICE}
rm -f /opt/mm.vpn.fail*
fi
rm -f /opt/mm.stop