mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-27 21:00:40 +00:00
fix(misc): replace generic return 1 with specific exit codes in remaining .func files
Replace 80 generic 'return 1' error returns with specific exit codes across alpine-tools.func, build.func, core.func, cloud-init.func, and vm-core.func, matching the EXIT_CODES.md schema. alpine-tools.func (51 replaced): - check_for_gh_release, fetch_and_deploy_gh: API/DNS/download errors - setup_yq, setup_adminer, setup_uv, setup_java, setup_go, setup_composer - need_tool, download_with_progress build.func (13 replaced): - install_ssh_keys_into_ct: file operation errors (252) - choose_and_set_storage_for_file: parameter/service errors (65/150) - _find_default_vars, default_var_settings: file not found (252) - destroy_lxc, resolve_storage_preselect, select_storage: param errors (65) - validate_storage_space: hardware/space errors (236) core.func (9 replaced): - get_header: download failed (250) - prompt_select: no options (65) - check_or_create_swap: dd/mkswap/swapon failures (150), invalid size (65) - get_current_ip, get_lxc_ip: IP detection failed (6) cloud-init.func (6 replaced): - setup_cloud_init: invalid IP/gateway format (65) - configure_cloud_init_interactive: whiptail missing (127) - get_vm_ip, wait_for_cloud_init: timeout/connection errors (7/150) vm-core.func (1 replaced): - get_header: download failed (250) Boolean returns (validate_*, is_*, prompt_*, 'no update') kept as return 1.
This commit is contained in:
+9
-9
@@ -858,7 +858,7 @@ get_header() {
|
||||
if [ ! -s "$local_header_path" ]; then
|
||||
if ! curl -fsSL "$header_url" -o "$local_header_path"; then
|
||||
msg_warn "Failed to download header: $header_url"
|
||||
return 1
|
||||
return 250
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1358,7 +1358,7 @@ prompt_select() {
|
||||
if [[ $num_options -eq 0 ]]; then
|
||||
msg_warn "prompt_select called with no options"
|
||||
echo "" >&2
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
|
||||
# Validate default
|
||||
@@ -1600,7 +1600,7 @@ check_or_create_swap() {
|
||||
swap_size_mb=$(prompt_input "Enter swap size in MB (e.g., 2048 for 2GB):" "2048" 60)
|
||||
if ! [[ "$swap_size_mb" =~ ^[0-9]+$ ]]; then
|
||||
msg_error "Invalid swap size: '${swap_size_mb}' (must be a number in MB)"
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
|
||||
local swap_file="/swapfile"
|
||||
@@ -1608,19 +1608,19 @@ check_or_create_swap() {
|
||||
msg_info "Creating ${swap_size_mb}MB swap file at $swap_file"
|
||||
if ! dd if=/dev/zero of="$swap_file" bs=1M count="$swap_size_mb" status=progress; then
|
||||
msg_error "Failed to allocate swap file (dd failed)"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
if ! chmod 600 "$swap_file"; then
|
||||
msg_error "Failed to set permissions on $swap_file"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
if ! mkswap "$swap_file"; then
|
||||
msg_error "Failed to format swap file (mkswap failed)"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
if ! swapon "$swap_file"; then
|
||||
msg_error "Failed to activate swap (swapon failed)"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
msg_ok "Swap file created and activated successfully"
|
||||
}
|
||||
@@ -1699,13 +1699,13 @@ function get_lxc_ip() {
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
return 6
|
||||
}
|
||||
|
||||
LOCAL_IP="$(get_current_ip || true)"
|
||||
if [[ -z "$LOCAL_IP" ]]; then
|
||||
msg_error "Could not determine LOCAL_IP (checked: eth0, hostname -I, ip route, IPv6 targets)"
|
||||
return 1
|
||||
return 6
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user