mirror of https://gitlab.com/hp3icc/emq-TE1.git
Update data-mmdvm.sh
This commit is contained in:
parent
07960bff40
commit
1bf439ab83
|
|
@ -130,19 +130,23 @@ cat > /opt/mmvm.sh <<- "EOFXE"
|
|||
last_update=0
|
||||
|
||||
while true; do
|
||||
# Verificamos si alguno de los servicios está activo
|
||||
if systemctl is-active mmdvmh.service nxdn2dmr.service ysf2dmr.service P25Reflector.service mmdvm_bridgeP25b.service p25gatewayP25b.service; then
|
||||
# Si está activo y ha pasado al menos 12 horas desde la última actualización, mostramos "actualizando"
|
||||
# Verificamos si hay algún servicio activo que comience con "mmdvm", "p25" o "P25"
|
||||
active_services=$(systemctl list-units --type=service --state=active | grep -E 'mmdvm|nxdn|ysf|dmr|p25|P25')
|
||||
|
||||
if [[ -n "$active_services" ]]; then
|
||||
# Si hay servicios activos y ha pasado al menos 12 horas desde la última actualización, ejecutamos el script
|
||||
current_time=$(date +%s)
|
||||
if [ $((current_time - last_update)) -ge 43200 ]; then
|
||||
echo "Actualizando archivos..."
|
||||
/usr/bin/python3 /opt/data-mmdvm.py
|
||||
# Actualizamos el tiempo de la última actualización
|
||||
last_update=$current_time
|
||||
fi
|
||||
else
|
||||
# Si todos los servicios están inactivos, limpiamos la variable last_update
|
||||
# Si no hay servicios activos, reiniciamos el tiempo de última actualización
|
||||
last_update=0
|
||||
fi
|
||||
|
||||
sleep 60 # Espera 1 minuto antes de la próxima verificación
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue