From bac7dcab563d0547fa374ff98dc9351b1687595c Mon Sep 17 00:00:00 2001 From: Script Proyect by HP3ICC Date: Fri, 24 May 2024 03:51:34 +0000 Subject: [PATCH] Add new file --- menu/menu-ap | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 menu/menu-ap diff --git a/menu/menu-ap b/menu/menu-ap new file mode 100644 index 0000000..edd0356 --- /dev/null +++ b/menu/menu-ap @@ -0,0 +1,64 @@ +#!/bin/bash +#menu-ap +cat > /bin/menu-ap <<- "EOF" +#!/bin/bash +while : ; do +choix=$(whiptail --title "WiFi auto AP option" --menu "Select enable or disable auto AP mode." 20 75 11 \ +1 " Disable auto AP mode" \ +2 " Enable auto AP mode " \ +3 " 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=("autoap.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 + ;; +2) +#!/bin/bash + +# Lista de servicios a reiniciar +servicios=("autoap.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 stop "$servicio" + sudo systemctl start "$servicio" + else + echo "start $servicio" + sudo systemctl stop "$servicio" + sudo systemctl start "$servicio" + sudo systemctl enable "$servicio" + fi +done +;; +3) +break; +esac +done +exit 0 +EOF +# +chmod +x /bin/menu-ap +ln -sf /bin/menu-ap /bin/MENU-AP +chmod +x /bin/MENU*