Update mm-scripts.sh

This commit is contained in:
2023-03-26 19:22:47 -05:00
parent 31a82913eb
commit a052dfbc6f

View File

@@ -325,11 +325,35 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
for srvc in "${SERVICES_CHECK[@]}"; do
if [ "$(systemctl is-active ${srvc})" != "active" ]; then
/bin/systemctl start ${srvc}
sleep 5s
fi
checkport=$(lsof -Pi :${MM_SERVICE_PORTS[${srvc}]} -sTCP:LISTEN -t)
if [ "${checkport}" == "" ] && [ "${MM_UPDATE_REPO[${srvc}]}" != "" ]; then
UPDATESERVICE {$srvc} >/dev/null 2>&1
checked=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
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
fi
done