#!/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)
# Lista de servicios a reiniciar
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"

# 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
 ;;
2)
# Lista de servicios a reiniciar
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"

# 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
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)
# Lista de servicios a reiniciar
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"

# 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
 ;;
2)
# Lista de servicios a reiniciar
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"

# 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
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)
# Lista de servicios a reiniciar
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"

# 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
 ;;
2)
# Lista de servicios a reiniciar
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"

# 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
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)
# Lista de servicios a reiniciar
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"

# 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
 ;;
2)
# Lista de servicios a reiniciar
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"

# 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
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
# Función para verificar si un servicio existe
service_exists() {
  local service_name=$1
  # Usamos 'timeout' para evitar que el comando se quede bloqueado
  timeout 1s sudo systemctl status "$service_name" >/dev/null 2>&1
  return $?
}

# Detener todos los servicios que estén activos o habilitados (primer bucle)
for i in {01..40}; do
  service_name="mmdvm_bridge$i.service"
  
  # Verifica si el servicio existe
  if service_exists "$service_name"; then
    # Verifica si el servicio está activo O habilitado (de forma silenciosa)
    if sudo systemctl is-active "$service_name" >/dev/null 2>&1 || sudo systemctl is-enabled "$service_name" >/dev/null 2>&1; then
      # Detener el servicio (de forma silenciosa)
      sudo systemctl stop "$service_name" >/dev/null 2>&1
    fi
  fi
done

# Modificar los archivos de configuración (segundo bucle)
for i in {01..40}; do
  archivo="/opt/user$i/MMDVM_Bridge.ini"
  if [ -e "$archivo" ]; then
    sed -i "s/FileRoot=.*/FileRoot=MMDVM_Bridge$i/g" "$archivo"
  fi
done 2>/dev/null

# Iniciar todos los servicios habilitados (tercer bucle)
for i in {01..40}; do
  service_name="mmdvm_bridge$i.service"
  
  # Verifica si el servicio existe
  if service_exists "$service_name"; then
    # Verifica si el servicio está habilitado (de forma silenciosa)
    if sudo systemctl is-enabled "$service_name" >/dev/null 2>&1; then
      # Iniciar el servicio (de forma silenciosa)
      sudo systemctl start "$service_name" >/dev/null 2>&1
      sudo systemctl enable "$service_name" >/dev/null 2>&1
    fi
  fi
done
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*

