From 367233eae5f7b6c916eee419924bdff0da5d90e1 Mon Sep 17 00:00:00 2001 From: nocode Date: Wed, 8 Jul 2026 02:39:10 +0200 Subject: [PATCH] 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. --- .../usr/local/bin/fws-gameboot-bootfix | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 configs/releng/airootfs/usr/local/bin/fws-gameboot-bootfix diff --git a/configs/releng/airootfs/usr/local/bin/fws-gameboot-bootfix b/configs/releng/airootfs/usr/local/bin/fws-gameboot-bootfix new file mode 100644 index 0000000..c9eda04 --- /dev/null +++ b/configs/releng/airootfs/usr/local/bin/fws-gameboot-bootfix @@ -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