Files
football/scripts/test-iso.sh
Charles N Wyble 7d286f8f2c refactor: Move active scripts to scripts/ directory
Moves current active scripts to scripts/ directory:
- build-iso.sh: Creates Debian ISO with preseed
- test-iso.sh: Tests ISO in QEMU VM

Keeps root directory clean and organized.

💘 Generated with Crush

Assisted-by: Gemini 2.5 Flash via Crush <crush@charm.land>
2026-01-20 11:46:53 -05:00

181 lines
4.8 KiB
Bash
Executable File

#!/bin/bash
# Football ISO Test Script
# Boots QEMU VM from ISO to test installation
# All work done in Docker container
set -e
BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ISO_PATH="$BUILD_DIR/output/football-installer.iso"
DISK_PATH="$BUILD_DIR/output/test-vm-disk.qcow2"
CONSOLE_LOG="$BUILD_DIR/output/vm-console.log"
VM_PID_FILE="$BUILD_DIR/output/vm.pid"
echo "================================================"
echo "Football ISO Test - VM Boot"
echo "================================================"
echo ""
# ============================================================================
# Step 1: Verify ISO Exists
# ============================================================================
echo "[1/4] Verifying ISO..."
if [ ! -f "$ISO_PATH" ]; then
echo "❌ ISO not found: $ISO_PATH"
echo "Run ./build-iso.sh first"
exit 1
fi
docker run --rm \
-v "$BUILD_DIR:/build" \
debian:trixie \
bash -c "
echo 'ISO information:'
file /build/output/football-installer.iso
echo ''
echo 'ISO size:'
ls -lh /build/output/football-installer.iso
"
echo ""
echo "✅ ISO verified"
echo ""
# ============================================================================
# Step 2: Create Test Disk
# ============================================================================
echo "[2/4] Creating test disk..."
mkdir -p "$BUILD_DIR/output"
docker run --rm \
-v "$BUILD_DIR:/build" \
debian:trixie \
bash -c '
set -e
echo "Installing qemu-utils..."
apt-get update -qq
apt-get install -y -qq qemu-utils
echo ""
echo "Creating 16GB QCOW2 disk..."
cd /build/output
qemu-img create -f qcow2 test-vm-disk.qcow2 16G
echo ""
echo "✅ Test disk created"
ls -lh /build/output/test-vm-disk.qcow2
'
echo ""
echo "✅ Step 2 complete"
echo ""
# ============================================================================
# Step 3: Boot VM from ISO
# ============================================================================
echo "[3/4] Booting VM from ISO..."
echo ""
echo "VM Configuration:"
echo " CPU: 2 cores"
echo " RAM: 2GB"
echo " Disk: 16GB"
echo " Boot: $ISO_PATH"
echo ""
echo "NOTE: VM will boot in background mode"
echo "Console output will be saved to: $CONSOLE_LOG"
echo "To monitor console: tail -f $CONSOLE_LOG"
echo ""
# Start VM with QEMU using screen session
# Using screen to manage long-running QEMU process
screen -dmS football-iso-test \
qemu-system-x86_64 \
-m 2048 \
-smp 2 \
-drive file="$DISK_PATH",format=qcow2 \
-drive file="$ISO_PATH",media=cdrom,readonly=on \
-boot d \
-nographic \
-serial file:"$CONSOLE_LOG" \
-display none
# Save QEMU PID for later use
pgrep -f "qemu-system-x86_64.*$DISK_PATH" | head -1 > "$VM_PID_FILE"
echo "✅ VM started (PID: $(cat $VM_PID_FILE 2>/dev/null || echo 'unknown'))"
echo ""
# ============================================================================
# Step 4: Monitor Boot
# ============================================================================
echo "[4/4] Monitoring boot (waiting 120 seconds)..."
echo ""
for i in {1..120}; do
if [ -f "$CONSOLE_LOG" ]; then
# Check for installation prompts
if grep -q "Choose the country" "$CONSOLE_LOG" 2>/dev/null; then
echo "🟢 Installer running - Country selection detected"
break
fi
# Check for errors
if grep -qi "error\|panic\|fatal" "$CONSOLE_LOG" 2>/dev/null; then
echo "⚠️ Error detected in console"
tail -20 "$CONSOLE_LOG"
break
fi
fi
sleep 1
done
echo ""
echo "==========================================="
echo "VM Status"
echo "==========================================="
echo ""
if [ -f "$VM_PID_FILE" ]; then
VM_PID=$(cat "$VM_PID_FILE" 2>/dev/null || echo 'unknown')
if kill -0 "$VM_PID" 2>/dev/null; then
echo "🟢 VM is running (PID: $VM_PID)"
else
echo "🔴 VM has stopped"
fi
fi
echo ""
echo "Recent console output (last 30 lines):"
if [ -f "$CONSOLE_LOG" ]; then
tail -30 "$CONSOLE_LOG"
else
echo "No console output yet"
fi
echo ""
echo "==========================================="
echo "Manual Access"
echo "==========================================="
echo ""
echo "To access VM console interactively:"
echo " 1. Stop current VM: kill \$(cat $VM_PID_FILE)"
echo " 2. Remove -nographic flag:"
echo " qemu-system-x86_64 \\"
echo " -m 4096 -smp 2 \\"
echo " -drive file=$DISK_PATH,format=qcow2 \\"
echo " -drive file=$ISO_PATH,media=cdrom,readonly=on \\"
echo " -boot d"
echo ""
echo "To stop VM:"
echo " kill \$(cat $VM_PID_FILE)"
echo ""
echo "Console log location: $CONSOLE_LOG"
echo ""