From aecf3fc7db6056393b989694ce5f7caf2563d21e Mon Sep 17 00:00:00 2001 From: Esteban Mackay Q Date: Tue, 17 Oct 2023 23:26:12 -0500 Subject: [PATCH] update --- README.md | 2 +- install.sh | 1 + install/mmdvm.sh | 5 ----- install/p25.sh | 2 +- install/p25cross.sh | 4 ++-- install/ysf2dmr.sh | 2 +- menu/data-mmdvm.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++ menu/menu-mmdvm | 6 +----- menu/menu-nxdn2dmr | 6 +----- menu/menu-p25r | 6 ++++-- menu/menu-ysf2dmr | 6 +----- 11 files changed, 62 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 4f730c6..5923c6e 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Imagen para raspberry, proyecto emq-TE1 - recomendado para cualquier Raspberry : Puede instalar en su sistema operativo (Ubuntu , raspberry , Debian ) utilizando el Bash de auto instalación desde su consola terminal con permisos de super usuario, importante su sistema operativo debe tener instalado sudo y curl antes de utilizar el Bash de auto instalación . -* Ultima revision de scrip 16/10/2023 +* Ultima revision de scrip 17/10/2023 * Bash de auto instalación : diff --git a/install.sh b/install.sh index af0edd2..8d41d22 100644 --- a/install.sh +++ b/install.sh @@ -159,6 +159,7 @@ bash -c "$(curl -fsSL https://gitlab.com/hp3icc/fdmr/-/raw/main/fdmr-bridge.sh)" bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/nxdn2dmr.sh)" && bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/p25.sh)" && bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/p25cross.sh)" && +bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/data-mmdvm.sh)" echo install menu bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/menu)" && bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/menu-aprs)" && diff --git a/install/mmdvm.sh b/install/mmdvm.sh index 2ca633c..aab969f 100644 --- a/install/mmdvm.sh +++ b/install/mmdvm.sh @@ -624,11 +624,6 @@ WantedBy=multi-user.target EOF # ##################################################################################################################### -bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/data-mmdvm.sh)" - - -############################################################################################################################### - systemctl daemon-reload diff --git a/install/p25.sh b/install/p25.sh index 02de7e0..6eaad12 100644 --- a/install/p25.sh +++ b/install/p25.sh @@ -53,7 +53,7 @@ sudo rm -r /opt/DVReflectors #sudo chmod +x /usr/local/bin/P25Reflector.sh #sudo sed -i "s/PROG_ARGS=.*/PROG_ARGS=\"\/opt\/P25Reflector\/P25Reflector.ini\"/g" /usr/local/bin/P25Reflector.sh sudo sed -i "s/FilePath=.*/FilePath=\/var\/log\/P25Reflector/g" /opt/P25Reflector/P25Reflector.ini -sudo sed -i "s/Name=.*/Name=\/var\/lib\/mmdvm\/DMRIds.dat/g" /opt/P25Reflector/P25Reflector.ini +sudo sed -i "s/Name=.*/Name=\/opt\/data-files\/DMRIds.dat/g" /opt/P25Reflector/P25Reflector.ini sudo sed -i "s/Daemon=.*/Daemon=0/g" /opt/P25Reflector/P25Reflector.ini cp /opt/P25Reflector/P25Reflector.ini /etc/P25Reflector.ini #/usr/local/bin/P25Reflector.sh stop diff --git a/install/p25cross.sh b/install/p25cross.sh index c3c07b6..1bb106a 100644 --- a/install/p25cross.sh +++ b/install/p25cross.sh @@ -135,7 +135,7 @@ FilePath=/var/log/mmdvm FileRoot=MMDVM_Bridge [DMR Id Lookup] -File=/var/lib/mmdvm/DMRIds.dat +File=/opt/data-files/DMRIds.dat Time=24 [NXDN Id Lookup] @@ -227,7 +227,7 @@ Debug=0 Daemon=0 [Id Lookup] -Name=/var/lib/mmdvm/DMRIds.dat +Name=/opt/data-files/DMRIds.dat Time=24 [Voice] diff --git a/install/ysf2dmr.sh b/install/ysf2dmr.sh index 5fd926f..85f38f3 100644 --- a/install/ysf2dmr.sh +++ b/install/ysf2dmr.sh @@ -195,7 +195,7 @@ Daemon=0 [DMR Network] Id=000000000 -#XLXFile=/opt/data-files/XLXHosts.txtt +#XLXFile=/opt/data-files/XLXHosts.txt #XLXReflector=744 #XLXModule=A StartupDstId=9 diff --git a/menu/data-mmdvm.sh b/menu/data-mmdvm.sh index 77fafa1..2c538a9 100644 --- a/menu/data-mmdvm.sh +++ b/menu/data-mmdvm.sh @@ -103,4 +103,53 @@ then mkdir /opt/data-files chmod 777 /opt/data-files fi +cat > /opt/mmvm.sh <<- "EOFXE" +#!/bin/bash + +# Inicializamos una variable para llevar el control del tiempo +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" + current_time=$(date +%s) + if [ $((current_time - last_update)) -ge 43200 ]; then + /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 + last_update=0 + fi + sleep 60 # Espera 1 minuto antes de la próxima verificación +done + + + +EOFXE +chmod +x /opt/mmvm.sh +cat > /lib/systemd/system/data-mmdvm.service <<- "EOFXD" +[Unit] +Description=data-mmdvm +After=multi-user.target +After=network.target + +[Service] +ExecStart=/bin/bash /opt/mmvm.sh +Restart=on-failure + +[Install] +WantedBy=multi-user.target + +EOFXD +systemctl daemon-reload +if systemctl is-active data-mmdvm.service; then + systemctl stop data-mmdvm.service + systemctl start data-mmdvm.service + else + systemctl start data-mmdvm.service + systemctl enable data-mmdvm.service +fi python3 /opt/data-mmdvm.py \ No newline at end of file diff --git a/menu/menu-mmdvm b/menu/menu-mmdvm index 6f18c26..7c45758 100644 --- a/menu/menu-mmdvm +++ b/menu/menu-mmdvm @@ -48,13 +48,13 @@ sudo nano /opt/YSFGateway2/YSFGateway.ini;; 4) sudo nano /opt/YSF2DMRGW/YSF2DMR.ini;; 5) -python3 /opt/data-mmdvm.py && cronedit.sh '* */24 * * *' 'python3 /opt/data-mmdvm.py' add sudo systemctl stop mmdvmh.service if cat /opt/MMDVMHost/MMDVM.ini | grep ServiceStart=0 >/dev/null 2>&1 then sudo systemctl disable mmdvmh.service elif cat /opt/MMDVMHost/MMDVM.ini | grep ServiceStart=1 >/dev/null 2>&1 then + python3 /opt/data-mmdvm.py && sudo systemctl start mmdvmh.service sudo systemctl enable mmdvmh.service fi @@ -90,10 +90,6 @@ then fi ;; 6) -if systemctl status ysf2dmr.service | grep disable >/dev/null 2>&1 -then - cronedit.sh '* */24 * * *' 'python3 /opt/data-mmdvm.py' remove -fi sudo systemctl stop mmdvmh.service && sudo systemctl disable mmdvmh.service && systemctl stop ysf2dmrgw.service && sudo systemctl stop dmrgw.service ;; 7) if sudo systemctl status http.server-mmdvmh.service |grep "service; enabled;" >/dev/null 2>&1 diff --git a/menu/menu-nxdn2dmr b/menu/menu-nxdn2dmr index 68aa156..2753bf3 100644 --- a/menu/menu-nxdn2dmr +++ b/menu/menu-nxdn2dmr @@ -20,7 +20,7 @@ case $choix in 1) sudo nano /opt/NXDN2DMR/NXDN2DMR.ini;; 2) -python3 /opt/data-mmdvm.py && (crontab -l; echo "* */24 * * * python3 /opt/data-mmdvm.py")|awk '!x[$0]++'|crontab - && +python3 /opt/data-mmdvm.py && if systemctl status nxdn2dmr.service |grep active >/dev/null 2>&1 then sudo systemctl stop nxdn2dmr.service @@ -31,10 +31,6 @@ then sudo systemctl enable nxdn2dmr.service fi sudo systemctl start nxdn2dmr.service ;; 3) -if systemctl status mmdvmh.service | grep disable >/dev/null 2>&1 -then - (crontab -l | grep -v "python3 /opt/data-mmdvm.py") | crontab - -fi sudo systemctl stop nxdn2dmr.service && sudo systemctl disable nxdn2dmr.service ;; 4) break; diff --git a/menu/menu-p25r b/menu/menu-p25r index d2aa575..ec85451 100644 --- a/menu/menu-p25r +++ b/menu/menu-p25r @@ -40,6 +40,7 @@ case $choix in 1) sudo nano /etc/P25Reflector.ini ;; 2) +python3 /opt/data-mmdvm.py && sudo systemctl stop P25Reflector.service && if ! sudo systemctl status P25Reflector.service |grep "service; enabled;" >/dev/null 2>&1 then @@ -316,12 +317,12 @@ case $choix in sudo sed -i "37s/Static=.*/Static=$p25id/g" /opt/p25bridge/P25Gateway.ini sudo sed -i "38s/Startup=.*/Startup=$p25id/g" /opt/p25bridge/P25Gateway.ini - input_file="/var/lib/mmdvm/P25Hosts.txt" + input_file="/opt/data-files/P25Hosts.txt" output_file="/opt/P25Hosts2.txt" grep -w "^$p25id" "$input_file" > "$output_file" rm -f /tmp/mcall.txt /tmp/mid.txt /tmp/p25id.txt /tmp/sbridge.txt /tmp/sport.txt /tmp/sopti.txt /tmp/midg.txt /tmp/spass.txt - +python3 /opt/data-mmdvm.py #!/bin/bash # Lista de servicios a reiniciar @@ -344,6 +345,7 @@ done ;; 2) +python3 /opt/data-mmdvm.py #!/bin/bash # Lista de servicios a reiniciar diff --git a/menu/menu-ysf2dmr b/menu/menu-ysf2dmr index c3b2040..95ad835 100644 --- a/menu/menu-ysf2dmr +++ b/menu/menu-ysf2dmr @@ -20,7 +20,7 @@ case $choix in 1) sudo nano /opt/YSF2DMR/YSF2DMR.ini;; 2) -python3 /opt/data-mmdvm.py && (crontab -l; echo "* */24 * * * python3 /opt/data-mmdvm.py")|awk '!x[$0]++'|crontab - && +python3 /opt/data-mmdvm.py && if systemctl status ysf2dmr.service |grep active >/dev/null 2>&1 then sudo systemctl stop ysf2dmr.service @@ -31,10 +31,6 @@ then sudo systemctl enable ysf2dmr.service fi sudo systemctl start ysf2dmr.service ;; 3) -if systemctl status mmdvmh.service | grep disable >/dev/null 2>&1 -then - (crontab -l | grep -v "python3 /opt/data-mmdvm.py") | crontab - -fi sudo systemctl stop ysf2dmr.service && sudo systemctl disable ysf2dmr.service ;; 4) break;