This commit is contained in:
Esteban Mackay Q 2023-10-08 21:57:02 -05:00
parent 259cf3cf0b
commit 0d319e91dc
2 changed files with 45 additions and 7 deletions

View File

@ -57,6 +57,27 @@ sudo sed -i "s/Name=.*/Name=\/var\/lib\/mmdvm\/DMRIds.dat/g" /opt/P25Reflector/P
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
sudo cat > /usr/local/bin/clear-p25-logs.sh <<- "EOF"
#!/bin/bash
log_dir="/var/log/P25Reflector/"
# Verifica si la carpeta de registro existe
if [ -d "$log_dir" ]; then
# Verifica si hay archivos en la carpeta
if [ -n "$(ls -A $log_dir)" ]; then
# Borra todos los archivos en la carpeta
rm -f $log_dir*
echo "Se han eliminado todos los archivos en $log_dir"
else
echo "No se encontraron archivos en $log_dir"
fi
else
echo "La carpeta $log_dir no existe"
fi
EOF
sudo chmod +x /usr/local/bin/clear-p25-logs.sh
sudo cat > /lib/systemd/system/P25Reflector.service <<- "EOF"
[Unit]
Description=P25 Reflector Service
@ -73,9 +94,10 @@ RestartPreventExitStatus=SEGV
RestartSec=3
StandardOutput=null
WorkingDirectory=/opt/P25Reflector
#ExecStartPre = /bin/sh -c 'echo "Starting P25Reflector: [`date +%%T.%%3N`]" >> /var/log/netcheck'
ExecStartPre=/usr/local/bin/clear-p25-logs.sh
#/bin/sh -c 'echo "Starting P25Reflector: [`date +%%T.%%3N`]" >> /var/log/netcheck'
ExecStart=/usr/local/bin/P25Reflector /etc/P25Reflector.ini
ExecReload=/bin/kill -HUP $MAINPID
#ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
[Install]

View File

@ -15,7 +15,7 @@ fi
sudo cat > /bin/menu-p25r <<- "EOF"
#!/bin/bash
while : ; do
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Reflector" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 11 \
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Reflector" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 12 \
1 " Editar P25FReflector Server " \
2 " Iniciar Reflector " \
3 " Detener Reflector " \
@ -24,8 +24,9 @@ choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Reflector" --menu "Sub
6 " Editar Puerto http " \
7 " enable setup.php " \
8 " remove setup.php " \
9 " P25Bbridge <> XLX/DMR " \
10 " Menu Principal " 3>&1 1>&2 2>&3)
9 " UPDATE Host & DMRId " \
10 " P25Bbridge <> XLX/DMR " \
11 " Menu Principal " 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
@ -40,7 +41,6 @@ case $choix in
sudo nano /etc/P25Reflector.ini ;;
2)
sudo systemctl stop P25Reflector.service &&
rm /var/log/P25Reflector/*
if ! sudo systemctl status P25Reflector.service |grep "service; enabled;" >/dev/null 2>&1
then
sudo systemctl enable P25Reflector.service
@ -112,9 +112,25 @@ if [ -f "/var/www/p25/setup.php" ]
whiptail --title "P25Reflector" --msgbox "setup.php is not enabled / setup.php no esta habilitado" 0 50
fi ;;
9)
clear
echo "Update Host files - please wait"
sudo /usr/local/sbin/DVSM_Update.sh
# Lista de servicios a reiniciar
servicios=("P25Reflector.service" "md380-emuP25b.service" "analog_bridge1.service" "analog_bridge2.service" "mmdvm_bridgeP25b.service" "p25gatewayP25b.service")
# Recorre la lista de servicios y verifica si están activos
for servicio in "${servicios[@]}"; do
if systemctl status "$servicio" | grep "Active: active" >/dev/null 2>&1; then
echo "Reiniciando el servicio $servicio"
sudo systemctl restart "$servicio"
fi
done
;;
10)
menu-p25b
;;
10)
11)
break
;;
esac