From ba93e85eea7b86fc76ba13f2efc2905be28ec0c3 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:12:48 +0100 Subject: [PATCH] fix(vm): fix LVM/LVM-thin storage and error reporting for all VM scripts - Add catch-all (*) case to storage type detection in all VM scripts that were missing it (debian-vm, debian-13-vm, ubuntu2204/2404/2504, nextcloud-vm, owncloud-vm, opnsense-vm, pimox-haos-vm) - Add catch-all to mikrotik-routeros (had zfspool but not lvm/lvmthin) - Fix error_handler in ALL 14 VM scripts to send numeric exit_code to post_update_to_api instead of bash command text, which caused 'Unknown error' in telemetry because the API expects a number --- vm/debian-13-vm.sh | 7 ++++++- vm/debian-vm.sh | 7 ++++++- vm/docker-vm.sh | 2 +- vm/haos-vm.sh | 2 +- vm/mikrotik-routeros.sh | 7 ++++++- vm/nextcloud-vm.sh | 7 ++++++- vm/openwrt-vm.sh | 2 +- vm/opnsense-vm.sh | 7 ++++++- vm/owncloud-vm.sh | 7 ++++++- vm/pimox-haos-vm.sh | 7 ++++++- vm/ubuntu2204-vm.sh | 7 ++++++- vm/ubuntu2404-vm.sh | 7 ++++++- vm/ubuntu2504-vm.sh | 7 ++++++- vm/umbrel-os-vm.sh | 2 +- 14 files changed, 64 insertions(+), 14 deletions(-) diff --git a/vm/debian-13-vm.sh b/vm/debian-13-vm.sh index af036768e..fcf0f7978 100644 --- a/vm/debian-13-vm.sh +++ b/vm/debian-13-vm.sh @@ -70,7 +70,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } @@ -560,6 +560,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/debian-vm.sh b/vm/debian-vm.sh index 7692b8c3d..1af726b3d 100644 --- a/vm/debian-vm.sh +++ b/vm/debian-vm.sh @@ -70,7 +70,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } @@ -501,6 +501,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/docker-vm.sh b/vm/docker-vm.sh index f45da27ad..b4de65d94 100644 --- a/vm/docker-vm.sh +++ b/vm/docker-vm.sh @@ -45,7 +45,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } diff --git a/vm/haos-vm.sh b/vm/haos-vm.sh index f82b5940a..ab490b002 100644 --- a/vm/haos-vm.sh +++ b/vm/haos-vm.sh @@ -74,7 +74,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } diff --git a/vm/mikrotik-routeros.sh b/vm/mikrotik-routeros.sh index 0f000a84c..6ea0c868b 100644 --- a/vm/mikrotik-routeros.sh +++ b/vm/mikrotik-routeros.sh @@ -71,7 +71,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } @@ -566,6 +566,11 @@ zfspool) DISK_REF="" DISK_IMPORT="-format raw" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac DISK_VAR="vm-${VMID}-disk-0${DISK_EXT:-}" diff --git a/vm/nextcloud-vm.sh b/vm/nextcloud-vm.sh index 130b8148f..960322d5d 100644 --- a/vm/nextcloud-vm.sh +++ b/vm/nextcloud-vm.sh @@ -70,7 +70,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } @@ -487,6 +487,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1,2}; do disk="DISK$i" diff --git a/vm/openwrt-vm.sh b/vm/openwrt-vm.sh index 00e85c5d7..f14708f86 100644 --- a/vm/openwrt-vm.sh +++ b/vm/openwrt-vm.sh @@ -74,7 +74,7 @@ function error_handler() { local exit_code="$?" local line_number="$1" local command="$2" - post_update_to_api "failed" "$command" + post_update_to_api "failed" "$exit_code" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" echo -e "\n$error_message\n" cleanup_vmid diff --git a/vm/opnsense-vm.sh b/vm/opnsense-vm.sh index bc5acbf2d..9d7eac26a 100644 --- a/vm/opnsense-vm.sh +++ b/vm/opnsense-vm.sh @@ -48,7 +48,7 @@ function error_handler() { local exit_code="$?" local line_number="$1" local command="$2" - post_update_to_api "failed" "$command" + post_update_to_api "failed" "$exit_code" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" echo -e "\n$error_message\n" cleanup_vmid @@ -619,6 +619,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/owncloud-vm.sh b/vm/owncloud-vm.sh index bff0d7f88..8cfd668f8 100644 --- a/vm/owncloud-vm.sh +++ b/vm/owncloud-vm.sh @@ -71,7 +71,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } @@ -500,6 +500,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1,2}; do disk="DISK$i" diff --git a/vm/pimox-haos-vm.sh b/vm/pimox-haos-vm.sh index 07e1740a1..e234ecc96 100644 --- a/vm/pimox-haos-vm.sh +++ b/vm/pimox-haos-vm.sh @@ -79,7 +79,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid } @@ -402,6 +402,11 @@ nfs | dir) DISK_REF="$VMID/" DISK_IMPORT="-format qcow2" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/ubuntu2204-vm.sh b/vm/ubuntu2204-vm.sh index 55a4dee7d..910691104 100644 --- a/vm/ubuntu2204-vm.sh +++ b/vm/ubuntu2204-vm.sh @@ -66,7 +66,7 @@ function error_handler() { local exit_code="$?" local line_number="$1" local command="$2" - post_update_to_api "failed" "$command" + post_update_to_api "failed" "$exit_code" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" echo -e "\n$error_message\n" cleanup_vmid @@ -482,6 +482,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/ubuntu2404-vm.sh b/vm/ubuntu2404-vm.sh index 565718d88..d2c503458 100644 --- a/vm/ubuntu2404-vm.sh +++ b/vm/ubuntu2404-vm.sh @@ -69,7 +69,7 @@ function error_handler() { local exit_code="$?" local line_number="$1" local command="$2" - post_update_to_api "failed" "$command" + post_update_to_api "failed" "$exit_code" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" echo -e "\n$error_message\n" cleanup_vmid @@ -484,6 +484,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/ubuntu2504-vm.sh b/vm/ubuntu2504-vm.sh index 5e6d3a800..7ba4da312 100644 --- a/vm/ubuntu2504-vm.sh +++ b/vm/ubuntu2504-vm.sh @@ -68,7 +68,7 @@ function error_handler() { local exit_code="$?" local line_number="$1" local command="$2" - post_update_to_api "failed" "$command" + post_update_to_api "failed" "$exit_code" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" echo -e "\n$error_message\n" cleanup_vmid @@ -483,6 +483,11 @@ btrfs) FORMAT=",efitype=4m" THIN="" ;; +*) + DISK_EXT="" + DISK_REF="" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" diff --git a/vm/umbrel-os-vm.sh b/vm/umbrel-os-vm.sh index 02a5bb439..25ef06ed2 100644 --- a/vm/umbrel-os-vm.sh +++ b/vm/umbrel-os-vm.sh @@ -69,7 +69,7 @@ function error_handler() { local line_number="$1" local command="$2" local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - post_update_to_api "failed" "${command}" + post_update_to_api "failed" "${exit_code}" echo -e "\n$error_message\n" cleanup_vmid }