#!/bin/bash sudo cat > /bin/menu-ysf2ysf <<- "EOF" #!/bin/bash if [ $EUID -ne 0 ]; then whiptail --title "sudo su" --msgbox "requiere ser usuario root , escriba (sudo su) antes de entrar a menu / requires root user, type (sudo su) before entering menu" 0 50 exit 1 fi while : ; do choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu YSF Bridge" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion:" 23 56 13 \ 1 " Editar YSF BRIDGE 1 " \ 2 " Editar YSF BRIDGE 2 " \ 3 " Start & Restart YSF BRIDGE " \ 4 " Stop YSF Bridge " \ 5 " 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/ysf_bridge1/ysf_bridge.ini ;; 2) sudo nano /opt/ysf_bridge2/ysf_bridge.ini ;; 3) choix_servicio=$(whiptail --title "Iniciar YSF Bridge" --menu "Seleccione el Beacon a iniciar:" 15 40 8 \ 1 "YSF BRIDGE 1" \ 2 "YSF BRIDGE 2" \ 3>&1 1>&2 2>&3) exitstatus_servicio=$? if [ $exitstatus_servicio = 0 ]; then echo "Iniciar servicio: $choix_servicio" # Agrega aqui­ la logica para iniciar el servicio correspondiente (usando el valor de $choix_servicio) sudo systemctl stop ysf2ysf$choix_servicio.service && sudo systemctl start ysf2ysf$choix_servicio.service && sudo systemctl enable ysf2ysf$choix_servicio.service else echo "Volver al menu principal." fi ;; 4) choix_servicio=$(whiptail --title "Detener YSF Bridge" --menu "Seleccione el Beacon a detener:" 15 40 8 \ 1 "YSF BRIDGE 1" \ 2 "YSF BRIDGE 2" \ 3>&1 1>&2 2>&3) exitstatus_servicio=$? if [ $exitstatus_servicio = 0 ]; then echo "Detener servicio: $choix_servicio" # Agrega aqui la logica para iniciar el servicio correspondiente (usando el valor de $choix_servicio) sudo systemctl stop ysf2ysf$choix_servicio.service && sudo systemctl disable ysf2ysf$choix_servicio.service else echo "Volver al menu principal." fi ;; 5) break; esac done exit 0 EOF ###### chmod +x /bin/menu* ln -sf /bin/menu-ysf2ysf /bin/MENU-YSF2YSF chmod +x /bin/MENU*