#!/bin/bash cat > /bin/menu-mmdvm <<- "EOF" #!/bin/bash while : ; do choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu MMDVMHost" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion." 24 50 16 \ 1 " Editar MMDVMHost " \ 2 " Editar DMRGateway " \ 3 " Editar YSFGateway " \ 4 " Editar YSF2DMR " \ 5 " Start&Restart service MMDVM " \ 6 " Stop service MMDVM " \ 7 " Dashboard ON " \ 8 " Dashboard Off " \ 9 " Editar Puerto http " \ 10 " Editar HTML " \ 11 " Editar Dashboard " \ 12 " Dashboard TG Name FreeDMR " \ 13 " Dashboard TG Name Brandmeister " \ 14 " Menu Principal " 3>&1 1>&2 2>&3) exitstatus=$? #on recupere ce choix #exitstatus=$? if [ $exitstatus = 0 ]; then echo "Your chosen option:" $choix else echo "You chose cancel."; break; fi # case : action en fonction du choix case $choix in 1) sudo nano /opt/MMDVMHost/MMDVM.ini;; 2) sudo nano /opt/DMRGateway/DMRGateway.ini;; 3) sudo nano /opt/YSFGateway2/YSFGateway.ini;; 4) sudo nano /opt/YSF2DMRGW/YSF2DMR.ini;; 5) sh /opt/data-file.sh && cronedit.sh '* */24 * * *' 'sh /opt/data-file.sh' 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 sudo systemctl start mmdvmh.service sudo systemctl enable mmdvmh.service fi sudo systemctl stop ysfgw.service if cat /opt/YSFGateway2/YSFGateway.ini | grep ServiceStart=0 >/dev/null 2>&1 then sudo systemctl disable ysfgw.service elif cat /opt/YSFGateway2/YSFGateway.ini | grep ServiceStart=1 >/dev/null 2>&1 then sudo systemctl start ysfgw.service sudo systemctl enable ysfgw.service fi sudo systemctl stop ysf2dmrgw.service if cat /opt/YSF2DMRGW/YSF2DMR.ini | grep ServiceStart=0 >/dev/null 2>&1 then sudo systemctl disable ysf2dmrgw.service elif cat /opt/YSF2DMRGW/YSF2DMR.ini | grep ServiceStart=1 >/dev/null 2>&1 then sudo systemctl start ysf2dmrgw.service sudo systemctl enable ysf2dmrgw.service fi sudo systemctl stop dmrgw.service if cat /opt/DMRGateway/DMRGateway.ini | grep ServiceStart=0 >/dev/null 2>&1 then sudo systemctl disable dmrgw.service elif cat /opt/DMRGateway/DMRGateway.ini | grep ServiceStart=1 >/dev/null 2>&1 then sudo systemctl start dmrgw.service sudo systemctl enable dmrgw.service fi ;; 6) if systemctl status ysf2dmr.service | grep disable >/dev/null 2>&1 then cronedit.sh '* */24 * * *' 'sh /opt/data-file.sh' 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 then sudo systemctl disable http.server-mmdvmh.service fi if sudo systemctl status http.server-mmdvmh.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-mmdvmh.service fi if sudo systemctl status logtailer-mmdvmh.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable logtailer-mmdvmh.service fi if sudo systemctl status logtailer-mmdvmh.service |grep active >/dev/null 2>&1 then sudo systemctl stop logtailer-mmdvmh.service fi variable80=$(grep "Web-Dashboar-Port:" /opt/wdp5 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=\/usr\/bin\/python3 -m http.server $variable80 --directory \/opt\/MMDVMHost-Websocketboard\/html/g" /lib/systemd/system/http.server-mmdvmh.service && systemctl daemon-reload && if sudo netstat -tuln | grep -q "0.0.0.0:$variable80"; then whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50 else if ! sudo systemctl status http.server-mmdvmh.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-mmdvmh.service fi if ! sudo systemctl status logtailer-mmdvmh.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable logtailer-mmdvmh.service fi sudo systemctl start http.server-mmdvmh.service sudo systemctl start logtailer-mmdvmh.service fi ;; 8) sudo systemctl stop logtailer-mmdvmh.service && sudo systemctl disable logtailer-mmdvmh.service && sudo systemctl stop http.server-mmdvmh.service && sudo systemctl disable http.server-mmdvmh.service && cronedit.sh '* */24 * * *' 'sh /bin/tg-name.sh' remove ;; 9) if sudo systemctl status http.server-mmdvmh.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-mmdvmh.service fi sudo nano /opt/wdp5 && variable80=$(grep "Web-Dashboar-Port:" /opt/wdp5 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=\/usr\/bin\/python3 -m http.server $variable80 --directory \/opt\/MMDVMHost-Websocketboard\/html/g" /lib/systemd/system/http.server-mmdvmh.service && systemctl daemon-reload && if sudo netstat -tuln | grep -q "0.0.0.0:$variable80"; then whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50 else if sudo systemctl status http.server-mmdvmh.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl start http.server-mmdvmh.service fi fi ;; 10) sudo nano /opt/MMDVMHost-Websocketboard/html/index.html ;; 11) sudo nano /opt/MMDVMHost-Websocketboard/html/js/config.js ;; 12) python3 /opt/tg-name-fdmr.py ;; 13) python3 /opt/tg-name-bm.py ;; 14) break; esac done exit 0 EOF ####### cat > /opt/tg-name-fdmr.py <<- "EOF" import csv import requests # URL del archivo CSV url = "https://freedmr.cymru/talkgroups/talkgroup_ids.csv" # Descargar el archivo CSV response = requests.get(url) content = response.content.decode("utf-8") # Leer el archivo CSV original csv_reader = csv.reader(content.splitlines()) header = next(csv_reader) # Leer la primera fila como encabezado # Ruta de archivo de salida output_file_path = "/opt/MMDVMHost-Websocketboard/html/data/TG_List.csv" # Almacenar los datos en una lista data = [] # Procesar los datos del archivo original y agregarlos a la lista for row in csv_reader: data.append([int(row[0]), row[1], int(row[2])]) # Agregar la línea adicional data.append([9, "Dial-TG TG9"]) data.append([6, "XLX TG6"]) data.append([2, "Local TG2"]) data.append([9990, "Parrot TG9990"]) # Ordenar la lista por el valor de la columna "id" data.sort(key=lambda x: x[0]) # Abrir el archivo de salida en modo escritura with open(output_file_path, "w", newline="") as output_file: csv_writer = csv.writer(output_file) # Escribir la primera fila de encabezado csv_writer.writerow(["DMR", "2", "id", "callsign tgid"]) # Escribir los datos en el nuevo formato for row in data: if len(row) == 3: csv_writer.writerow(["DMR", "2", row[0], f"{row[1]} {row[2]}"]) else: csv_writer.writerow(["DMR", "2", row[0], row[1]]) print("Proceso completado. Archivo de salida generado en:", output_file_path) EOF cat > /opt/tg-name-bm.py <<- "EOF" import csv import requests # URL del archivo de texto url = "http://www.pistar.uk/downloads/TGList_BM.txt" # Descargar el archivo de texto response = requests.get(url) content = response.content.decode("utf-8") # Dividir el contenido del archivo en líneas lines = content.splitlines() # Ruta del archivo de salida output_file_path = "/opt/MMDVMHost-Websocketboard/html/data/TG_List.csv" # Almacenar los datos en una lista data = [] # Procesar los datos del archivo original y agregarlos a la lista for line in lines: if not line.startswith('#'): parts = line.split(';') if len(parts) >= 4: data.append([int(parts[0]), parts[2], parts[3]]) # Agregar líneas adicionales data.append([9990, "Parrot", "TG9990"]) data.append([6, "XLX", "TG6"]) # Ordenar la lista por el valor de la columna "id" data.sort(key=lambda x: x[0]) # Abrir el archivo de salida en modo escritura with open(output_file_path, "w", newline="") as output_file: csv_writer = csv.writer(output_file) # Escribir la primera fila de encabezado csv_writer.writerow(["DMR", "2", "id", "callsign tgid"]) # Escribir los datos en el nuevo formato for row in data: csv_writer.writerow(["DMR", "2", row[0], row[1] + " " + row[2]]) print("Proceso completado. Archivo de salida generado en:", output_file_path) EOF ################################################################################################################ chmod +x /bin/menu-mmdvm ln -sf /bin/menu-mmdvm /bin/MENU-MMDVM chmod +x /bin/MENU* python3 /opt/tg-name-bm.py