我想向对话框bash脚本添加选项
我给这次狂欢做了编码我想向对话框bash脚本添加选项,bash,dialog,option,Bash,Dialog,Option,我给这次狂欢做了编码 #!/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 "
#!/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
当我按Setup转到另一个bash设置,或按nginx Setup转到bash进行nginx设置时,如何添加选项?您有两个选项,可以为脚本中的每个菜单项创建一个函数,如下所示:
function setup {
# code to show the new dialog with all the new options and chioces
}
或者使用新对话框创建单独的脚本,例如,对于设置选项,创建一个新的设置脚本文件,然后从案例块中调用,如下所示:
Setup) ./setup ;;