diff --git a/mm-scripts.sh b/mm-scripts.sh index f392247..c17c20c 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -29,7 +29,7 @@ unset IFS MMSTART(){ [ $VERBOSE = true ] && chktmstart=`date +%s` - if [ "${1}" = "start" ]; then + if [ "${1}" = "start" ] || [ "${1}" = "" ]; then mmsv='Starting' echo echo -en "${idsCL[LightCyan]}Starting the VPN Tunnel ... ${idsCL[Default]}" @@ -52,7 +52,7 @@ MMSTART(){ rm -f /opt/mm.vpn.fail MMSTOP sleep 5m - "${VPN_START[@]}" + "${VPN_START[@]}" & sleep 1m rm -f /opt/mm.stop exit 1 @@ -68,7 +68,7 @@ MMSTART(){ touch /opt/mm.vpn.fail MMSTOP sleep 1m - "${VPN_START[@]}" + "${VPN_START[@]}" & sleep 1m rm -f /opt/mm.stop exit 1 @@ -99,7 +99,7 @@ MMSTART(){ [ $SENDNOTICE = true ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net MMSTOP sleep 2m - "${VPN_START[@]}" + "${VPN_START[@]}" & sleep 1m rm -f /opt/mm.stop exit 1 @@ -125,7 +125,7 @@ MMSTART(){ [ $SENDNOTICE = true ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net MMSTOP sleep 2m - "${VPN_START[@]}" + "${VPN_START[@]}" & sleep 1m rm -f /opt/mm.stop exit 1 @@ -143,7 +143,7 @@ MMSTART(){ [ $SENDNOTICE = true ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" 9208839613@mms.att.net MMSTOP sleep 2m - "${VPN_START[@]}" + "${VPN_START[@]}" & sleep 1m rm -f /opt/mm.stop exit 1 @@ -159,15 +159,19 @@ MMSTART(){ echo -e "${idsCL[LightCyan]}It may take a couple of minutes before all services fully start${idsCL[Default]}" echo fi - if [ "${1}" == "start" ] || [ -f /opt/mm.vpn.fail* ]; then - echo "$(date) - Media services have been restarted" >> $logfile - elif [ "${1}" != "start" ] && [ -f /opt/mm.vpn.fail* ]; then - [ $SENDNOTICE = true ] && echo "Media services have been restarted" | mail -s "Services Restored" 9208839613@mms.att.net + if [ -f /opt/mm.vpn.fail* ]; then + echo "$(date) - VPN issue has been fixed" >> $logfile + if [ "${1}" == "check" ]; then + [ $SENDNOTICE = true ] && echo "VPN issue has been fixed" | mail -s "Services Restored" 9208839613@mms.att.net + fi + rm -f /opt/mm.vpn.fail* fi rm -f /opt/mm.stop - rm -f /opt/mm.vpn.fail* echo echo -e "${idsCL[Green]}All services have been started${idsCL[Default]}" + if [ "${1}" = "start" ] || [ "${1}" = "" ]; then + [ $VERBOSE = true ] && echo "$(date) - All services started" >> $logfile + fi fi echo @@ -285,7 +289,7 @@ MMSTATUS(){ echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" MMSTOP sleep 30s - MMSTART start + MMSTART fi echo -en " |- Verify traffic route to VPN -> : " @@ -299,7 +303,7 @@ MMSTATUS(){ echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" MMSTOP sleep 30s - MMSTART start + MMSTART fi echo @@ -335,7 +339,7 @@ if [ ! -f /opt/mm.update.stop ]; then fi MMSTOP sleep 10s - MMSTART start;; + MMSTART;; status) if [ -f /opt/mm.stop ]; then