From 1d2589e10b27a4e51751997ed7fdff0d3b08423c Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 29 Apr 2023 21:15:56 -0500 Subject: [PATCH] Update mm-scripts.sh --- mm-scripts.sh | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/mm-scripts.sh b/mm-scripts.sh index 02c9145..da5dd94 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -44,7 +44,29 @@ unset IFS cw_spc=40 MMCRONCHECK(){ - [ -f ${MMFOLDER}/mm.stop ] && /usr/local/bin/mm check q >/dev/null 2>&1 || /usr/local/bin/mm check q >> /opt/idssys/mediamanager/logs/outputs.check.log + if [ -f ${MMFOLDER}/mm.stop ]; then + /usr/local/bin/mm check q >/dev/null 2>&1 + else + echo -e "\n\n$(date) - Starting log #############################\n" >> ${outputlogfile} + /usr/local/bin/mm check q >> ${outputlogfile} + echo -e "\n$(date) - Finished log #############################" >> ${outputlogfile} + fi + + if [ $(date +%H)$(date +%u) -eq 4 ] && [ $(date +%H)$(date +%M) -ge 0400 ] && [ $(date +%H)$(date +%M) -le 0405 ] ; then + versup=$(expr `date +%s` - $(stat -c %Y ${MMFOLDER}/vers.info)) + if [ ${vpnuptime} -ge 600 ]; then + /usr/local/bin/mm update-allservices >/dev/null 2>&1 + echo "$(date) - Updated All Services" >> $logfile + } + elif [ $(date +%H)$(date +%M) -ge 0300 ] && [ $(date +%H)$(date +%M) -le 0305 ] ; then + versup=$(expr `date +%s` - $(stat -c %Y ${MMFOLDER}/vers.info)) + if [ ${vpnuptime} -ge 600 ]; then + /usr/local/bin/mm update-allservices >/dev/null 2>&1 + echo "$(date) - Updated All Services" >> $logfile + } + fi + + exit 0 } @@ -1340,15 +1362,19 @@ USAGE(){ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then - [ "${2}" == "q" ] && [ "${action}" == "check" ] && [ ! -f ${MMFOLDER}/mm.stop ] && echo -e "\n\n$(date) - Starting log #############################\n" >> ${outputlogfile} if [ -f ${MMFOLDER}/mm.stop ]; then stoppedsince=`date +%s`-$(stat -c %Y ${MMFOLDER}/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]}" fi case $action in - start | check) - [ "${2}" == "cron" ] && MMCRONCHECK - + clear) echo -e "${idsCL[LightCyan]}Clearing all mm.* files ${idsCL[Default]}"; echo;; + cron) MMCRONCHECK;; + setup) MMSETUP;; + vpninfo) GETVPNINFO;; + speedtest) VPNSPEEDTEST;; + + stop) MMSTOP;; + start | check) if [ -f ${MMFOLDER}/mm.stop ] && [ "${action}" == "check" ]; then if [ "${2}" != "q" ]; then echo -e "${stopmsg}" @@ -1381,9 +1407,6 @@ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then [ ! -f ${MMFOLDER}/mm.stop ] && MMSTART ${action} ${2} [ "${action}" != "status" ] && rm -f ${MMFOLDER}/mm.stop.checking ;; - stop) - MMSTOP - ;; restart) if [ -f ${MMFOLDER}/mm.stop ]; then echo -e "${stopmsg}" @@ -1404,10 +1427,9 @@ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then fi MMSTATUS ${2} ;; - setup) MMSETUP;; - vpninfo) GETVPNINFO;; - speedtest) VPNSPEEDTEST;; + update);; + update-list) SHOWSRVCUPDATES;; update-service) UPDATESERVICE ${2};; update-allservices) # for usrvc in "${SERVICES_CHECK[@]}"; do @@ -1415,8 +1437,7 @@ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then [ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && UPDATESERVICE ${usrvc} ${2} done ;; - update-list) SHOWSRVCUPDATES;; - clear) echo -e "${idsCL[LightCyan]}Clearing all mm.* files ${idsCL[Default]}"; echo;; + *) USAGE;; esac