fix(vm): reject failed ISO downloads and repair image sources

This commit is contained in:
martino
2026-10-16 15:42:58 +02:00
parent 7f21cae196
commit f07dbfe10f
5 changed files with 513 additions and 30 deletions
+2 -2
View File
@@ -113,10 +113,10 @@ function select_linux_iso_official() {
"Ubuntu 24.04 Server|CLI|ProxMenux|https://releases.ubuntu.com/24.04/ubuntu-24.04.4-live-server-amd64.iso"
"Ubuntu 22.04 Server|CLI|ProxMenux|https://releases.ubuntu.com/22.04/ubuntu-22.04.5-live-server-amd64.iso"
"Ubuntu 20.04 Server|CLI|ProxMenux|https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso"
"Debian 13|Desktop|ProxMenux|https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-13.4.0-amd64-DVD-1.iso"
"Debian 13|Desktop|ProxMenux|https://cdimage.debian.org/cdimage/archive/13.6.0/amd64/iso-dvd/debian-13.6.0-amd64-DVD-1.iso"
"Debian 12|Desktop|ProxMenux|https://cdimage.debian.org/cdimage/archive/12.13.0/amd64/iso-dvd/debian-12.13.0-amd64-DVD-1.iso"
"Debian 11|Desktop|ProxMenux|https://cdimage.debian.org/cdimage/archive/11.11.0/amd64/iso-dvd/debian-11.11.0-amd64-DVD-1.iso"
"Debian 13 Netinst|CLI|ProxMenux|https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.4.0-amd64-netinst.iso"
"Debian 13 Netinst|CLI|ProxMenux|https://cdimage.debian.org/cdimage/archive/13.6.0/amd64/iso-cd/debian-13.6.0-amd64-netinst.iso"
"Debian 12 Netinst|CLI|ProxMenux|https://cdimage.debian.org/cdimage/archive/12.13.0/amd64/iso-cd/debian-12.13.0-amd64-netinst.iso"
"Debian 11 Netinst|CLI|ProxMenux|https://cdimage.debian.org/cdimage/archive/11.11.0/amd64/iso-cd/debian-11.11.0-amd64-netinst.iso"
"Fedora Workstation 42|Desktop|ProxMenux|https://download.fedoraproject.org/pub/fedora/linux/releases/42/Workstation/x86_64/iso/Fedora-Workstation-Live-42-1.1.x86_64.iso"
+4 -3
View File
@@ -100,7 +100,7 @@ function resolve_truenas_core_iso() {
}
function resolve_omv_iso() {
local default_ver="8.1.1"
local default_ver="8.3.1"
local detected_ver=""
if _has_curl; then
@@ -157,13 +157,14 @@ function resolve_xigmanas_iso() {
}
function resolve_rockstor_iso() {
local default_file="Rockstor-Leap15.6-generic.x86_64-5.0.15-0.install.iso"
local default_file="Rockstor-Leap15.6-generic.x86_64-5.1.0-0.install.iso"
local detected_file=""
local base_url="https://rockstor.com/downloads/installer/leap/15.6/x86_64"
if _has_curl; then
detected_file=$(
curl -fsSL "${base_url}/" 2>/dev/null \
# The installer directory forbids listings; use the official downloads page.
curl -fsSL "https://rockstor.com/dls/index.html" 2>/dev/null \
| grep -Eo 'Rockstor-Leap15\.6-generic\.x86_64-[0-9]+\.[0-9]+\.[0-9]+-[0-9]+\.install\.iso' \
| _latest_version_from_lines
)
+27 -25
View File
@@ -259,6 +259,25 @@ function run_gpu_passthrough_wizard() {
# Download beside the destination, publishing only a complete non-empty file.
function download_vm_iso() {
local iso_url="$1" iso_path="$2"
local staging_dir download_status=1
local -a wget_options=(--no-verbose --show-progress)
[[ "$iso_url" == *"sourceforge.net"* ]] && wget_options+=(--content-disposition)
staging_dir=$(mktemp -d "${iso_path}.part.XXXXXX") || return 1
if wget "${wget_options[@]}" -O "$staging_dir/media.iso" "$iso_url" \
&& [[ -s "$staging_dir/media.iso" ]] \
&& { [[ ! -f "$iso_path" ]] || chmod --reference="$iso_path" "$staging_dir/media.iso"; } \
&& mv -fT -- "$staging_dir/media.iso" "$iso_path"; then
download_status=0
fi
rm -f -- "$staging_dir/media.iso"
rmdir -- "$staging_dir" || return 1
return "$download_status"
}
# ==========================================================
# Create VM
# ==========================================================
@@ -266,21 +285,12 @@ function create_vm() {
local BOOT_ORDER=""
local DISK_INFO=""
local DISK_INDEX=0
local ISO_DIR="/var/lib/vz/template/iso"
local ISO_DIR="${ISO_DIR:-/var/lib/vz/template/iso}"
if [[ -n "$ISO_PATH" && -n "$ISO_URL" && ! -f "$ISO_PATH" ]]; then
if [[ -n "$ISO_PATH" && -n "$ISO_URL" ]] && [[ ! -f "$ISO_PATH" || ! -s "$ISO_PATH" ]]; then
if [[ "$ISO_URL" == *"sourceforge.net"* ]]; then
wget --content-disposition --show-progress -O "$ISO_PATH" "$ISO_URL"
else
wget --no-verbose --show-progress -O "$ISO_PATH" "$ISO_URL"
fi
if [[ -f "$ISO_PATH" ]]; then
if download_vm_iso "$ISO_URL" "$ISO_PATH"; then
ISO_VOLID="${ISO_VOLID:-local:iso/$(basename "$ISO_PATH")}"
msg_ok "$(translate "ISO image downloaded")"
else
@@ -647,7 +657,7 @@ fi
if [[ "$OS_TYPE" == "2" ]]; then
local VIRTIO_DIR="/var/lib/vz/template/iso"
local VIRTIO_DIR="$ISO_DIR"
local VIRTIO_SELECTED=""
local VIRTIO_VOLID=""
local VIRTIO_DOWNLOAD_URL="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso"
@@ -662,21 +672,13 @@ fi
case "$VIRTIO_OPTION" in
1)
if [[ -f "$VIRTIO_DIR/virtio-win.iso" ]]; then
if whiptail --title "ProxMenux" --yesno "$(translate "A VirtIO ISO already exists. Do you want to overwrite it?")" 10 60; then
wget -q --show-progress -O "$VIRTIO_DIR/virtio-win.iso" "$VIRTIO_DOWNLOAD_URL"
if [[ -f "$VIRTIO_DIR/virtio-win.iso" ]]; then
msg_ok "$(translate "VirtIO driver ISO downloaded successfully.")"
else
msg_error "$(translate "Failed to download VirtIO driver ISO.")"
fi
fi
else
wget -q --show-progress -O "$VIRTIO_DIR/virtio-win.iso" "$VIRTIO_DOWNLOAD_URL"
if [[ -f "$VIRTIO_DIR/virtio-win.iso" ]]; then
if [[ ! -f "$VIRTIO_DIR/virtio-win.iso" || ! -s "$VIRTIO_DIR/virtio-win.iso" ]] \
|| whiptail --title "ProxMenux" --yesno "$(translate "A VirtIO ISO already exists. Do you want to overwrite it?")" 10 60; then
if download_vm_iso "$VIRTIO_DOWNLOAD_URL" "$VIRTIO_DIR/virtio-win.iso"; then
msg_ok "$(translate "VirtIO driver ISO downloaded successfully.")"
else
msg_error "$(translate "Failed to download VirtIO driver ISO.")"
continue
fi
fi