我编写了这个Bash
#!/bin/bash
options=(
--backtitle "Setup Scripts "
--title "[Main Menu]"
--menu "You can use the UP/DOWN arrow keys, Or the number keys 1-9 to choose an option.
Choose the option" 18 70 8
)
choices=(
Setup "Start Setup And Secure this Server"
Nginx_Setup "Install Nginx"
Anti_MaleWare "Install Anti-MaleWare"
Softaculous "Install Softaculous"
ModSec "Install ModSecurity"
OpsView "Add OpsView Agent"
External_Backup "Add This Server To External Backup"
Check_Backup "Check Backup Configration"
)
menuitem=$( dialog "${options[@]}" "${choices[@]}" 3>&1 1>&2 2>&3 3>&- )
case $menuitem in
Setup) setup ;;
Nginx_Setup) nginx ;;
Anti-MaleWare) anti-maleware ;;
Softaculous) Softaculous ;;
ModSec) modsec ;;
OpsView) opsview ;;
External_Backup) externalbackup ;;
Check_Backup) configbackup ;;
"") clear ;;
esac
当我按下设置进入另一个bash设置时,如何添加选项,或按nginx设置进入Bash进行设置Nginx?
答案 0 :(得分:0)
您有两个选项,要么为脚本中的每个菜单项创建一个函数,如下所示:
function setup {
# code to show the new dialog with all the new options and chioces
}
或者您使用新对话框制作单独的脚本,例如。对于安装选项,您可以创建一个新的安装脚本文件,而不是从您的案例块调用,如下所示:
Setup) ./setup ;;