diff --git a/mm-scripts.sh b/mm-scripts.sh index 36e923d..e8c4b16 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -328,14 +328,10 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf if [ "${MM_SERVICE_PORTS[${srvc}]}" != "" ]; then 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 10 ]; then + until [ "${checkport}" != "" ]; do + if [ ${cc} -eq 10 ]; then if [ -f ${MMFOLDER}/mm.${srvc}.starting ]; then msg="${srvc^} Service is not starting properly, will try and update" echo -e "${idsCL[Red]}${msg}${idsCL[Default]}" @@ -353,12 +349,14 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf else touch ${MMFOLDER}/mm.${srvc}.starting fi - checked="" + checkport="go" fi - ((cc=${cc}+1)) - sleep 1s - checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) + if [ "${checkport}" != "go" ]; then + checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) + ((cc=${cc}+1)) + sleep 1s + fi done @@ -432,11 +430,11 @@ MMSTOP(){ checked=false until [ "${checked}" = "" ]; do for srvc in "${SERVICES_CHECK[@]}"; do - if ! lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t >/dev/null; then - checked="" - else - checked=false - fi + checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) + until [ "${checkport}" != "" ]; do + sleep 1s + checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t) + done done done echo -e "${idsCL[Green]}Done${idsCL[Default]}"