mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-10-09 06:56:37 +00:00
fix(i18n): natural Spanish for the menus and the OCI catalogue.
This commit is contained in:
@@ -251,7 +251,7 @@ detect_host_gpus() {
|
||||
# Container selection
|
||||
# ============================================================
|
||||
select_container() {
|
||||
local menu_items=()
|
||||
local menu_items=() oci_hidden=0
|
||||
while IFS= read -r line; do
|
||||
[[ "$line" =~ ^VMID ]] && continue
|
||||
local ctid status name
|
||||
@@ -259,19 +259,26 @@ select_container() {
|
||||
status=$(echo "$line" | awk '{print $2}')
|
||||
name=$(echo "$line" | awk '{print $3}')
|
||||
[[ -z "$ctid" ]] && continue
|
||||
if pmx_lxc_is_oci "$ctid"; then
|
||||
oci_hidden=$((oci_hidden + 1))
|
||||
continue
|
||||
fi
|
||||
menu_items+=("$ctid" "${name:-CT-${ctid}} (${status})")
|
||||
done < <(pct list 2>/dev/null)
|
||||
|
||||
local oci_note="" list_h=12
|
||||
[[ $oci_hidden -gt 0 ]] && list_h=7 && oci_note="\n\n$(translate 'Containers created from an OCI image are not listed: their devices are changed in OCI manager Apps (Recreate).')"
|
||||
|
||||
if [[ ${#menu_items[@]} -eq 0 ]]; then
|
||||
dialog --backtitle "ProxMenux" \
|
||||
--title "$(translate 'Add GPU to LXC')" \
|
||||
--msgbox "\n$(translate 'No LXC containers found on this system.')" 8 60
|
||||
--msgbox "\n$(translate 'No LXC containers found on this system.')${oci_note}" 12 66
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CONTAINER_ID=$(dialog --backtitle "ProxMenux" \
|
||||
--title "$(translate 'Add GPU to LXC')" \
|
||||
--menu "\n$(translate 'Select the LXC container:')" 20 72 12 \
|
||||
--menu "\n$(translate 'Select the LXC container:')${oci_note}" 20 72 "$list_h" \
|
||||
"${menu_items[@]}" \
|
||||
2>&1 >/dev/tty) || exit 0
|
||||
}
|
||||
|
||||
@@ -1402,7 +1402,7 @@ check_switch_mode() {
|
||||
SWITCH_FROM_LXC=true
|
||||
SWITCH_LXC_LIST=$(IFS=', '; echo "${lxc_affected[*]}")
|
||||
|
||||
local msg action_choice
|
||||
local msg action_choice oci_count=0
|
||||
msg="\n$(translate 'The selected GPU is currently used by the following LXC container(s):')\n\n"
|
||||
local i
|
||||
for i in "${!LXC_AFFECTED_CTIDS[@]}"; do
|
||||
@@ -1411,8 +1411,13 @@ check_switch_mode() {
|
||||
onboot_txt="onboot=0"
|
||||
[[ "${LXC_AFFECTED_RUNNING[$i]}" == "1" ]] && status_txt="$(translate 'running')"
|
||||
[[ "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]] && onboot_txt="onboot=1"
|
||||
if pmx_lxc_is_oci "${LXC_AFFECTED_CTIDS[$i]}"; then
|
||||
onboot_txt+=", OCI"
|
||||
oci_count=$((oci_count + 1))
|
||||
fi
|
||||
msg+=" • CT ${LXC_AFFECTED_CTIDS[$i]} (${LXC_AFFECTED_NAMES[$i]}) [${status_txt}, ${onboot_txt}]\n"
|
||||
done
|
||||
[[ "$oci_count" -gt 0 ]] && msg+="\n$(translate 'OCI containers keep their configuration: they are stopped and their Start on boot is disabled. Their GPU is removed from OCI manager Apps, with Recreate.')\n"
|
||||
msg+="\n$(translate 'VM passthrough requires exclusive VFIO binding of the GPU.')\n"
|
||||
msg+="$(translate 'Choose how to handle affected LXC containers before switching to VM mode.')\n\n"
|
||||
[[ "$running_count" -gt 0 ]] && \
|
||||
@@ -1421,17 +1426,22 @@ check_switch_mode() {
|
||||
msg+="\Z1\Zb$(translate 'Start on boot enabled (onboot=1)'): ${onboot_count}\Zn\n"
|
||||
msg+="\n\Z1$(translate 'After this LXC → VM switch, reboot the host so the new binding state is applied cleanly.')\Zn"
|
||||
|
||||
action_choice=$(_pmx_menu --default-item "2" \
|
||||
"$(translate 'GPU Used in LXC Containers')" \
|
||||
"$msg" 25 96 8 \
|
||||
"1" "$(translate 'Keep GPU in LXC config (disable Start on boot)')" \
|
||||
"2" "$(translate 'Remove GPU from LXC config (keep Start on boot)')") || exit 0
|
||||
if [[ "$oci_count" -eq ${#LXC_AFFECTED_CTIDS[@]} ]]; then
|
||||
LXC_SWITCH_ACTION="keep_gpu_disable_onboot"
|
||||
_pmx_msgbox "$(translate 'GPU Used in LXC Containers')" "$msg" 25 96
|
||||
else
|
||||
action_choice=$(_pmx_menu --default-item "2" \
|
||||
"$(translate 'GPU Used in LXC Containers')" \
|
||||
"$msg" 25 96 8 \
|
||||
"1" "$(translate 'Keep GPU in LXC config (disable Start on boot)')" \
|
||||
"2" "$(translate 'Remove GPU from LXC config (keep Start on boot)')") || exit 0
|
||||
|
||||
case "$action_choice" in
|
||||
1) LXC_SWITCH_ACTION="keep_gpu_disable_onboot" ;;
|
||||
2) LXC_SWITCH_ACTION="remove_gpu_keep_onboot" ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
case "$action_choice" in
|
||||
1) LXC_SWITCH_ACTION="keep_gpu_disable_onboot" ;;
|
||||
2) LXC_SWITCH_ACTION="remove_gpu_keep_onboot" ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
SWITCH_FROM_LXC=false
|
||||
fi
|
||||
@@ -1942,7 +1952,15 @@ cleanup_lxc_configs() {
|
||||
msg_ok "$(translate 'LXC already stopped') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
|
||||
if [[ "$LXC_SWITCH_ACTION" == "keep_gpu_disable_onboot" ]]; then
|
||||
# OCI manager Apps keeps the record of what an OCI container has: its
|
||||
# configuration is not edited from here.
|
||||
local action="$LXC_SWITCH_ACTION"
|
||||
if pmx_lxc_is_oci "$ctid"; then
|
||||
action="keep_gpu_disable_onboot"
|
||||
msg_warn "$(translate 'OCI container, configuration kept. Remove its GPU from OCI manager Apps, with Recreate: CT') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
|
||||
if [[ "$action" == "keep_gpu_disable_onboot" ]]; then
|
||||
if [[ "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]]; then
|
||||
if pct set "$ctid" -onboot 0 >>"$LOG_FILE" 2>&1; then
|
||||
msg_warn "$(translate 'Start on boot disabled for LXC') ${ctid}" | tee -a "$screen_capture"
|
||||
@@ -1952,7 +1970,7 @@ cleanup_lxc_configs() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LXC_SWITCH_ACTION" == "remove_gpu_keep_onboot" && -f "$conf" ]]; then
|
||||
if [[ "$action" == "remove_gpu_keep_onboot" && -f "$conf" ]]; then
|
||||
_remove_selected_gpu_from_lxc_conf "$conf"
|
||||
msg_ok "$(translate 'GPU access removed from LXC') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
|
||||
@@ -63,7 +63,7 @@ initialize_cache
|
||||
# ==========================================================
|
||||
|
||||
select_container() {
|
||||
local menu_items=()
|
||||
local menu_items=() oci_hidden=0
|
||||
while IFS= read -r line; do
|
||||
[[ "$line" =~ ^VMID ]] && continue
|
||||
local ctid status name
|
||||
@@ -71,19 +71,26 @@ select_container() {
|
||||
status=$(echo "$line" | awk '{print $2}')
|
||||
name=$(echo "$line" | awk '{print $3}')
|
||||
[[ -z "$ctid" ]] && continue
|
||||
if pmx_lxc_is_oci "$ctid"; then
|
||||
oci_hidden=$((oci_hidden + 1))
|
||||
continue
|
||||
fi
|
||||
menu_items+=("$ctid" "${name:-CT-${ctid}} (${status})")
|
||||
done < <(pct list 2>/dev/null)
|
||||
|
||||
local oci_note="" list_h=12
|
||||
[[ $oci_hidden -gt 0 ]] && list_h=7 && oci_note="\n\n$(translate 'Containers created from an OCI image are not listed: their devices are changed in OCI manager Apps (Recreate).')"
|
||||
|
||||
if [[ ${#menu_items[@]} -eq 0 ]]; then
|
||||
dialog --backtitle "ProxMenux" \
|
||||
--title "$(translate 'Install Coral TPU in LXC')" \
|
||||
--msgbox "\n$(translate 'No LXC containers found on this system.')" 8 60
|
||||
--msgbox "\n$(translate 'No LXC containers found on this system.')${oci_note}" 12 66
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CONTAINER_ID=$(dialog --backtitle "ProxMenux" \
|
||||
--title "$(translate 'Install Coral TPU in LXC')" \
|
||||
--menu "\n$(translate 'Select the LXC container:')" 20 72 12 \
|
||||
--menu "\n$(translate 'Select the LXC container:')${oci_note}" 20 72 "$list_h" \
|
||||
"${menu_items[@]}" \
|
||||
2>&1 >/dev/tty) || exit 0
|
||||
|
||||
|
||||
@@ -770,7 +770,7 @@ detect_affected_lxc_for_selected() {
|
||||
prompt_lxc_action_for_vm_mode() {
|
||||
[[ ${#LXC_AFFECTED_CTIDS[@]} -eq 0 ]] && return 0
|
||||
|
||||
local running_count=0 onboot_count=0 i
|
||||
local running_count=0 onboot_count=0 oci_count=0 i
|
||||
for i in "${!LXC_AFFECTED_CTIDS[@]}"; do
|
||||
[[ "${LXC_AFFECTED_RUNNING[$i]}" == "1" ]] && running_count=$((running_count + 1))
|
||||
[[ "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]] && onboot_count=$((onboot_count + 1))
|
||||
@@ -783,11 +783,23 @@ prompt_lxc_action_for_vm_mode() {
|
||||
st="$(translate 'stopped')"; ob="onboot=0"
|
||||
[[ "${LXC_AFFECTED_RUNNING[$i]}" == "1" ]] && st="$(translate 'running')"
|
||||
[[ "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]] && ob="onboot=1"
|
||||
if pmx_lxc_is_oci "${LXC_AFFECTED_CTIDS[$i]}"; then
|
||||
ob+=", OCI"
|
||||
oci_count=$((oci_count + 1))
|
||||
fi
|
||||
msg+=" • CT ${LXC_AFFECTED_CTIDS[$i]} (${LXC_AFFECTED_NAMES[$i]}) [${st}, ${ob}]\n"
|
||||
done
|
||||
[[ "$oci_count" -gt 0 ]] && msg+="\n$(translate 'OCI containers keep their configuration: they are stopped and their Start on boot is disabled. Their GPU is removed from OCI manager Apps, with Recreate.')\n"
|
||||
msg+="\n$(translate 'Switching to GPU -> VM mode requires exclusive VFIO binding.')\n"
|
||||
[[ "$running_count" -gt 0 ]] && msg+="\Z1$(translate 'Running containers detected'): ${running_count}\Zn\n"
|
||||
[[ "$onboot_count" -gt 0 ]] && msg+="\Z1\Zb$(translate 'Start on boot enabled'): ${onboot_count}\Zn\n"
|
||||
if [[ "$oci_count" -eq ${#LXC_AFFECTED_CTIDS[@]} ]]; then
|
||||
LXC_ACTION="keep_gpu_disable_onboot"
|
||||
dialog --backtitle "ProxMenux" --colors \
|
||||
--title "$(translate 'LXC Conflict Policy')" \
|
||||
--msgbox "$msg" 22 80
|
||||
return 0
|
||||
fi
|
||||
msg+="\n$(translate 'Choose conflict policy:')"
|
||||
|
||||
choice=$(dialog --backtitle "ProxMenux" --colors \
|
||||
@@ -849,13 +861,21 @@ apply_lxc_action_for_vm_mode() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LXC_ACTION" == "keep_gpu_disable_onboot" && "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]]; then
|
||||
# OCI manager Apps keeps the record of what an OCI container has: its
|
||||
# configuration is not edited from here.
|
||||
local action="$LXC_ACTION"
|
||||
if pmx_lxc_is_oci "$ctid"; then
|
||||
action="keep_gpu_disable_onboot"
|
||||
msg_warn "$(translate 'OCI container, configuration kept. Remove its GPU from OCI manager Apps, with Recreate: CT') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
|
||||
if [[ "$action" == "keep_gpu_disable_onboot" && "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]]; then
|
||||
if pct set "$ctid" -onboot 0 >>"$LOG_FILE" 2>&1; then
|
||||
msg_warn "$(translate 'Start on boot disabled for LXC') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LXC_ACTION" == "remove_gpu_keep_onboot" && -f "$conf" ]]; then
|
||||
if [[ "$action" == "remove_gpu_keep_onboot" && -f "$conf" ]]; then
|
||||
local t
|
||||
for t in "${types[@]}"; do
|
||||
_remove_type_from_lxc_conf "$conf" "$t"
|
||||
|
||||
@@ -596,7 +596,7 @@ detect_affected_lxc_for_selected() {
|
||||
prompt_lxc_action_for_vm_mode() {
|
||||
[[ ${#LXC_AFFECTED_CTIDS[@]} -eq 0 ]] && return 0
|
||||
|
||||
local running_count=0 onboot_count=0 i
|
||||
local running_count=0 onboot_count=0 oci_count=0 i
|
||||
for i in "${!LXC_AFFECTED_CTIDS[@]}"; do
|
||||
[[ "${LXC_AFFECTED_RUNNING[$i]}" == "1" ]] && running_count=$((running_count + 1))
|
||||
[[ "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]] && onboot_count=$((onboot_count + 1))
|
||||
@@ -609,11 +609,21 @@ prompt_lxc_action_for_vm_mode() {
|
||||
st="$(translate 'stopped')"; ob="onboot=0"
|
||||
[[ "${LXC_AFFECTED_RUNNING[$i]}" == "1" ]] && st="$(translate 'running')"
|
||||
[[ "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]] && ob="onboot=1"
|
||||
if pmx_lxc_is_oci "${LXC_AFFECTED_CTIDS[$i]}"; then
|
||||
ob+=", OCI"
|
||||
oci_count=$((oci_count + 1))
|
||||
fi
|
||||
msg+=" - CT ${LXC_AFFECTED_CTIDS[$i]} (${LXC_AFFECTED_NAMES[$i]}) [${st}, ${ob}]\n"
|
||||
done
|
||||
[[ "$oci_count" -gt 0 ]] && msg+="\n$(translate 'OCI containers keep their configuration: they are stopped and their Start on boot is disabled. Their GPU is removed from OCI manager Apps, with Recreate.')\n"
|
||||
msg+="\n$(translate 'Switching to GPU -> VM mode requires exclusive VFIO binding.')\n"
|
||||
[[ "$running_count" -gt 0 ]] && msg+="$(translate 'Running containers detected'): ${running_count}\n"
|
||||
[[ "$onboot_count" -gt 0 ]] && msg+="$(translate 'Start on boot enabled'): ${onboot_count}\n"
|
||||
if [[ "$oci_count" -eq ${#LXC_AFFECTED_CTIDS[@]} ]]; then
|
||||
LXC_ACTION="keep_gpu_disable_onboot"
|
||||
hybrid_msgbox "$(translate 'LXC Conflict Policy')" "$msg" 22 80
|
||||
return 0
|
||||
fi
|
||||
msg+="\n$(translate 'Choose conflict policy'):"
|
||||
|
||||
local choice
|
||||
@@ -675,13 +685,21 @@ apply_lxc_action_for_vm_mode() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LXC_ACTION" == "keep_gpu_disable_onboot" && "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]]; then
|
||||
# OCI manager Apps keeps the record of what an OCI container has: its
|
||||
# configuration is not edited from here.
|
||||
local action="$LXC_ACTION"
|
||||
if pmx_lxc_is_oci "$ctid"; then
|
||||
action="keep_gpu_disable_onboot"
|
||||
msg_warn "$(translate 'OCI container, configuration kept. Remove its GPU from OCI manager Apps, with Recreate: CT') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
|
||||
if [[ "$action" == "keep_gpu_disable_onboot" && "${LXC_AFFECTED_ONBOOT[$i]}" == "1" ]]; then
|
||||
if pct set "$ctid" -onboot 0 >>"$LOG_FILE" 2>&1; then
|
||||
msg_warn "$(translate 'Start on boot disabled for LXC') ${ctid}" | tee -a "$screen_capture"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LXC_ACTION" == "remove_gpu_keep_onboot" && -f "$conf" ]]; then
|
||||
if [[ "$action" == "remove_gpu_keep_onboot" && -f "$conf" ]]; then
|
||||
local t
|
||||
for t in "${types[@]}"; do
|
||||
_remove_type_from_lxc_conf "$conf" "$t"
|
||||
|
||||
Reference in New Issue
Block a user