mirror of https://gitlab.com/hp3icc/emq-TE1.git
106 lines
3.6 KiB
Bash
106 lines
3.6 KiB
Bash
#!/bin/bash
|
|
sudo cat > /bin/menu-ysf <<- "EOF"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu YSFReflector" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 11 \
|
|
1 " Editar pYSFReflector Server " \
|
|
2 " Iniciar Reflector " \
|
|
3 " Detener Reflector " \
|
|
4 " Dashboard on " \
|
|
5 " Dashboard off " \
|
|
6 " Editar Puerto http " \
|
|
7 " Editar HTML " \
|
|
8 " Editar 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)
|
|
sudo nano /opt/pYSFReflector3/pysfreflector.ini ;;
|
|
2)
|
|
sudo systemctl stop YSFReflector.service && sudo systemctl start YSFReflector.service && sudo systemctl enable YSFReflector.service ;;
|
|
3)
|
|
sudo systemctl stop YSFReflector.service && sudo systemctl disable YSFReflector.service ;;
|
|
4)
|
|
if sudo systemctl status http.server-ysf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable http.server-ysf.service
|
|
fi
|
|
if sudo systemctl status http.server-ysf.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-ysf.service
|
|
fi
|
|
if sudo systemctl status logtailer-ysf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable logtailer-ysf.service
|
|
fi
|
|
if sudo systemctl status logtailer-ysf.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop logtailer-ysf.service
|
|
fi
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp4 | grep -Eo '[A.0-9]{1,9}')
|
|
if [ -z "$variable80" ]
|
|
then variable80=80
|
|
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=\/usr\/bin\/python3 -m http.server $variable80 --directory \/opt\/WSYSFDash\/html/g" /lib/systemd/system/http.server-ysf.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-ysf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl enable http.server-ysf.service
|
|
fi
|
|
if ! sudo systemctl status logtailer-ysf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl enable logtailer-ysf.service
|
|
fi
|
|
sudo systemctl start http.server-ysf.service
|
|
sudo systemctl start logtailer-ysf.service
|
|
fi ;;
|
|
5)
|
|
sudo systemctl stop logtailer-ysf.service && sudo systemctl disable logtailer-ysf.service && sudo systemctl stop http.server-ysf.service && sudo systemctl disable http.server-ysf.service ;;
|
|
6)
|
|
if sudo systemctl status http.server-ysf.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-ysf.service
|
|
fi
|
|
sudo nano /opt/wdp4 &&
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp4 | 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-ysf.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-ysf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl start http.server-ysf.service
|
|
fi
|
|
fi ;;
|
|
7)
|
|
sudo nano /opt/WSYSFDash/html/index.html ;;
|
|
8)
|
|
nano /opt/WSYSFDash/html/js/config.js ;;
|
|
9)
|
|
break;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF
|
|
#########
|
|
chmod +x /bin/menu-ysf
|
|
ln -sf /bin/menu-ysf /bin/MENU-YSF
|
|
chmod +x /bin/MENU*
|