Files
blair-pve-sync-temp/install-gpu-boot-watch.sh
T
2026-06-24 03:00:43 -04:00

40 lines
1.5 KiB
Bash

#!/bin/bash
# Install GPU boot ready-check on pve (detect mode by default).
set -euo pipefail
BASE_URL="${BLAIR_BOOT_WATCH_BASE_URL:-https://git.easygoingaming.com/Davoguha/blair-pve-sync-temp/raw/main}"
TARGET='/usr/local/sbin/watch-blair-gpu-boot.sh'
SHARE_COPY='/tank/blair-share/tools/golden/host/watch-blair-gpu-boot.sh'
CRON='/etc/cron.d/blair-gpu-boot-watch'
STATE='/var/lib/blair-gpu-boot-watch.json'
echo "=== Download boot watch script ==="
curl -fsSL "$BASE_URL/watch-blair-gpu-boot.sh" -o "$TARGET"
chmod +x "$TARGET"
sed -i 's/\r$//' "$TARGET" 2>/dev/null || true
mkdir -p "$(dirname "$SHARE_COPY")" /tank/blair-share/fleet/monitor
cp -f "$TARGET" "$SHARE_COPY"
chmod +x "$SHARE_COPY"
touch /var/log/blair-gpu-boot-watch.log
echo "=== cron (every 3 min, detect-only) ==="
cat > "$CRON" <<'EOF'
# Detect hung Windows boot: running but QEMU GA never responds.
# Enable recovery: add BLAIR_BOOT_WATCH_MODE=recover to the line below (max 1 restart/6h/VM).
*/3 * * * * root BLAIR_BOOT_WATCH_MODE=detect /usr/local/sbin/watch-blair-gpu-boot.sh >> /var/log/blair-gpu-boot-watch.log 2>&1
EOF
chmod 644 "$CRON"
cat "$CRON"
echo "=== test run (detect) ==="
BLAIR_BOOT_WATCH_MODE=detect "$TARGET"
echo "=== state ==="
cat "$STATE" 2>/dev/null || echo '(no state yet)'
echo "=== share status ==="
cat /tank/blair-share/fleet/monitor/boot-watch.json 2>/dev/null || true
echo "=== done ==="
echo ""
echo "To enable auto-recovery after burn-in:"
echo " sed -i 's/MODE=detect/MODE=recover/' $CRON"