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