mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-25 00:46:21 +00:00
Update add_gpu_vm.sh
This commit is contained in:
@@ -196,6 +196,16 @@ _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_dialog_begin() {
|
||||||
|
[[ "$WIZARD_CALL" == "true" ]] || return 0
|
||||||
|
tput smcup >/dev/tty 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
_wizard_dialog_end() {
|
||||||
|
[[ "$WIZARD_CALL" == "true" ]] || return 0
|
||||||
|
tput rmcup >/dev/tty 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
_file_has_exact_line() {
|
_file_has_exact_line() {
|
||||||
local line="$1"
|
local line="$1"
|
||||||
local file="$2"
|
local file="$2"
|
||||||
@@ -435,22 +445,17 @@ ensure_selected_gpu_not_already_in_target_vm() {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local choice
|
local choice rc
|
||||||
if [[ "$WIZARD_CALL" == "true" ]]; then
|
_wizard_dialog_begin
|
||||||
choice=$(whiptail --backtitle "ProxMenux" \
|
choice=$(dialog --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[@]}" \
|
||||||
3>&1 1>&2 2>&3) || exit 0
|
2>&1 >/dev/tty)
|
||||||
else
|
rc=$?
|
||||||
choice=$(dialog --backtitle "ProxMenux" \
|
_wizard_dialog_end
|
||||||
--title "$(translate 'GPU Already Assigned to This VM')" \
|
[[ $rc -ne 0 ]] && exit 0
|
||||||
--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) || exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
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]}"
|
||||||
@@ -638,22 +643,17 @@ select_gpu() {
|
|||||||
menu_items+=("$i" "$label")
|
menu_items+=("$i" "$label")
|
||||||
done
|
done
|
||||||
|
|
||||||
local choice
|
local choice rc
|
||||||
if [[ "$WIZARD_CALL" == "true" ]]; then
|
_wizard_dialog_begin
|
||||||
choice=$(whiptail --backtitle "ProxMenux" \
|
choice=$(dialog --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[@]}" \
|
||||||
3>&1 1>&2 2>&3) || exit 0
|
2>&1 >/dev/tty)
|
||||||
else
|
rc=$?
|
||||||
choice=$(dialog --backtitle "ProxMenux" \
|
_wizard_dialog_end
|
||||||
--title "$(translate 'Select GPU for VM Passthrough')" \
|
[[ $rc -ne 0 ]] && exit 0
|
||||||
--menu "\n$(translate 'Select the GPU to pass through to the VM:')" \
|
|
||||||
18 82 10 \
|
|
||||||
"${menu_items[@]}" \
|
|
||||||
2>&1 >/dev/tty) || exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
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]}"
|
||||||
@@ -1305,23 +1305,18 @@ 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
|
local vm_action_choice rc
|
||||||
if [[ "$WIZARD_CALL" == "true" ]]; then
|
_wizard_dialog_begin
|
||||||
vm_action_choice=$(whiptail --backtitle "ProxMenux" \
|
vm_action_choice=$(dialog --backtitle "ProxMenux" --colors \
|
||||||
--title "$(translate 'GPU Already Assigned to Another VM')" \
|
--title "$(translate 'GPU Already Assigned to Another VM')" \
|
||||||
--menu "$msg" 24 98 8 \
|
--default-item "1" \
|
||||||
"1" "$(translate 'Keep GPU in source VM config (disable Start on boot if enabled)')" \
|
--menu "$msg" 24 98 8 \
|
||||||
"2" "$(translate 'Remove GPU from source VM config (keep Start on boot)')" \
|
"1" "$(translate 'Keep GPU in source VM config (disable Start on boot if enabled)')" \
|
||||||
3>&1 1>&2 2>&3) || exit 0
|
"2" "$(translate 'Remove GPU from source VM config (keep Start on boot)')" \
|
||||||
else
|
2>&1 >/dev/tty)
|
||||||
vm_action_choice=$(dialog --backtitle "ProxMenux" --colors \
|
rc=$?
|
||||||
--title "$(translate 'GPU Already Assigned to Another VM')" \
|
_wizard_dialog_end
|
||||||
--default-item "1" \
|
[[ $rc -ne 0 ]] && exit 0
|
||||||
--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) || exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
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" ;;
|
||||||
@@ -1399,15 +1394,14 @@ confirm_summary() {
|
|||||||
local run_title
|
local run_title
|
||||||
run_title=$(_get_vm_run_title)
|
run_title=$(_get_vm_run_title)
|
||||||
|
|
||||||
if [[ "$WIZARD_CALL" == "true" ]]; then
|
local rc
|
||||||
whiptail --backtitle "ProxMenux" --title "${run_title}" --yesno "$msg" 28 78
|
_wizard_dialog_begin
|
||||||
[[ $? -ne 0 ]] && exit 0
|
dialog --backtitle "ProxMenux" --colors \
|
||||||
else
|
--title "${run_title}" \
|
||||||
dialog --backtitle "ProxMenux" --colors \
|
--yesno "$msg" 28 78
|
||||||
--title "${run_title}" \
|
rc=$?
|
||||||
--yesno "$msg" 28 78
|
_wizard_dialog_end
|
||||||
[[ $? -ne 0 ]] && exit 0
|
[[ $rc -ne 0 ]] && exit 0
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user