new file location

This commit is contained in:
2023-01-01 11:30:25 -06:00
parent ca025aa280
commit d33e37c37e
2 changed files with 34 additions and 34 deletions

View File

@@ -34,7 +34,7 @@ MMSTART(){
[ $VERBOSE = true ] && chktmstart=`date +%s` [ $VERBOSE = true ] && chktmstart=`date +%s`
if [ "${1}" = "start" ] || [ "${1}" = "" ]; then if [ "${1}" = "start" ] || [ "${1}" = "" ]; then
GOFORSTART=true; GOFORSTART=true;
elif [ "${1}" = "check" ] && [ "$(systemctl is-active openvpn)" != "active" ] && [ ! -f /opt/mm.vpn* ]; then elif [ "${1}" = "check" ] && [ "$(systemctl is-active openvpn)" != "active" ] && [ ! -f /opt/idssys/mediamanager/mm.vpn* ]; then
GOFORSTART=true; GOFORSTART=true;
[ "${EMAIL_NOTICE}" != "" ] && echo "" | mail -s "Starting Media Management Systems" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "" | mail -s "Starting Media Management Systems" ${EMAIL_NOTICE}
echo "$(date) - Starting Media Management system - (openvpn not running)" >> $logfile echo "$(date) - Starting Media Management system - (openvpn not running)" >> $logfile
@@ -62,20 +62,20 @@ MMSTART(){
OUT=$(ip link | grep "$VPN_INTERFACE") OUT=$(ip link | grep "$VPN_INTERFACE")
if [ ${#OUT} = 0 ]; then if [ ${#OUT} = 0 ]; then
if [ -f /opt/mm.vpn.fail ]; then if [ -f /opt/idssys/mediamanager/mm.vpn.fail ]; then
echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}" echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}"
echo "$(date) - VPN Failure #2 - restarting system" >> $logfile echo "$(date) - VPN Failure #2 - restarting system" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "2nd Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "2nd Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail2 touch /opt/idssys/mediamanager/mm.vpn.fail2
rm -f /opt/mm.vpn.fail rm -f /opt/idssys/mediamanager/mm.vpn.fail
MMSTOP MMSTOP
sleep 5m sleep 5m
"${VPN_START[@]}" & "${VPN_START[@]}" &
sleep 30s sleep 30s
rm -f /opt/mm.stop rm -f /opt/idssys/mediamanager/mm.stop
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
elif [ -f /opt/mm.vpn.fail2 ]; then elif [ -f /opt/idssys/mediamanager/mm.vpn.fail2 ]; then
echo "$(date) - VPN Failure #3 - Shutting down Media Management systems" >> $logfile echo "$(date) - VPN Failure #3 - Shutting down Media Management systems" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Final Failure, shutting down system" | mail -s "VPN Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Final Failure, shutting down system" | mail -s "VPN Failure" ${EMAIL_NOTICE}
MMSTOP MMSTOP
@@ -85,12 +85,12 @@ MMSTART(){
echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}" echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}"
echo "$(date) - VPN Failure #1 - restarting system" >> $logfile echo "$(date) - VPN Failure #1 - restarting system" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "1st Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "1st Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail touch /opt/idssys/mediamanager/mm.vpn.fail
MMSTOP MMSTOP
sleep 30s sleep 30s
"${VPN_START[@]}" & "${VPN_START[@]}" &
sleep 30s sleep 30s
rm -f /opt/mm.stop rm -f /opt/idssys/mediamanager/mm.stop
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -125,12 +125,12 @@ MMSTART(){
echo -e "${idsCL[Red]}Could not confirm default routes, restarting system!${idsCL[Default]}" echo -e "${idsCL[Red]}Could not confirm default routes, restarting system!${idsCL[Default]}"
echo "$(date) - Could not confirm default routes, restarting system" >> $logfile echo "$(date) - Could not confirm default routes, restarting system" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail touch /opt/idssys/mediamanager/mm.vpn.fail
MMSTOP MMSTOP
sleep 2m sleep 2m
"${VPN_START[@]}" & "${VPN_START[@]}" &
sleep 1m sleep 1m
rm -f /opt/mm.stop rm -f /opt/idssys/mediamanager/mm.stop
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -155,12 +155,12 @@ MMSTART(){
echo "$(date) - Cannot get an WAN address, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile 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 [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE} [ "${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 touch /opt/idssys/mediamanager/mm.vpn.fail
MMSTOP MMSTOP
sleep 2m sleep 2m
"${VPN_START[@]}" & "${VPN_START[@]}" &
sleep 1m sleep 1m
rm -f /opt/mm.stop rm -f /opt/idssys/mediamanager/mm.stop
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -175,12 +175,12 @@ MMSTART(){
echo "$(date) - Traffic is not routing through VPN, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile 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 [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/mm.vpn.fail touch /opt/idssys/mediamanager/mm.vpn.fail
MMSTOP MMSTOP
sleep 2m sleep 2m
"${VPN_START[@]}" & "${VPN_START[@]}" &
sleep 1m sleep 1m
rm -f /opt/mm.stop rm -f /opt/idssys/mediamanager/mm.stop
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -195,12 +195,12 @@ MMSTART(){
#echo -e "${idsCL[LightCyan]}It may take a couple of minutes before all services fully start${idsCL[Default]}" #echo -e "${idsCL[LightCyan]}It may take a couple of minutes before all services fully start${idsCL[Default]}"
MMSTATUS MMSTATUS
fi fi
if [ -f /opt/mm.vpn.fail* ]; then if [ -f /opt/idssys/mediamanager/mm.vpn.fail* ]; then
echo "$(date) - VPN issue has been fixed" >> $logfile echo "$(date) - VPN issue has been fixed" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "VPN issue has been fixed" | mail -s "Services Restored" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "VPN issue has been fixed" | mail -s "Services Restored" ${EMAIL_NOTICE}
rm -f /opt/mm.vpn.fail* rm -f /opt/idssys/mediamanager/mm.vpn.fail*
fi fi
rm -f /opt/mm.stop rm -f /opt/idssys/mediamanager/mm.stop
echo -e "${idsCL[Green]}All systems are go!${idsCL[Default]}" echo -e "${idsCL[Green]}All systems are go!${idsCL[Default]}"
if [ "${1}" = "start" ] || [ "${1}" = "" ]; then if [ "${1}" = "start" ] || [ "${1}" = "" ]; then
echo "$(date) - Media Management systems started" >> $logfile echo "$(date) - Media Management systems started" >> $logfile
@@ -215,14 +215,14 @@ MMSTART(){
} }
MMSTOP(){ MMSTOP(){
if [ -f /opt/mm.stop ]; then if [ -f /opt/idssys/mediamanager/mm.stop ]; then
echo -e "${idsCL[Yellow]}The system is already stopped, will verify anyway...${idsCL[Default]}" echo -e "${idsCL[Yellow]}The system is already stopped, will verify anyway...${idsCL[Default]}"
else else
echo -e "${idsCL[Green]}Stopping System...${idsCL[Default]}" echo -e "${idsCL[Green]}Stopping System...${idsCL[Default]}"
echo echo
fi fi
echo echo
touch /opt/mm.stop touch /opt/idssys/mediamanager/mm.stop
echo -en "${idsCL[LightCyan]}Stopping Services... ${idsCL[Default]}" echo -en "${idsCL[LightCyan]}Stopping Services... ${idsCL[Default]}"
#for srvc in "${SERVICES_CHECK[@]}"; do #for srvc in "${SERVICES_CHECK[@]}"; do
for i in "${!NM_SERVICES[@]}"; do for i in "${!NM_SERVICES[@]}"; do
@@ -318,7 +318,7 @@ MMSTATUS(){
echo -e "${idsCL[Green]}Matches 0.0.0.0 route${idsCL[Default]}" echo -e "${idsCL[Green]}Matches 0.0.0.0 route${idsCL[Default]}"
else else
echo -e "${idsCL[Red]}Does not match 0.0.0.0 route${idsCL[Default]}" echo -e "${idsCL[Red]}Does not match 0.0.0.0 route${idsCL[Default]}"
if [ ! -f /opt/mm.stop ]; then if [ ! -f /opt/idssys/mediamanager/mm.stop ]; then
echo echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP MMSTOP
@@ -334,7 +334,7 @@ MMSTATUS(){
echo -e "${idsCL[Green]}Good${idsCL[Default]}" echo -e "${idsCL[Green]}Good${idsCL[Default]}"
else else
echo -e "${idsCL[Red]}Not Good${idsCL[Default]}" echo -e "${idsCL[Red]}Not Good${idsCL[Default]}"
if [ ! -f /opt/mm.stop ]; then if [ ! -f /opt/idssys/mediamanager/mm.stop ]; then
echo echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP MMSTOP
@@ -353,27 +353,27 @@ MMSTATUS(){
echo echo
} }
if [ ! -f /opt/mm.update.stop ]; then if [ ! -f /opt/idssys/mediamanager/mm.update.stop ]; then
if [ -f /opt/mm.stop ]; then if [ -f /opt/idssys/mediamanager/mm.stop ]; then
stoppedsince=`date +%s`-$(stat -c %Y /opt/mm.stop) stoppedsince=`date +%s`-$(stat -c %Y /opt/idssys/mediamanager/mm.stop)
stopmsg="${idsCL[Yellow]}The system has currently been stopped for '$(SHOW_TIME ${stoppedsince})'.\n${idsCL[LightCyan]}(You'll need to run \"mm start\" to start services again)${idsCL[Default]}" stopmsg="${idsCL[Yellow]}The system has currently been stopped for '$(SHOW_TIME ${stoppedsince})'.\n${idsCL[LightCyan]}(You'll need to run \"mm start\" to start services again)${idsCL[Default]}"
fi fi
case $action in case $action in
start | check) start | check)
if [ -f /opt/mm.stop ] && [ "${action}" = "check" ]; then if [ -f /opt/idssys/mediamanager/mm.stop ] && [ "${action}" = "check" ]; then
echo -e "${stopmsg}" echo -e "${stopmsg}"
# [ $VERBOSE = true ] && echo "$(date) - Not checking, system has been stopped" >> $logfile # [ $VERBOSE = true ] && echo "$(date) - Not checking, system has been stopped" >> $logfile
echo echo
exit 1 exit 1
fi fi
touch /opt/mm.stop touch /opt/idssys/mediamanager/mm.stop
MMSTART ${action};; MMSTART ${action};;
stop) stop)
MMSTOP;; MMSTOP;;
restart) restart)
if [ -f /opt/mm.stop ]; then if [ -f /opt/idssys/mediamanager/mm.stop ]; then
echo -e "${stopmsg}" echo -e "${stopmsg}"
echo echo
exit 1 exit 1
@@ -383,7 +383,7 @@ if [ ! -f /opt/mm.update.stop ]; then
MMSTART;; MMSTART;;
status) status)
if [ -f /opt/mm.stop ]; then if [ -f /opt/idssys/mediamanager/mm.stop ]; then
echo -e "${stopmsg}" echo -e "${stopmsg}"
echo echo
fi fi

12
run.sh
View File

@@ -3,16 +3,16 @@
source /opt/idssys/defaults/colors.inc source /opt/idssys/defaults/colors.inc
if [ -f /opt/mm.checking ]; then if [ -f /opt/idssys/mediamanager/mm.checking ]; then
fd=$(( `date +%s` - `stat -L --format %Y /opt/mm.checking` )) fd=$(( `date +%s` - `stat -L --format %Y /opt/idssys/mediamanager/mm.checking` ))
if [ ${fd} -gt 900 ]; then if [ ${fd} -gt 900 ]; then
rm -f /opt/mm.checking rm -f /opt/idssys/mediamanager/mm.checking
else else
echo -e "${idsCL[LightCyan]}Try again later, 'mm' program currently in use...${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Try again later, 'mm' program currently in use...${idsCL[Default]}"
fi fi
fi fi
if [ ! -f /opt/mm.checking ]; then if [ ! -f /opt/idssys/mediamanager/mm.checking ]; then
touch /opt/mm.checking touch /opt/idssys/mediamanager/mm.checking
source /opt/idssys/defaults/default.inc source /opt/idssys/defaults/default.inc
source /opt/idssys/mediamanager/defaults.inc source /opt/idssys/mediamanager/defaults.inc
@@ -71,7 +71,7 @@ if [ ! -f /opt/mm.checking ]; then
fi fi
fi fi
/opt/idssys/mediamanager/mm-scripts.sh ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} /opt/idssys/mediamanager/mm-scripts.sh ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14}
rm -f /opt/mm.checking rm -f /opt/idssys/mediamanager/mm.checking
fi fi
exit 0 exit 0