Skip to content

Commit cdbaab9

Browse files
committed
Improve Incus and OS mismatch error handling
Refines `incus_check` to inspect `incus info` probe errors and return targeted guidance for daemon-down, permission, and uninitialized-install cases instead of a single generic start command. Updates the container OS guard to treat cross-distribution mismatches as a separate "WRONG OS" condition, with clearer remediation and dialog text to avoid impossible upgrade advice.
1 parent 862ed8d commit cdbaab9

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

incus/core.func

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,30 @@ incus_check() {
239239
exit 1
240240
fi
241241

242-
# Check if incus daemon is accessible
243-
if ! incus info &>/dev/null; then
244-
incus_msg_error "Incus daemon is not running or not accessible."
245-
incus_msg_error "Run: systemctl start incus"
242+
# Check if incus daemon is accessible. The probe's own error is what tells
243+
# a stopped daemon apart from a permission problem or an uninitialised
244+
# install, so keep it instead of always advising "systemctl start incus".
245+
local probe_err probe_rc=0
246+
probe_err="$(LC_ALL=C incus info 2>&1 >/dev/null)" || probe_rc=$?
247+
if ((probe_rc != 0)); then
248+
case "$probe_err" in
249+
*"onnection refused"* | *"o such file or directory"* | *"ailed to connect"*)
250+
incus_msg_error "Incus daemon is not running."
251+
incus_msg_error "Run: systemctl start incus"
252+
;;
253+
*"ermission denied"* | *"not authorized"* | *"nauthorized"*)
254+
incus_msg_error "No permission to reach the Incus daemon as $(id -un)."
255+
incus_msg_error "Run: sudo usermod -aG incus-admin $(id -un) - then log out and back in"
256+
;;
257+
*"not been initialized"* | *"o storage pool"*)
258+
incus_msg_error "Incus is installed but not initialised."
259+
incus_msg_error "Run: incus admin init"
260+
;;
261+
*)
262+
incus_msg_error "Cannot query the Incus daemon (incus info exited ${probe_rc})."
263+
incus_msg_error "${probe_err:-no error output - try running: incus info}"
264+
;;
265+
esac
246266
exit 1
247267
fi
248268

ui/menu.func

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,15 @@ check_container_os_guard() {
862862
return 0
863863
fi
864864

865-
local mismatch_detail remediation
866-
if [[ "$downgraded_target" -eq 1 ]]; then
865+
local mismatch_detail remediation dialog_title="OS VERSION MISMATCH"
866+
if [[ "$cur_os" != "$rec_os" ]]; then
867+
# Two different distributions. Their version numbers are not comparable and
868+
# there is no upgrade path between them, so the version-mismatch wording
869+
# produced impossible advice like "upgrade the container OS to debian 26.04".
870+
dialog_title="WRONG OS"
871+
mismatch_detail="This container runs ${cur_os} ${cur_ver}, but ${APP:-this script} is built for ${rec_os}.\n\nThese are different distributions - ${cur_os} cannot be upgraded to ${rec_os}, and their version numbers are unrelated.\n\nRecommended: create a new ${rec_os} ${rec_ver} container and install ${APP:-the application} there."
872+
remediation="Create a new ${rec_os} ${rec_ver} container instead - ${cur_os} cannot be upgraded to ${rec_os}"
873+
elif [[ "$downgraded_target" -eq 1 ]]; then
867874
mismatch_detail="Your container runs ${cur_os} ${cur_ver}, which is newer than what this script now targets (${rec_os} ${rec_ver}).\n\nThe target was likely lowered on purpose, e.g. because ${APP:-the app} had problems on newer OS versions - check the GitHub issues for ${APP:-this app} for details.\n\nContinuing on ${cur_ver} often still works, but isn't guaranteed. If you are unsure, ask in our Discord (https://discord.gg/3AnUqsXnmK) before continuing."
868875
remediation="This script now targets the older ${rec_os} ${rec_ver}. Check the GitHub issues for ${APP:-this app}, or ask in Discord (https://discord.gg/3AnUqsXnmK) if you are unsure"
869876
else
@@ -873,7 +880,7 @@ check_container_os_guard() {
873880

874881
if [[ "${PHS_SILENT:-0}" != "1" ]] && command -v whiptail &>/dev/null && [ -t 0 ] && [[ "$TERM" != "dumb" ]]; then
875882
local choice
876-
choice=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "OS VERSION MISMATCH" --menu \
883+
choice=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$dialog_title" --menu \
877884
"${mismatch_detail}\n\nIf you continue anyway, it may break — no support is provided in that case.\n\nContinue anyway?" \
878885
20 70 3 \
879886
"1" "No (cancel update)" \

0 commit comments

Comments
 (0)