feat(gameboot): add fws-gameboot-bootfix systemd oneshot service

Add boot fix script that executes at every FWS startup to reassert BootOrder[0] = FWS.

This serves as a permanent safety net to handle cases where Windows Update or system crashes might reorder the EFI boot options, ensuring the system always boots into FWS when no explicit BootNext is set, preventing the system from becoming stuck in Windows.

The script is inactive on live systems via ConditionPathExists check.
This commit is contained in:
2026-07-08 02:39:10 +02:00
parent 3d91ef3ac5
commit 367233eae5
@@ -0,0 +1,25 @@
#!/bin/bash
# ============================================================
# fws-gameboot-bootfix — exécuté à CHAQUE démarrage de FWS (oneshot systemd).
#
# Réasserte BootOrder[0] = FWS. Filet de sûreté PERMANENT : après un Windows
# Update qui remet « Windows Boot Manager » en tête de BootOrder, ou après tout
# crash/reboot non géré, un boot SANS BootNext retombe toujours sur FWS (jamais
# coincé côté Windows ; l'image d'hibernation reste accessible).
#
# Inerte sur le live (le service porte ConditionPathExists=!/run/archiso).
# ============================================================
set -u
[ -d /sys/firmware/efi ] || exit 0
command -v efibootmgr >/dev/null 2>&1 || exit 0
fws="$(efibootmgr 2>/dev/null | sed -n 's/^Boot\([0-9A-Fa-f]\{4\}\)\*\? *\(FWS\|GRUB\).*/\1/p' | head -1)"
[ -n "$fws" ] || exit 0
# BootOrder[0] = FWS (sans dupliquer, en préservant l'ordre existant derrière).
order="$(efibootmgr 2>/dev/null | sed -n 's/^BootOrder: //p' | tr -d '[:space:]')"
if [ -n "$order" ] && [ "${order%%,*}" != "$fws" ]; then
rest="$(printf '%s' "$order" | tr ',' '\n' | grep -vx "$fws" | paste -sd, -)"
efibootmgr -o "${fws}${rest:+,$rest}" >/dev/null 2>&1 || true
fi
exit 0