Update add_gpu_vm.sh

This commit is contained in:
MacRimi
2026-04-06 22:34:37 +02:00
parent 2fda3dd1d5
commit c429d391f5

View File

@@ -196,28 +196,6 @@ _set_wizard_result() {
printf '%s\n' "$result" >"$GPU_WIZARD_RESULT_FILE" 2>/dev/null || true 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() { _file_has_exact_line() {
local line="$1" local line="$1"
local file="$2" local file="$2"
@@ -457,17 +435,13 @@ ensure_selected_gpu_not_already_in_target_vm() {
exit 0 exit 0
fi fi
local choice rc local choice
_wizard_dialog_begin
choice=$(dialog --clear --backtitle "ProxMenux" --colors \ choice=$(dialog --clear --backtitle "ProxMenux" --colors \
--title "$(translate 'GPU Already Assigned to This VM')" \ --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:')" \ --menu "\n$(translate 'The selected GPU is already present in this VM. Select another GPU to continue:')" \
18 82 10 \ 18 82 10 \
"${menu_items[@]}" \ "${menu_items[@]}" \
2>&1 >/dev/tty) 3>&1 1>&2 2>&3) || exit 0
rc=$?
_wizard_dialog_end
[[ $rc -ne 0 ]] && exit 0
SELECTED_GPU="${ALL_GPU_TYPES[$choice]}" SELECTED_GPU="${ALL_GPU_TYPES[$choice]}"
SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}" SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}"
@@ -655,17 +629,13 @@ select_gpu() {
menu_items+=("$i" "$label") menu_items+=("$i" "$label")
done done
local choice rc local choice
_wizard_dialog_begin
choice=$(dialog --clear --backtitle "ProxMenux" --colors \ choice=$(dialog --clear --backtitle "ProxMenux" --colors \
--title "$(translate 'Select GPU for VM Passthrough')" \ --title "$(translate 'Select GPU for VM Passthrough')" \
--menu "\n$(translate 'Select the GPU to pass through to the VM:')" \ --menu "\n$(translate 'Select the GPU to pass through to the VM:')" \
18 82 10 \ 18 82 10 \
"${menu_items[@]}" \ "${menu_items[@]}" \
2>&1 >/dev/tty) 3>&1 1>&2 2>&3) || exit 0
rc=$?
_wizard_dialog_end
[[ $rc -ne 0 ]] && exit 0
SELECTED_GPU="${ALL_GPU_TYPES[$choice]}" SELECTED_GPU="${ALL_GPU_TYPES[$choice]}"
SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}" SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}"
@@ -1317,18 +1287,14 @@ check_switch_mode() {
fi fi
msg+="$(translate 'Choose conflict policy for the source VM:')" msg+="$(translate 'Choose conflict policy for the source VM:')"
local vm_action_choice rc local vm_action_choice
_wizard_dialog_begin
vm_action_choice=$(dialog --clear --backtitle "ProxMenux" --colors \ vm_action_choice=$(dialog --clear --backtitle "ProxMenux" --colors \
--title "$(translate 'GPU Already Assigned to Another VM')" \ --title "$(translate 'GPU Already Assigned to Another VM')" \
--default-item "1" \ --default-item "1" \
--menu "$msg" 24 98 8 \ --menu "$msg" 24 98 8 \
"1" "$(translate 'Keep GPU in source VM config (disable Start on boot if enabled)')" \ "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" "$(translate 'Remove GPU from source VM config (keep Start on boot)')" \
2>&1 >/dev/tty) 3>&1 1>&2 2>&3) || exit 0
rc=$?
_wizard_dialog_end
[[ $rc -ne 0 ]] && exit 0
case "$vm_action_choice" in case "$vm_action_choice" in
1) SWITCH_VM_ACTION="keep_gpu_disable_onboot" ;; 1) SWITCH_VM_ACTION="keep_gpu_disable_onboot" ;;
@@ -1406,14 +1372,10 @@ confirm_summary() {
local run_title local run_title
run_title=$(_get_vm_run_title) run_title=$(_get_vm_run_title)
local rc
_wizard_dialog_begin
dialog --clear --backtitle "ProxMenux" --colors \ dialog --clear --backtitle "ProxMenux" --colors \
--title "${run_title}" \ --title "${run_title}" \
--yesno "$msg" 28 78 --yesno "$msg" 28 78
rc=$? [[ $? -ne 0 ]] && exit 0
_wizard_dialog_end
[[ $rc -ne 0 ]] && exit 0
} }