From b498f8f04ae2e3b44835de51dac3f8e295468955 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 26 Mar 2023 20:11:22 -0500 Subject: [PATCH] Update mm-scripts.sh --- mm-scripts.sh | 54 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/mm-scripts.sh b/mm-scripts.sh index f89ad4b..b34f834 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -326,35 +326,37 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf if [ "$(systemctl is-active ${srvc})" != "active" ]; then /bin/systemctl start ${srvc} fi - checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) - - checked=false - tryupdate=false - cc=0 - until [ "${checked}" = "" ]; do - if [ "${checkport}" != "" ]; then - checked="" - fi - if [ "${checked}" == "false" ] && [ ${cc} -eq 15 ]; then - echo -e "${idsCL[Red]}${srvc} Service is not starting properly, will try and update${idsCL[Default]}" - echo "$(date) - ${srvc} Service is not starting properly, will try and update" >> $logfile - SENDNOTICE "${srvc} Service Issue" "${srvc} Service is not starting properly, will try and update" 1 - checked="" - tryupdate="true" - - msg="Updating Service" - c=0; spc=''; spc1=$((${cw_spc}-${#msg})) - until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done - echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}" - fi - ((cc=${cc}+1)) - sleep 1s + if [ "${MM_SERVICE_PORTS[${srvc}]}" != "" ]; then checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) - done + checked=false + tryupdate=false + cc=0 + until [ "${checked}" = "" ]; do + if [ "${checkport}" != "" ]; then + checked="" + fi + if [ "${checked}" == "false" ] && [ ${cc} -eq 3 ]; then + echo -e "${idsCL[Red]}${srvc} Service is not starting properly, will try and update${idsCL[Default]}" + echo "$(date) - ${srvc} Service is not starting properly, will try and update" >> $logfile + SENDNOTICE "${srvc} Service Issue" "${srvc} Service is not starting properly, will try and update" 1 + checked="" + tryupdate="true" + + msg="Updating Service" + c=0; spc=''; spc1=$((${cw_spc}-${#msg})) + until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}" + fi + ((cc=${cc}+1)) + sleep 1s + checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) + + done - if ([ "${checkport}" == "" ] || [ "${tryupdate}" == "true" ]) && [ "${MM_UPDATE_REPO[${srvc}]}" != "" ]; then - UPDATESERVICE ${srvc} >/dev/null 2>&1 + if ([ "${checkport}" == "" ] || [ "${tryupdate}" == "true" ]) && [ "${MM_UPDATE_REPO[${srvc}]}" != "" ]; then + UPDATESERVICE ${srvc} >/dev/null 2>&1 + fi fi done