Update data-mmdvm.sh

This commit is contained in:
Esteban Mackay Q. 2024-12-29 00:25:23 -05:00
parent 6bc38c9ac6
commit dedf9ac2d3
1 changed files with 15 additions and 4 deletions

View File

@ -8,6 +8,7 @@ echo "Inicio: $SCRIPT_NAME" >> /opt/curl.txt
cat > /opt/data-mmdvm.py <<- "EOFXC"
import os
import subprocess
import re
APRSHOSTS = "/opt/data-files/APRSHosts.txt"
DCSHOSTS = "/opt/data-files/DCS_Hosts.txt"
@ -87,8 +88,18 @@ for dest_file, source_url in files_to_generate:
subprocess.run(['curl', '--fail', '-o', dest_file, '-s', source_url])
# Additional step for DMRId.dat
subprocess.run(['wget', '-O', DMRIDFILE_ALTERNATE, "http://datafiles.ddns.net:8888/DMRIds.dat"])
subprocess.run(['sed', '-i', 's/,.*//; s/ */ /g; s/^\(\S\+\s\S\+\s\S\+\).*$/\1/', DMRIDFILE_ALTERNATE])
subprocess.run(['cp', DMRIDFILE, DMRIDFILE_ALTERNATE]) # Correcting the 'cp' command
# Realizando el reemplazo utilizando Python (sin sed)
with open(DMRIDFILE_ALTERNATE, 'r') as file:
content = file.read()
# Realizar el reemplazo usando una expresión regular
content = re.sub(r'^([^,]+),([^,]+),([^,]+).*', r'\1 \2 \3', content, flags=re.M)
# Escribir el contenido modificado de vuelta al archivo
with open(DMRIDFILE_ALTERNATE, 'w') as file:
file.write(content)
# Fix up ircDDBGateway Host Files on v4
if os.path.exists("/opt/data-files/ircddbgateway"):
@ -137,8 +148,6 @@ while true; do
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"
@ -170,3 +179,5 @@ fi
(crontab -l | grep -v "python3 /opt/data-mmdvm.py") | crontab -
# Registra el final en /opt/curl.txt
echo "Finalizado: $SCRIPT_NAME" >> /opt/curl.txt