mirror of https://gitlab.com/hp3icc/emq-TE1.git
1276 lines
40 KiB
Bash
1276 lines
40 KiB
Bash
#!/bin/bash
|
|
if ! grep -q "Web-Dashboar-name" "/opt/wdp3" > /dev/null 2>&1; then
|
|
sudo cat > /opt/wdp3 <<- "EOFX"
|
|
##########################################
|
|
# Select number port, DVSwitch Dashboard #
|
|
##########################################
|
|
|
|
Web-Dashboar-name: dvs
|
|
Web-Dashboar-Port: 80
|
|
Web-Dashboar-dns:
|
|
Web-Dashboar-dir: /var/www/dvs
|
|
|
|
EOFX
|
|
fi
|
|
if [ ! -d "/var/www/dvs/qrz_photo/" ] && [ ! -f "/usr/local/dvs/dvsmu" ] && [ -f "/opt/emq-ver" ]; then
|
|
sudo cat > /bin/menu-dvs <<- "EOF3"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Script Proyect HP3ICC Menu DVSwitch" --menu "Nota : Debe encender Dvswitch antes de editar para utilizar." 20 60 11 \
|
|
1 " Encender Dvswitch " \
|
|
2 " Apagar Dvswitch " \
|
|
3 " Editar Dvswitch Server " \
|
|
4 " Cambiar Puerto http & dns de Dashboard " \
|
|
5 " Start Dashboard " \
|
|
6 " Dashboard off " \
|
|
7 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."
|
|
break
|
|
fi
|
|
|
|
case $choix in
|
|
1)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener un servicio
|
|
stop_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Función para iniciar y habilitar un servicio
|
|
start_and_enable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Iniciando y habilitando $service_name"
|
|
sudo systemctl start "$service_name" > /dev/null 2>&1
|
|
sudo systemctl enable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener todos los servicios base primero
|
|
for servicio in $servicios; do
|
|
stop_service "$servicio"
|
|
done
|
|
|
|
# Detener todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_service "mmdvm_bridge$i.service"
|
|
stop_service "analog_bridge$i.service"
|
|
stop_service "md380-emu$i.service"
|
|
done
|
|
|
|
# Esperar 5 segundos para asegurar que todos los servicios se detengan
|
|
sleep 5
|
|
|
|
# Iniciar y habilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
start_and_enable_service "$servicio"
|
|
done
|
|
|
|
# Iniciar y habilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
start_and_enable_service "mmdvm_bridge$i.service"
|
|
start_and_enable_service "analog_bridge$i.service"
|
|
start_and_enable_service "md380-emu$i.service"
|
|
done
|
|
;;
|
|
2)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener y deshabilitar un servicio
|
|
stop_and_disable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo y deshabilitando $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
sudo systemctl disable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener y deshabilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
stop_and_disable_service "$servicio"
|
|
done
|
|
|
|
# Detener y deshabilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_and_disable_service "mmdvm_bridge$i.service"
|
|
stop_and_disable_service "analog_bridge$i.service"
|
|
stop_and_disable_service "md380-emu$i.service"
|
|
done
|
|
rm /var/log/mmdvm/*;;
|
|
3)
|
|
sudo /usr/local/dvs/dvs ;;
|
|
4)
|
|
wdp=/opt/wdp3
|
|
if [ -f "/tmp/w0dn0.txt" ]; then
|
|
rm /tmp/w0dn0.txt
|
|
fi
|
|
if [ -f "/tmp/wd0p.txt" ]; then
|
|
rm /tmp/wd0p.txt
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "Select HTTP port:" 10 60 2>/tmp/wd0p.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
wd0p=$(cat /tmp/wd0p.txt)
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "DNS name:" 10 60 2>/tmp/w0dn0.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
w0dn0=$(cat /tmp/w0dn0.txt)
|
|
|
|
sed -i "s|Web-Dashboar-Port:.*|Web-Dashboar-Port: $wd0p|g" $wdp
|
|
sed -i "s|Web-Dashboar-dns:.*|Web-Dashboar-dns: $w0dn0|g" $wdp
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
5)
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
6)
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "stop $servicio"
|
|
sudo systemctl disable "$servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
7)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF3
|
|
fi
|
|
#
|
|
if [ ! -d "/var/www/dvs/qrz_photo/" ] && [ -f "/usr/local/dvs/dvsmu" ] && [ -f "/opt/emq-ver" ]; then
|
|
sudo cat > /bin/menu-dvs <<- "EOFR"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Script Proyect HP3ICC Menu DVSwitch" --menu "Nota : Debe encender Dvswitch antes de editar para utilizar." 20 60 11 \
|
|
1 " Encender Dvswitch " \
|
|
2 " Apagar Dvswitch " \
|
|
3 " Editar Dvswitch Server " \
|
|
4 " Editar DVSMU Server " \
|
|
5 " Cambiar Puerto http & dns de Dashboard " \
|
|
6 " Start Dashboard " \
|
|
7 " Dashboard off " \
|
|
8 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."
|
|
break
|
|
fi
|
|
|
|
case $choix in
|
|
1)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener un servicio
|
|
stop_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Función para iniciar y habilitar un servicio
|
|
start_and_enable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Iniciando y habilitando $service_name"
|
|
sudo systemctl start "$service_name" > /dev/null 2>&1
|
|
sudo systemctl enable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener todos los servicios base primero
|
|
for servicio in $servicios; do
|
|
stop_service "$servicio"
|
|
done
|
|
|
|
# Detener todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_service "mmdvm_bridge$i.service"
|
|
stop_service "analog_bridge$i.service"
|
|
stop_service "md380-emu$i.service"
|
|
done
|
|
|
|
# Esperar 5 segundos para asegurar que todos los servicios se detengan
|
|
sleep 5
|
|
|
|
# Iniciar y habilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
start_and_enable_service "$servicio"
|
|
done
|
|
|
|
# Iniciar y habilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
start_and_enable_service "mmdvm_bridge$i.service"
|
|
start_and_enable_service "analog_bridge$i.service"
|
|
start_and_enable_service "md380-emu$i.service"
|
|
done
|
|
;;
|
|
2)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener y deshabilitar un servicio
|
|
stop_and_disable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo y deshabilitando $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
sudo systemctl disable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener y deshabilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
stop_and_disable_service "$servicio"
|
|
done
|
|
|
|
# Detener y deshabilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_and_disable_service "mmdvm_bridge$i.service"
|
|
stop_and_disable_service "analog_bridge$i.service"
|
|
stop_and_disable_service "md380-emu$i.service"
|
|
done
|
|
rm /var/log/mmdvm/*;;
|
|
3)
|
|
sudo /usr/local/dvs/dvs ;;
|
|
4)
|
|
sudo /usr/local/dvs/dvsmu ;;
|
|
5)
|
|
wdp=/opt/wdp3
|
|
if [ -f "/tmp/w0dn0.txt" ]; then
|
|
rm /tmp/w0dn0.txt
|
|
fi
|
|
if [ -f "/tmp/wd0p.txt" ]; then
|
|
rm /tmp/wd0p.txt
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "Select HTTP port:" 10 60 2>/tmp/wd0p.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
wd0p=$(cat /tmp/wd0p.txt)
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "DNS name:" 10 60 2>/tmp/w0dn0.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
w0dn0=$(cat /tmp/w0dn0.txt)
|
|
|
|
sed -i "s|Web-Dashboar-Port:.*|Web-Dashboar-Port: $wd0p|g" $wdp
|
|
sed -i "s|Web-Dashboar-dns:.*|Web-Dashboar-dns: $w0dn0|g" $wdp
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
;;
|
|
6)
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
7)
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "stop $servicio"
|
|
sudo systemctl disable "$servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
9)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
|
|
EOFR
|
|
fi
|
|
if [ -d "/var/www/dvs/qrz_photo/" ] && [ ! -f "/usr/local/dvs/dvsmu" ] && [ -f "/opt/emq-ver" ]; then
|
|
sudo cat > /bin/menu-dvs <<- "EOF3"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Script Proyect HP3ICC Menu DVSwitch" --menu "Nota : Debe encender Dvswitch antes de editar para utilizar." 20 60 11 \
|
|
1 " Encender Dvswitch " \
|
|
2 " Apagar Dvswitch " \
|
|
3 " Editar Dvswitch Server " \
|
|
4 " Cambiar Puerto http & dns de Dashboard " \
|
|
5 " Start Dashboard Full " \
|
|
6 " Dashboard off " \
|
|
7 " Start Dashboard no Buttons " \
|
|
8 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."
|
|
break
|
|
fi
|
|
|
|
case $choix in
|
|
1)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener un servicio
|
|
stop_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Función para iniciar y habilitar un servicio
|
|
start_and_enable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Iniciando y habilitando $service_name"
|
|
sudo systemctl start "$service_name" > /dev/null 2>&1
|
|
sudo systemctl enable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener todos los servicios base primero
|
|
for servicio in $servicios; do
|
|
stop_service "$servicio"
|
|
done
|
|
|
|
# Detener todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_service "mmdvm_bridge$i.service"
|
|
stop_service "analog_bridge$i.service"
|
|
stop_service "md380-emu$i.service"
|
|
done
|
|
|
|
# Esperar 5 segundos para asegurar que todos los servicios se detengan
|
|
sleep 5
|
|
|
|
# Iniciar y habilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
start_and_enable_service "$servicio"
|
|
done
|
|
|
|
# Iniciar y habilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
start_and_enable_service "mmdvm_bridge$i.service"
|
|
start_and_enable_service "analog_bridge$i.service"
|
|
start_and_enable_service "md380-emu$i.service"
|
|
done
|
|
;;
|
|
2)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener y deshabilitar un servicio
|
|
stop_and_disable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo y deshabilitando $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
sudo systemctl disable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener y deshabilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
stop_and_disable_service "$servicio"
|
|
done
|
|
|
|
# Detener y deshabilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_and_disable_service "mmdvm_bridge$i.service"
|
|
stop_and_disable_service "analog_bridge$i.service"
|
|
stop_and_disable_service "md380-emu$i.service"
|
|
done
|
|
rm /var/log/mmdvm/*;;
|
|
3)
|
|
sudo /usr/local/dvs/dvs ;;
|
|
4)
|
|
wdp=/opt/wdp3
|
|
if [ -f "/tmp/w0dn0.txt" ]; then
|
|
rm /tmp/w0dn0.txt
|
|
fi
|
|
if [ -f "/tmp/wd0p.txt" ]; then
|
|
rm /tmp/wd0p.txt
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "Select HTTP port:" 10 60 2>/tmp/wd0p.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
wd0p=$(cat /tmp/wd0p.txt)
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "DNS name:" 10 60 2>/tmp/w0dn0.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
w0dn0=$(cat /tmp/w0dn0.txt)
|
|
|
|
sed -i "s|Web-Dashboar-Port:.*|Web-Dashboar-Port: $wd0p|g" $wdp
|
|
sed -i "s|Web-Dashboar-dns:.*|Web-Dashboar-dns: $w0dn0|g" $wdp
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
5)
|
|
cp /opt/index-dvs.txt /var/www/dvs/index.php &&
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
6)
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "stop $servicio"
|
|
sudo systemctl disable "$servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
7)
|
|
cp /opt/index-dvs.txt /var/www/dvs/index.php &&
|
|
bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/dvs-nb.sh)" &&
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
8)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF3
|
|
fi
|
|
if [ -d "/var/www/dvs/qrz_photo/" ] && [ -f "/usr/local/dvs/dvsmu" ] && [ -f "/opt/emq-ver" ]; then
|
|
# Avanzar con el script si el directorio y el archivo existen
|
|
sudo cat > /bin/menu-dvs <<- "EOFR"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Script Proyect HP3ICC Menu DVSwitch" --menu "Nota : Debe encender Dvswitch antes de editar para utilizar." 20 60 11 \
|
|
1 " Encender Dvswitch " \
|
|
2 " Apagar Dvswitch " \
|
|
3 " Editar Dvswitch Server " \
|
|
4 " Editar DVSMU Server " \
|
|
5 " Cambiar Puerto http & dns de Dashboard " \
|
|
6 " Start Dashboard Full " \
|
|
7 " Dashboard off " \
|
|
8 " Start Dashboard no Buttons " \
|
|
9 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."
|
|
break
|
|
fi
|
|
|
|
case $choix in
|
|
1)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener un servicio
|
|
stop_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Función para iniciar y habilitar un servicio
|
|
start_and_enable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Iniciando y habilitando $service_name"
|
|
sudo systemctl start "$service_name" > /dev/null 2>&1
|
|
sudo systemctl enable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener todos los servicios base primero
|
|
for servicio in $servicios; do
|
|
stop_service "$servicio"
|
|
done
|
|
|
|
# Detener todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_service "mmdvm_bridge$i.service"
|
|
stop_service "analog_bridge$i.service"
|
|
stop_service "md380-emu$i.service"
|
|
done
|
|
|
|
# Esperar 5 segundos para asegurar que todos los servicios se detengan
|
|
sleep 5
|
|
|
|
# Iniciar y habilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
start_and_enable_service "$servicio"
|
|
done
|
|
|
|
# Iniciar y habilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
start_and_enable_service "mmdvm_bridge$i.service"
|
|
start_and_enable_service "analog_bridge$i.service"
|
|
start_and_enable_service "md380-emu$i.service"
|
|
done
|
|
;;
|
|
2)
|
|
# Directorio donde se encuentran los archivos de servicio
|
|
service_dir="/lib/systemd/system/"
|
|
|
|
# Lista de servicios base
|
|
servicios="md380-emu.service analog_bridge.service mmdvm_bridge.service nxdngateway.service p25gateway.service ysfgateway.service quantar_bridge.service ircddbgatewayd.service p25parrot.service ysfparrot.service nxdnparrot.service"
|
|
|
|
# Función para detener y deshabilitar un servicio
|
|
stop_and_disable_service() {
|
|
local service_name="$1"
|
|
if [ -f "$service_dir$service_name" ]; then
|
|
echo "Deteniendo y deshabilitando $service_name"
|
|
sudo systemctl stop "$service_name" > /dev/null 2>&1
|
|
sudo systemctl disable "$service_name" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
# Detener y deshabilitar todos los servicios base
|
|
for servicio in $servicios; do
|
|
stop_and_disable_service "$servicio"
|
|
done
|
|
|
|
# Detener y deshabilitar todos los servicios enumerados
|
|
for i in {01..40}; do
|
|
stop_and_disable_service "mmdvm_bridge$i.service"
|
|
stop_and_disable_service "analog_bridge$i.service"
|
|
stop_and_disable_service "md380-emu$i.service"
|
|
done
|
|
rm /var/log/mmdvm/*;;
|
|
3)
|
|
sudo /usr/local/dvs/dvs ;;
|
|
4)
|
|
sudo /usr/local/dvs/dvsmu ;;
|
|
5)
|
|
wdp=/opt/wdp3
|
|
if [ -f "/tmp/w0dn0.txt" ]; then
|
|
rm /tmp/w0dn0.txt
|
|
fi
|
|
if [ -f "/tmp/wd0p.txt" ]; then
|
|
rm /tmp/wd0p.txt
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "Select HTTP port:" 10 60 2>/tmp/wd0p.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
wd0p=$(cat /tmp/wd0p.txt)
|
|
|
|
whiptail --title "Setup Webserver" --inputbox "DNS name:" 10 60 2>/tmp/w0dn0.txt
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus != 0 ]; then
|
|
echo "You chose cancel. Exiting..."
|
|
exit 1 # Salir del script con un código de error
|
|
fi
|
|
|
|
w0dn0=$(cat /tmp/w0dn0.txt)
|
|
|
|
sed -i "s|Web-Dashboar-Port:.*|Web-Dashboar-Port: $wd0p|g" $wdp
|
|
sed -i "s|Web-Dashboar-dns:.*|Web-Dashboar-dns: $w0dn0|g" $wdp
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
;;
|
|
6)
|
|
cp /opt/index-dvs.txt /var/www/dvs/index.php &&
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
7)
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "stop $servicio"
|
|
sudo systemctl disable "$servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
8)
|
|
cp /opt/index-dvs.txt /var/www/dvs/index.php &&
|
|
bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/dvs-nb.sh)" &&
|
|
wdp=/opt/wdp3
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then
|
|
rm /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
|
|
wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*')
|
|
if [ -z "$wd0p" ]
|
|
then wd0p=80
|
|
|
|
fi
|
|
wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*')
|
|
w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*')
|
|
w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*')
|
|
if [ -z "$w0dn0" ]; then
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50
|
|
exit 0
|
|
else
|
|
echo ""
|
|
fi
|
|
fi
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0
|
|
if [ ! -z "$w0dn0" ]; then
|
|
sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0
|
|
fi
|
|
sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0
|
|
sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0
|
|
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
sudo systemctl restart nginx
|
|
# Lista de servicios a reiniciar
|
|
servicios="webproxy.service monit.service"
|
|
|
|
# Primero, detener todos los servicios
|
|
for servicio in $servicios; do
|
|
if systemctl is-enabled "$servicio" &>/dev/null || systemctl is-active "$servicio" &>/dev/null; then
|
|
echo "Deteniendo $servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
|
|
# Esperar un momento para asegurarse de que todos los servicios se detengan completamente
|
|
sleep 5
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio"
|
|
sudo systemctl enable "$servicio" &>/dev/null
|
|
done
|
|
;;
|
|
9)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
|
|
EOFR
|
|
fi
|
|
#
|
|
if [ -f "/usr/local/dvs/dvsmu" ]; then
|
|
sed '132s/^#//' /usr/local/dvs/dvsmu -i
|
|
cp /usr/local/dvs/dvsmu /usr/local/bin/dvsmu
|
|
ln -sf /usr/local/bin/dvsmu /usr/local/bin/DVSMU
|
|
ln -sf /usr/local/dvs/dvs /bin/dvs
|
|
ln -sf /usr/local/dvs/dvs /bin/DVS
|
|
sudo chmod +x /bin/dvs
|
|
sudo chmod +x /bin/DVS
|
|
sudo chmod +x /usr/local/bin/dvsmu
|
|
sudo chmod +x /usr/local/bin/DVSMU
|
|
else
|
|
ln -sf /usr/local/dvs/dvs /bin/dvs
|
|
ln -sf /usr/local/dvs/dvs /bin/DVS
|
|
ln -sf /bin/menu-dvs /bin/MENU-DVS
|
|
sudo chmod +x /bin/MENU*
|
|
sudo chmod +x /bin/dvs
|
|
sudo chmod +x /bin/DVS
|
|
fi
|
|
chmod +x /bin/menu*
|
|
|