mirror of https://gitlab.com/hp3icc/emq-TE1.git
191 lines
6.4 KiB
Bash
191 lines
6.4 KiB
Bash
#!/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)
|
|
sudo systemctl stop md380-emu.service
|
|
sudo systemctl stop analog_bridge.service
|
|
sudo systemctl stop mmdvm_bridge.service
|
|
sudo systemctl stop nxdngateway.service
|
|
sudo systemctl stop p25gateway.service
|
|
sudo systemctl stop ysfgateway.service
|
|
sudo systemctl stop quantar_bridge.service
|
|
sudo systemctl stop ircddbgatewayd.service
|
|
sudo systemctl stop p25parrot.service
|
|
sudo systemctl stop ysfparrot.service
|
|
sudo systemctl stop nxdnparrot.service
|
|
|
|
sudo systemctl start md380-emu.service
|
|
sudo systemctl start analog_bridge.service
|
|
sudo systemctl start mmdvm_bridge.service
|
|
sudo systemctl start nxdngateway.service
|
|
sudo systemctl start p25gateway.service
|
|
sudo systemctl start ysfgateway.service
|
|
sudo systemctl start quantar_bridge.service
|
|
sudo systemctl start ircddbgatewayd.service
|
|
sudo systemctl start p25parrot.service
|
|
sudo systemctl start ysfparrot.service
|
|
sudo systemctl start nxdnparrot.service
|
|
sudo systemctl start ircddbgatewayd.service
|
|
|
|
sudo systemctl enable md380-emu.service
|
|
sudo systemctl enable analog_bridge.service
|
|
sudo systemctl enable mmdvm_bridge.service
|
|
sudo systemctl enable nxdngateway.service
|
|
sudo systemctl enable p25gateway.service
|
|
sudo systemctl enable ysfgateway.service
|
|
sudo systemctl enable quantar_bridge.service
|
|
sudo systemctl enable ircddbgatewayd.service
|
|
sudo systemctl enable p25parrot.service
|
|
sudo systemctl enable ysfparrot.service
|
|
sudo systemctl enable nxdnparrot.service ;;
|
|
2)
|
|
sudo systemctl stop md380-emu.service
|
|
sudo systemctl stop analog_bridge.service
|
|
sudo systemctl stop mmdvm_bridge.service
|
|
sudo systemctl stop nxdngateway.service
|
|
sudo systemctl stop p25gateway.service
|
|
sudo systemctl stop ysfgateway.service
|
|
sudo systemctl stop quantar_bridge.service
|
|
sudo systemctl stop ircddbgatewayd.service
|
|
sudo systemctl stop p25parrot.service
|
|
sudo systemctl stop ysfparrot.service
|
|
sudo systemctl stop nxdnparrot.service
|
|
|
|
sudo systemctl disable md380-emu.service
|
|
sudo systemctl disable analog_bridge.service
|
|
sudo systemctl disable mmdvm_bridge.service
|
|
sudo systemctl disable nxdngateway.service
|
|
sudo systemctl disable p25gateway.service
|
|
sudo systemctl disable ysfgateway.service
|
|
sudo systemctl disable quantar_bridge.service
|
|
sudo systemctl disable ircddbgatewayd.service
|
|
sudo systemctl disable p25parrot.service
|
|
sudo systemctl disable ysfparrot.service
|
|
sudo systemctl disable nxdnparrot.service
|
|
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 /var/www/dvs/index.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
|
|
fi
|
|
sudo systemctl start http.server-dvs.service
|
|
fi ;;
|
|
6)
|
|
sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service ;;
|
|
7)
|
|
cp /var/www/dvs/index.txt /var/www/dvs/index.php &&
|
|
sed -i '111,203{/^$/!s/^/\/\/ /}' /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
|
|
fi
|
|
sudo systemctl start http.server-dvs.service
|
|
fi ;;
|
|
8)
|
|
break;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF
|
|
#
|
|
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
|