Skip to content

Commit fdc3094

Browse files
committed
feat(preflight): add enterprise repo subscription check
- New preflight_repo_access() warns if enterprise repos are active without subscription - Scans /etc/apt/sources.list.d/ for enterprise.proxmox.com entries - Tests HTTP access (detects 401/403 Unauthorized) - Warning only — not a blocker (packages come from pve-no-subscription repo)
1 parent d242100 commit fdc3094

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

misc/build.func

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ fi
113113
# - Kernel: keyring limits (maxkeys/maxbytes for UID 100000)
114114
# - Storage: rootdir support, vztmpl support, available space
115115
# - Network: bridge availability, DNS resolution
116+
# - Repos: enterprise repo subscription validation
116117
# - Cluster: quorum status (if clustered)
117118
# - Proxmox: LXC stack health, container ID availability
118119
# - Template: download server reachability
@@ -348,6 +349,42 @@ preflight_dns_resolution() {
348349
return 0
349350
}
350351

352+
# ------------------------------------------------------------------------------
353+
# preflight_repo_access()
354+
#
355+
# - Checks if Proxmox enterprise repos are enabled without a valid subscription
356+
# - Scans /etc/apt/sources.list.d/ for enterprise.proxmox.com entries
357+
# - Tests HTTP access to detect 401 Unauthorized
358+
# - Warning only (not a blocker — packages come from no-subscription repo)
359+
# ------------------------------------------------------------------------------
360+
preflight_repo_access() {
361+
local enterprise_files
362+
enterprise_files=$(grep -rlE '^\s*deb\s+https://enterprise\.proxmox\.com' /etc/apt/sources.list.d/ 2>/dev/null || true)
363+
364+
if [[ -z "$enterprise_files" ]]; then
365+
preflight_pass "No enterprise repositories enabled"
366+
return 0
367+
fi
368+
369+
# Enterprise repo found — test if subscription is valid
370+
local http_code
371+
http_code=$(curl -sS -o /dev/null -w "%{http_code}" -m 5 "https://enterprise.proxmox.com/debian/pve/dists/" 2>/dev/null) || http_code="000"
372+
373+
if [[ "$http_code" == "401" || "$http_code" == "403" ]]; then
374+
preflight_warn "Enterprise repo enabled without valid subscription (HTTP ${http_code})"
375+
echo -e " ${TAB}${INFO} apt-get update will show '401 Unauthorized' errors"
376+
echo -e " ${TAB}${INFO} Disable in ${GN}/etc/apt/sources.list.d/${CL} or add a subscription key"
377+
return 0
378+
fi
379+
380+
if [[ "$http_code" =~ ^2[0-9]{2}$ ]]; then
381+
preflight_pass "Enterprise repository accessible (subscription valid)"
382+
else
383+
preflight_warn "Enterprise repo check inconclusive (HTTP ${http_code})"
384+
fi
385+
return 0
386+
}
387+
351388
# ------------------------------------------------------------------------------
352389
# preflight_cluster_quorum()
353390
#
@@ -567,6 +604,9 @@ run_preflight() {
567604
preflight_network_bridge
568605
preflight_dns_resolution
569606

607+
# --- Repository checks ---
608+
preflight_repo_access
609+
570610
# --- Proxmox/Cluster checks ---
571611
preflight_cluster_quorum
572612
preflight_lxc_stack

0 commit comments

Comments
 (0)