我创建了一个循环来为新用户执行一些虚拟机设置功能,其中包括添加主机名、IP 地址等。但是,如果我在任何whiptail 窗口中单击“取消”按钮,它只是移动到循环中的下一个whiptail元素。Cancel
如果选择了它,我如何设置它以取消循环并返回主菜单窗口?
while true
do
OPTION=$(whiptail --title "Configuration Menu" --menu "Choose an option" 20 78 10 \
"1" "Show current configuration." \
"2" "Setup Wizard." \
...
"0" "EXIT" 3>&1 1>&2 2>&3)
exitstatus=$?
case "$OPTION" in
...
2)
# Setup hostname
HOSTNAME=$(whiptail --inputbox "Hostname" 8 78 `hostname` --title "Serial Number" 3>&1 1>&2 2>&3)
...
# IP address configuration
IP_CONFIG=$(whiptail --title "Network Configuration" --radiolist "Choose a configuration option" 20 78 10 \
"DHCP" "Use Dynamic Host Protocol" ON \
"STATIC" "Configure Static IP" OFF 3>&1 1>&2 2>&3)
...
;;
esac