Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions incus/backend.func
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ incus_validate_storage_space() {
msg_custom "ℹ️" "${YW}" "Grow: incus storage set ${pool} size=50GiB | Or pick another pool"
return 0
fi
msg_ok "Storage space validated (${pool}: ~${free_gb}GB free)"
}

resolve_storage_preselect() {
Expand Down Expand Up @@ -366,17 +365,15 @@ incus_create_lxc_container() {

if resolve_storage_preselect container "${CONTAINER_STORAGE:-}"; then
STORAGE_POOL="$STORAGE_RESULT"
msg_ok "Storage ${BL}${STORAGE_POOL}${CL} (${STORAGE_INFO}) [Container]"
elif [[ -z "${CONTAINER_STORAGE:-}" ]]; then
select_storage container && STORAGE_POOL="$CONTAINER_STORAGE"
msg_ok "Storage ${BL}${STORAGE_POOL}${CL} [Container]"
else
STORAGE_POOL="${CONTAINER_STORAGE}"
fi

msg_info "Validating storage '${STORAGE_POOL}'"
incus storage info "$STORAGE_POOL" &>/dev/null || { msg_error "Storage pool '${STORAGE_POOL}' invalid"; exit 213; }
msg_ok "Storage '${STORAGE_POOL}' validated"
msg_ok "Storage '${STORAGE_POOL}' validated${STORAGE_INFO:+ - ${STORAGE_INFO}}"

if ! incus network show "${BRG}" >/dev/null 2>&1; then
msg_warn "Network '${BRG}' not found, auto-selecting fallback"
Expand All @@ -393,13 +390,13 @@ incus_create_lxc_container() {
exit 106
elif ((resolve_rc == 0)); then
image_name="${INCUS_LAUNCH_IMAGE}"
msg_ok "Image ${BL}${image_name}${CL}"
msg_ok "Image ${BL}${image_name}${CL} (cached)"
else
image_name="${INCUS_LAUNCH_IMAGE:-images:${IMAGE_OS}/${IMAGE_VERSION}}"
msg_custom "ℹ️" "${YW}" "Image not cached yet — will try pull: ${image_name}"
msg_custom "ℹ️" "${YW}" "Image ${image_name} not cached, pulling"
fi

msg_info "Creating LXC Container"
msg_info "Creating container"
incus_log_section "Container Creation: ${CT_NAME}"

local launch_args=()
Expand Down Expand Up @@ -506,7 +503,7 @@ incus_create_lxc_container() {
fi
fi

msg_ok "LXC Container ${CT_NAME} was successfully created."
msg_ok "Container ${CT_NAME} created"

msg_info "Waiting for container to initialize"
local waited=0
Expand All @@ -515,7 +512,7 @@ incus_create_lxc_container() {
waited=$((waited + 2))
[[ "$waited" -ge 60 ]] && { msg_error "Container not ready"; exit 1; }
done
msg_ok "Container ${CT_NAME} is ready"
msg_ok "Container started"

incus_set_container_hostname

Expand Down Expand Up @@ -587,7 +584,6 @@ incus_set_container_hostname() {
hn=$(echo "$hn" | tr '[:upper:]' '[:lower:]' | tr -d ' ' | tr '_' '-')
[[ -z "$hn" ]] && return 0

msg_info "Setting hostname to ${hn}"
_incus_soft incus config set "${CT_NAME}" "user.hostname=${hn}" >>"${LOGFILE:-$INCUS_BUILD_LOG}" 2>&1
# Prefer instance name for system hostname when UI used CT_ID as name
local sys_hn="${CT_NAME}"
Expand All @@ -606,7 +602,7 @@ incus_set_container_hostname() {
fi
fi
" >>"${LOGFILE:-$INCUS_BUILD_LOG}" 2>&1; then
msg_ok "Hostname set to ${sys_hn}"
:
else
msg_warn "Could not set the hostname inside ${CT_NAME} (see the log)"
fi
Expand Down Expand Up @@ -902,7 +898,7 @@ incus_configure_device_passthrough() {
}

incus_wait_for_network() {
msg_info "Waiting for network in LXC container"
msg_info "Waiting for the container network"

local net_type="" max_wait=40
net_type=$(incus network show "${BRG:-}" 2>/dev/null | awk '/^type:/ {print $2; exit}')
Expand Down Expand Up @@ -946,9 +942,8 @@ incus_wait_for_network() {
msg_warn "Network configured (IP: $ip_in_lxc) but connectivity test failed"
echo -e "${YW}Container may have limited internet access. Installation will continue...${CL}"
else
msg_ok "Network in LXC is reachable (ping)"
msg_ok "Network reachable (${ip_in_lxc})"
fi
msg_ok "IP set to ${ip_in_lxc}"
export IP="$ip_in_lxc"
}

Expand Down Expand Up @@ -1002,7 +997,7 @@ incus_set_root_password() {
}

incus_customize_container() {
msg_info "Customizing LXC Container"
msg_info "Customizing container"
ARCH="$(_cs_host_arch)"

if [[ "${var_os:-debian}" == "alpine" ]]; then
Expand Down Expand Up @@ -1061,7 +1056,7 @@ EOF"
fi

incus_set_root_password
msg_ok "Customized LXC Container"
msg_ok "Container customized"
}

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -1091,14 +1086,12 @@ _incus_wait_for_detached_install() {
_incus_push_functions_and_run_install() {
# Sets INCUS_LAST_INSTALL_EXIT (do not capture stdout — msg_* writes there).
INCUS_LAST_INSTALL_EXIT=0
msg_info "Pushing functions to container"
incus_ct_exec bash -c "cat > /tmp/incus-functions <<'INNEREOF'
${FUNCTIONS_FILE_PATH}
INNEREOF" >>"${LOGFILE:-$INCUS_BUILD_LOG}" 2>&1 || { msg_error "Failed to push functions"; exit 1; }
msg_ok "Functions pushed"

if [[ "${DNS_RETRY_OVERRIDE:-}" == "true" ]]; then
msg_info "Applying DNS override inside LXC"
msg_info "Applying the DNS override (8.8.8.8, 1.1.1.1)"
incus_ct_exec bash -c "echo -e 'nameserver 8.8.8.8\nnameserver 1.1.1.1' >/etc/resolv.conf" || true
msg_ok "DNS override applied"
fi
Expand Down Expand Up @@ -1249,7 +1242,6 @@ _incus_build_combined_log() {
}

incus_run_install_script_with_recovery() {
msg_info "Preparing installation"
incus_log_section "Application Installation: ${APP}"

declare -f start_install_timer &>/dev/null && start_install_timer || true
Expand All @@ -1261,7 +1253,6 @@ incus_run_install_script_with_recovery() {
local install_exit_code="${INCUS_LAST_INSTALL_EXIT:-1}"

if [[ "$install_exit_code" -eq 0 ]]; then
msg_ok "Installation completed"
CONTAINER_INSTALLING=false
INCUS_BUILD_OK=1
export INCUS_BUILD_OK
Expand Down Expand Up @@ -1569,7 +1560,6 @@ incus_build_container() {
_incus_prepare_install_exports

if [[ -n "${CONTAINER_STORAGE:-$STORAGE_POOL}" ]]; then
msg_info "Validating storage space"
incus_validate_storage_space "${CONTAINER_STORAGE:-$STORAGE_POOL}" "${DISK_SIZE}" || true
fi

Expand Down
16 changes: 8 additions & 8 deletions lxc/install.func
Original file line number Diff line number Diff line change
Expand Up @@ -1274,14 +1274,14 @@ network_check() {
msg_error "IPv4 Internet Not Connected"
fi

# Check IPv6 connectivity to Google, Cloudflare & Quad9 DNS servers.
if command -v ping6 &>/dev/null; then
if ping6 -c 1 -W 1 2606:4700:4700::1111 &>/dev/null || ping6 -c 1 -W 1 2001:4860:4860::8888 &>/dev/null || ping6 -c 1 -W 1 2620:fe::fe &>/dev/null; then
msg_ok "IPv6 Internet Connected"
ipv6_connected=true
else
msg_error "IPv6 Internet Not Connected"
fi
# Debian's iputils no longer ships a ping6 binary; and missing IPv6 is not an error.
local -a _ping6=(ping6)
command -v ping6 &>/dev/null || _ping6=(ping -6)
if "${_ping6[@]}" -c 1 -W 1 2606:4700:4700::1111 &>/dev/null || "${_ping6[@]}" -c 1 -W 1 2001:4860:4860::8888 &>/dev/null || "${_ping6[@]}" -c 1 -W 1 2620:fe::fe &>/dev/null; then
msg_ok "IPv6 Internet Connected"
ipv6_connected=true
else
msg_custom "ℹ️" "${YW}" "No IPv6 Internet (IPv4 is enough)"
fi

# If both IPv4 and IPv6 checks fail, prompt the user
Expand Down
34 changes: 14 additions & 20 deletions pve/backend.func
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ $PCT_OPTIONS_STRING"
# Validate storage space only if CONTAINER_STORAGE is already set
# (Storage selection happens in create_lxc_container for some modes)
if [[ -n "$CONTAINER_STORAGE" ]]; then
msg_info "Validating storage space"
if ! validate_storage_space "$CONTAINER_STORAGE" "$DISK_SIZE" "no"; then
local free_space
free_space=$(pvesm status 2>/dev/null | awk -v s="$CONTAINER_STORAGE" '$1 == s { print $6 }')
Expand All @@ -671,7 +670,6 @@ $PCT_OPTIONS_STRING"
msg_error "Not enough space on '$CONTAINER_STORAGE'. Required: ${DISK_SIZE}GB, Available: ${free_fmt}"
exit 214
fi
msg_ok "Storage space validated"
check_storage_health "$CONTAINER_STORAGE" "$DISK_SIZE"
fi

Expand Down Expand Up @@ -989,7 +987,7 @@ EOF
# START CONTAINER AND INSTALL USERLAND
# ============================================================================

msg_info "Starting LXC Container"
msg_info "Starting container"
# Checked, and with its own code. Unchecked, a failure here surfaced as pct's
# generic 255 -- which the exit table reads as DPKG's fatal error, so 197 runs
# across 70 apps in a fortnight were filed as a package manager problem when
Expand All @@ -1004,22 +1002,22 @@ EOF
# Wait for container to be running
for i in {1..10}; do
if pct status "$CTID" | grep -q "status: running"; then
msg_ok "Started LXC Container"
msg_ok "Container started"
break
fi
sleep 1
if [ "$i" -eq 10 ]; then
local ct_status
ct_status=$(pct status "$CTID" 2>/dev/null || echo "unknown")
msg_error "LXC Container did not reach running state (status: ${ct_status})"
msg_error "Container did not reach running state (status: ${ct_status})"
_pct_start_failed "$CTID" "$_start_out"
exit 117
fi
done

# Wait for network (skip for Alpine initially)
if [ "$var_os" != "alpine" ]; then
msg_info "Waiting for network in LXC container"
msg_info "Waiting for the container network"

# Wait for IP assignment (IPv4 or IPv6)
local ip_in_lxc=""
Expand Down Expand Up @@ -1067,7 +1065,7 @@ EOF
if [ "$ping_success" = false ]; then
msg_warn "Network configured (IP: $ip_in_lxc) but connectivity test failed - installation will continue"
else
msg_ok "Network in LXC is reachable (ping)"
msg_ok "Network reachable (${ip_in_lxc})"
fi
fi
# Function to get correct GID inside container
Expand All @@ -1088,7 +1086,7 @@ EOF
fi
fi

msg_info "Customizing LXC Container"
msg_info "Customizing container"

set +Eeuo pipefail
trap - ERR
Expand Down Expand Up @@ -1396,12 +1394,12 @@ PROFILE
fi

if [[ $install_exit_code -eq 0 ]]; then
msg_ok "Customized LXC Container"
msg_ok "Container customized"

if [[ "${DNS_RETRY_OVERRIDE:-false}" == "true" ]]; then
msg_info "Applying DNS retry override in LXC (8.8.8.8, 1.1.1.1)"
msg_info "Applying the DNS override (8.8.8.8, 1.1.1.1)"
pct exec "$CTID" -- bash -c "printf 'nameserver 8.8.8.8\nnameserver 1.1.1.1\n' >/etc/resolv.conf" >/dev/null 2>&1 || true
msg_ok "DNS override applied in LXC"
msg_ok "DNS override applied"
fi

install_ssh_keys_into_ct
Expand Down Expand Up @@ -3079,24 +3077,20 @@ create_lxc_container() {
if resolve_storage_preselect template "${TEMPLATE_STORAGE:-}"; then
TEMPLATE_STORAGE="$STORAGE_RESULT"
TEMPLATE_STORAGE_INFO="$STORAGE_INFO"
msg_ok "Storage ${BL}${TEMPLATE_STORAGE}${CL} (${TEMPLATE_STORAGE_INFO}) [Template]"
else
_storage_preselect_recover template "${TEMPLATE_STORAGE:-}" || exit 120
TEMPLATE_STORAGE="$STORAGE_RESULT"
TEMPLATE_STORAGE_INFO="$STORAGE_INFO"
msg_ok "Storage ${BL}${TEMPLATE_STORAGE}${CL} (${TEMPLATE_STORAGE_INFO}) [Template]"
fi

# Container storage selection
if resolve_storage_preselect container "${CONTAINER_STORAGE:-}"; then
CONTAINER_STORAGE="$STORAGE_RESULT"
CONTAINER_STORAGE_INFO="$STORAGE_INFO"
msg_ok "Storage ${BL}${CONTAINER_STORAGE}${CL} (${CONTAINER_STORAGE_INFO}) [Container]"
else
_storage_preselect_recover container "${CONTAINER_STORAGE:-}" || exit 119
CONTAINER_STORAGE="$STORAGE_RESULT"
CONTAINER_STORAGE_INFO="$STORAGE_INFO"
msg_ok "Storage ${BL}${CONTAINER_STORAGE}${CL} (${CONTAINER_STORAGE_INFO}) [Container]"
fi

msg_info "Validating storage '$CONTAINER_STORAGE'"
Expand Down Expand Up @@ -3165,15 +3159,15 @@ create_lxc_container() {
if [[ "$STORAGE_TYPE" == "lvmthin" ]] && ! _lvmthin_check "$CONTAINER_STORAGE"; then
exit 214
fi
msg_ok "Storage '$CONTAINER_STORAGE' ($STORAGE_TYPE) validated"
msg_ok "Storage '$CONTAINER_STORAGE' ($STORAGE_TYPE) validated${CONTAINER_STORAGE_INFO:+ - ${CONTAINER_STORAGE_INFO}}"

msg_info "Validating template storage '$TEMPLATE_STORAGE'"
TEMPLATE_TYPE=$(grep -E "^[^:]+: $TEMPLATE_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1 || true)

if ! pvesm status -content vztmpl 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$TEMPLATE_STORAGE"; then
msg_warn "Template storage '$TEMPLATE_STORAGE' may not support 'vztmpl'"
fi
msg_ok "Template storage '$TEMPLATE_STORAGE' validated"
msg_ok "Template storage '$TEMPLATE_STORAGE' validated${TEMPLATE_STORAGE_INFO:+ - ${TEMPLATE_STORAGE_INFO}}"

# Cluster quorum (if cluster)
if [[ -f /etc/pve/corosync.conf ]]; then
Expand Down Expand Up @@ -3234,7 +3228,7 @@ create_lxc_container() {
rm -f "$TEMPLATE_PATH"
download_catalog_template "$TEMPLATE_PATH"
else
msg_ok "Template ${BL}$TEMPLATE${CL} found locally."
msg_ok "Template ${BL}$TEMPLATE${CL} (local)"
fi

else
Expand Down Expand Up @@ -3481,7 +3475,7 @@ create_lxc_container() {
# ------------------------------------------------------------------------------
# Create LXC Container
# ------------------------------------------------------------------------------
msg_info "Creating LXC container"
msg_info "Creating container"

# Ensure subuid/subgid entries exist
grep -q "root:100000:65536" /etc/subuid || echo "root:100000:65536" >>/etc/subuid
Expand Down Expand Up @@ -3769,7 +3763,7 @@ create_lxc_container() {
exit 216
}

msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created."
msg_ok "Container ${BL}$CTID${CL} created"

if [[ -s "$LOGFILE" && -n "${BUILD_LOG:-}" ]]; then
{
Expand Down
Loading