Update mm-scripts.sh

This commit is contained in:
2023-03-26 20:11:22 -05:00
parent 45c76a6acb
commit b498f8f04a

View File

@@ -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