From aa45e1691ee2318aac33c6411a4d98ce408a1a21 Mon Sep 17 00:00:00 2001 From: Michel Abboud Date: Fri, 30 Jan 2026 08:10:55 +0000 Subject: [PATCH] fix: Reset magic byte on cached ISOs to trigger install pipeline The container marks processed ISOs with byte 0x16 at offset 0. Restoring a cached ISO with this byte into an empty data directory caused the container to skip installation and try to boot a nonexistent disk, dropping into a UEFI shell. Now resets byte 0 to 0x00 after copying so the container re-processes the ISO (driver injection, answer file, etc.) without re-downloading it. Also adds cache auto-restore to cmd_start() for base versions, not just cmd_new() instances. Co-Authored-By: Claude Opus 4.5 --- winctl.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/winctl.sh b/winctl.sh index 23987d4..457b7b9 100755 --- a/winctl.sh +++ b/winctl.sh @@ -1075,6 +1075,26 @@ cmd_start() { mkdir -p "$data_dir" fi + # Pre-populate from ISO cache if data dir is empty + if [[ -z "$(ls -A "$data_dir" 2>/dev/null)" ]]; then + local cache_src="$ISO_CACHE_DIR/$RESOLVED_BASE" + if [[ -d "$cache_src" ]]; then + local iso_files + iso_files=$(find "$cache_src" -maxdepth 1 -name '*.iso' -type f 2>/dev/null || true) + if [[ -n "$iso_files" ]]; then + info "Restoring cached ISO for $RESOLVED_BASE..." + cp "$cache_src"/*.iso "$data_dir/" + # Reset magic byte so the container re-processes the ISO + # (installs from it) instead of trying to boot a missing disk + local restored_iso + for restored_iso in "$data_dir"/*.iso; do + printf '\x00' | dd of="$restored_iso" bs=1 seek=0 count=1 conv=notrunc status=none 2>/dev/null || true + done + success "ISO restored from cache (skipping download)" + fi + fi + fi + # Check ports are available if ! check_port "$RESOLVED_WEB_PORT"; then error "Web port $RESOLVED_WEB_PORT is already in use" @@ -2353,6 +2373,11 @@ cmd_new() { if [[ -n "$iso_files" ]]; then info "Restoring cached ISO for $version..." cp "$cache_src"/*.iso "$data_dir/" + # Reset magic byte so the container re-processes the ISO + local restored_iso + for restored_iso in "$data_dir"/*.iso; do + printf '\x00' | dd of="$restored_iso" bs=1 seek=0 count=1 conv=notrunc status=none 2>/dev/null || true + done success "ISO restored from cache (skipping download)" fi fi