How do I loop my fancy Bash Dialog menu?
So here is what I have, and I am very happy with what I have so far, but I do want to add a loop so when a command has been executed, ask for a "ENTER" strike and it will send you back to the menu...
#!/bin/bash
cmd=(dialog --keep-tite --menu "Welcome to Ernie's Utility Menu v1.0:" 22 76 16)
options=(1 "Hide Connection"
2 "Disconnect from VPN"
3 "Status of Connection"
4 "Update the system"
5 "Clean up post update mess"
6 "Deep Clean (Trojans and malware)"
7 "Speedometer (Bandwith Monitor)"
8 "Bmon (Bandwith Monitor)"
9 "Test Bandwith speed (up & down)"
10 "Snow in the terminal"
)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
for choice in $choices
do
case $choice in
1)
expressvpn connect
;;
2)
expressvpn disconnect
;;
3)
expressvpn status && nmcli dev wifi
;;
4)
sudo apt update && sudo apt upgrade -y #!//&& sudo apt-get dist-upgrade -y not sure if I want to do this part....
;;
5)
sudo apt update && sudo apt -f install && sudo dpkg --configure -a && sudo apt clean && sudo apt autoremove && sudo -k && exit
;;
6)
sudo chkrootkit -d && sudo rkhunter -c --rwo && sudo -k
;;
7)
speedometer -l -r wlp2s0 -t lo -m $(( 1024 * 1024 * 3 / 2 ))
;;
8)
bmon
;;
9)
speedtest
;;
10)
./snow.sh
;;
esac
done
At the end of the script add:
read -p "Hit enter to continue ..."
exec /bin/bash "$0" "$@"
the exec
command will re-execute the script, re-using the current process.