diff --git a/scripts/gpu_tpu/add_gpu_vm.sh b/scripts/gpu_tpu/add_gpu_vm.sh index 62edc608..086c0285 100644 --- a/scripts/gpu_tpu/add_gpu_vm.sh +++ b/scripts/gpu_tpu/add_gpu_vm.sh @@ -196,28 +196,6 @@ _set_wizard_result() { printf '%s\n' "$result" >"$GPU_WIZARD_RESULT_FILE" 2>/dev/null || true } -_wizard_alt_screen_enter() { - # More robust than relying only on terminfo smcup in some terminals. - printf '\033[?1049h\033[H' >/dev/tty 2>/dev/null || true -} - -_wizard_alt_screen_leave() { - printf '\033[?1049l' >/dev/tty 2>/dev/null || true -} - -_wizard_dialog_begin() { - [[ "$WIZARD_CALL" == "true" ]] || return 0 - _wizard_alt_screen_enter - tput smcup >/dev/tty 2>/dev/null || true - printf '\033[2J\033[H' >/dev/tty 2>/dev/null || true -} - -_wizard_dialog_end() { - [[ "$WIZARD_CALL" == "true" ]] || return 0 - tput rmcup >/dev/tty 2>/dev/null || true - _wizard_alt_screen_leave -} - _file_has_exact_line() { local line="$1" local file="$2" @@ -457,17 +435,13 @@ ensure_selected_gpu_not_already_in_target_vm() { exit 0 fi - local choice rc - _wizard_dialog_begin + local choice choice=$(dialog --clear --backtitle "ProxMenux" --colors \ --title "$(translate 'GPU Already Assigned to This VM')" \ --menu "\n$(translate 'The selected GPU is already present in this VM. Select another GPU to continue:')" \ 18 82 10 \ "${menu_items[@]}" \ - 2>&1 >/dev/tty) - rc=$? - _wizard_dialog_end - [[ $rc -ne 0 ]] && exit 0 + 3>&1 1>&2 2>&3) || exit 0 SELECTED_GPU="${ALL_GPU_TYPES[$choice]}" SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}" @@ -655,17 +629,13 @@ select_gpu() { menu_items+=("$i" "$label") done - local choice rc - _wizard_dialog_begin + local choice choice=$(dialog --clear --backtitle "ProxMenux" --colors \ --title "$(translate 'Select GPU for VM Passthrough')" \ --menu "\n$(translate 'Select the GPU to pass through to the VM:')" \ 18 82 10 \ "${menu_items[@]}" \ - 2>&1 >/dev/tty) - rc=$? - _wizard_dialog_end - [[ $rc -ne 0 ]] && exit 0 + 3>&1 1>&2 2>&3) || exit 0 SELECTED_GPU="${ALL_GPU_TYPES[$choice]}" SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}" @@ -1317,18 +1287,14 @@ check_switch_mode() { fi msg+="$(translate 'Choose conflict policy for the source VM:')" - local vm_action_choice rc - _wizard_dialog_begin + local vm_action_choice vm_action_choice=$(dialog --clear --backtitle "ProxMenux" --colors \ --title "$(translate 'GPU Already Assigned to Another VM')" \ --default-item "1" \ --menu "$msg" 24 98 8 \ "1" "$(translate 'Keep GPU in source VM config (disable Start on boot if enabled)')" \ "2" "$(translate 'Remove GPU from source VM config (keep Start on boot)')" \ - 2>&1 >/dev/tty) - rc=$? - _wizard_dialog_end - [[ $rc -ne 0 ]] && exit 0 + 3>&1 1>&2 2>&3) || exit 0 case "$vm_action_choice" in 1) SWITCH_VM_ACTION="keep_gpu_disable_onboot" ;; @@ -1406,14 +1372,10 @@ confirm_summary() { local run_title run_title=$(_get_vm_run_title) - local rc - _wizard_dialog_begin dialog --clear --backtitle "ProxMenux" --colors \ --title "${run_title}" \ --yesno "$msg" 28 78 - rc=$? - _wizard_dialog_end - [[ $rc -ne 0 ]] && exit 0 + [[ $? -ne 0 ]] && exit 0 }