#!/bin/bash if [ -f "/opt/wdp3" ] then echo "found file" else cat > /opt/wdp3 <<- "EOFX" ########################################## # Select number port, DVSwitch Dashboard # ########################################## Web-Dashboar-Port: 80 EOFX fi cat > /bin/menu-dvs <<- "EOF" #!/bin/bash while : ; do choix=$(whiptail --title "Raspbian 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 de Dashboard " \ 5 " Dashboard on " \ 6 " Dashboard off " \ 7 " Remove Buttons Dashboard " \ 8 " 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) #!/bin/bash # 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 status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; then echo "restart $servicio" sudo systemctl restart "$servicio" else echo "start $servicio" sudo systemctl restart "$servicio" sudo systemctl enable "$servicio" fi done ;; 2) #!/bin/bash # 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 status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; 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) if sudo systemctl status http.server-dvs.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-dvs.service fi nano /opt/wdp3 && variable80=$(grep "Web-Dashboar-Port:" /opt/wdp3 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/dvs\//g" /lib/systemd/system/http.server-dvs.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-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl start http.server-dvs.service fi fi ;; 5) cp /opt/index-dvs.txt /var/www/dvs/index.php if sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-dvs.service fi if sudo systemctl status http.server-dvs.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-dvs.service fi variable80=$(grep "Web-Dashboar-Port:" /opt/wdp3 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/dvs\//g" /lib/systemd/system/http.server-dvs.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-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service sudo systemctl start http.server-dvs.service if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable webproxy.service sudo systemctl restart webproxy.service fi fi fi ;; 6) sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service && sudo systemctl disable webproxy.service && sudo systemctl stop webproxy.service ;; 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)" && if sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-dvs.service fi if sudo systemctl status http.server-dvs.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-dvs.service fi variable80=$(grep "Web-Dashboar-Port:" /opt/wdp3 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/dvs\//g" /lib/systemd/system/http.server-dvs.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-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service sudo systemctl restart http.server-dvs.service if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable webproxy.service sudo systemctl restart webproxy.service fi fi fi ;; 8) break; esac done exit 0 EOF # if [ -f "/usr/local/dvs/dvsmu" ] then cat > /bin/menu-dvs <<- "EOF" #!/bin/bash while : ; do choix=$(whiptail --title "Raspbian 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 Dvswitch MultiUser (DVSMU) " \ 5 " Cambiar Puerto http de Dashboard " \ 6 " Dashboard on " \ 7 " Dashboard off " \ 8 " Remove Buttons Dashboard " \ 9 " 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) #!/bin/bash # 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 status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; then echo "restart $servicio" sudo systemctl restart "$servicio" else echo "start $servicio" sudo systemctl restart "$servicio" sudo systemctl enable "$servicio" fi done ;; 2) #!/bin/bash # 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 status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; 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) if sudo systemctl status http.server-dvs.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-dvs.service fi nano /opt/wdp3 && variable80=$(grep "Web-Dashboar-Port:" /opt/wdp3 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/dvs\//g" /lib/systemd/system/http.server-dvs.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-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl start http.server-dvs.service if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable webproxy.service sudo systemctl restart webproxy.service fi fi fi ;; 6) cp /opt/index-dvs.txt /var/www/dvs/index.php if sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-dvs.service fi if sudo systemctl status http.server-dvs.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-dvs.service fi variable80=$(grep "Web-Dashboar-Port:" /opt/wdp3 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/dvs\//g" /lib/systemd/system/http.server-dvs.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-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service sudo systemctl restart http.server-dvs.service if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable webproxy.service sudo systemctl restart webproxy.service fi fi fi ;; 7) sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service && sudo systemctl disable webproxy.service && sudo systemctl stop webproxy.service ;; 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)" && if sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-dvs.service fi if sudo systemctl status http.server-dvs.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-dvs.service fi variable80=$(grep "Web-Dashboar-Port:" /opt/wdp3 | grep -Eo '[A.0-9]{1,9}') if [ -z "$variable80" ] then variable80=80 fi sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/dvs\//g" /lib/systemd/system/http.server-dvs.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-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service sudo systemctl restart http.server-dvs.service if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable webproxy.service sudo systemctl restart webproxy.service fi fi fi ;; 9) break; esac done exit 0 EOF 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 for i in {01..40}; do service_name="mmdvm_bridge$i.service" if sudo systemctl is-enabled "$service_name" >/dev/null 2>&1; then sudo systemctl restart "$service_name" fi done 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 fi chmod +x /bin/menu* 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