所以这就是我所拥有的,我对目前所拥有的非常满意,但我确实想添加一个循环,所以当执行命令时,要求按“ENTER”键,它会将您送回菜单...
#!/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
答案1
在脚本末尾添加:
read -p "Hit enter to continue ..."
exec /bin/bash "$0" "$@"
该exec
命令将重新执行脚本,重新使用当前进程。
答案2
所以,如果有人有兴趣回收这个菜单...这就是我的最终产品的样子;
#!/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"
# 11 "exit"
)
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
;;
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
;;
*)
exit
esac
read -p "Hit enter to continue ..."
exec /bin/bash "$0" "$@"
done