#!/bin/bash if [ -f "/opt/wdp6" ] then echo "found file" else sudo cat > /opt/wdp6 <<- "EOFX" ############################################## # Select number port, P25Reflector Dashboard # ############################################## Web-Dashboar-Port: 80 EOFX fi sudo cat > /bin/menu-p25r <<- "EOF" #!/bin/bash while : ; do choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Reflector" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 11 \ 1 " Editar P25FReflector Server " \ 2 " Iniciar Reflector " \ 3 " Detener Reflector " \ 4 " Dashboard on " \ 5 " Dashboard off " \ 6 " Editar Puerto http " \ 7 " enable setup.php " \ 8 " remove setup.php " \ 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 /etc/P25Reflector.ini ;; 2) sudo systemctl stop P25Reflector.service && if ! sudo systemctl status P25Reflector.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable P25Reflector.service fi if systemctl status P25Reflector.service |grep "Active: active" >/dev/null 2>&1 then sudo systemctl restart P25Reflector.service else sudo systemctl start P25Reflector.service fi ;; 3) sudo systemctl stop P25Reflector.service && sudo systemctl disable P25Reflector.service ;; 4) if sudo systemctl status http.server-p25.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-p25.service fi if sudo systemctl status http.server-p25.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-p25.service fi variable80=$(grep "Web-Dashboar-Port:" /opt/wdp6 | 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\/p25/g" /lib/systemd/system/http.server-p25.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-p25.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-p25.service fi sudo systemctl start http.server-p25.service fi ;; 5) sudo systemctl stop http.server-p25.service && sudo systemctl disable http.server-p25.service ;; 6) if sudo systemctl status http.server-p25.service |grep active >/dev/null 2>&1 then sudo systemctl stop http.server-p25.service fi sudo nano /opt/wdp6 && variable80=$(grep "Web-Dashboar-Port:" /opt/wdp6 | 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\/p25/g" /lib/systemd/system/http.server-p25.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-p25.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl start http.server-p25.service fi fi ;; 7) cp /opt/P25Reflector-Dashboard/setup.php /var/www/p25/setup.php && whiptail --title "P25Reflector" --msgbox "setup.php is ready to use, refresh your browser / Setup.php esta lista para usar, actualiza tu navegador" 0 50 ;; 8) if [ -f "/var/www/p25/setup.php" ] then rm /var/www/p25/setup.php whiptail --title "P25Reflector" --msgbox "setup.php has removed / setup.php a sido removido" 0 50 else whiptail --title "P25Reflector" --msgbox "setup.php is not enabled / setup.php no esta habilitado" 0 50 fi ;; 9) break; esac done exit 0 EOF ######### chmod +x /bin/menu-p25r ln -sf /bin/menu-p25r /bin/MENU-P25R chmod +x /bin/MENU*