feat(grub): add fws-recovery boot menu entry script

Add a new GRUB menu entry script that provides system recovery functionality.

The script generates a 'Réparer FWS (récupération du système)' menu entry that boots the system into fws-recovery.target with the fws.recovery=1 marker. This allows the recovery application to launch and perform system repairs via GUI or console fallback.

The script uses the fallback initramfs for maximum hardware compatibility during recovery operations, matching the UUID-based root detection logic of the standard 10_linux script.
This commit is contained in:
2026-07-07 02:47:14 +02:00
parent a75964e391
commit 50773635e8
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
# ============================================================================
# FWS — entrée « Réparer FWS » dans le menu GRUB du SYSTÈME INSTALLÉ
# (l'équivalent de l'environnement de récupération de Windows).
#
# Ce script est exécuté par grub-mkconfig (à l'installation via le %post du
# kickstart, puis à chaque fws-recovery « Réinstaller GRUB »). Il démarre le
# MÊME système sur fws-recovery.target (+ marqueur fws.recovery=1) :
# fws-recovery-boot.service prend alors tty1 et lance l'application de
# réparation (GUI via startx, repli console).
#
# Sur le live, ce fichier est inerte (grub-mkconfig n'y tourne jamais).
# ============================================================================
set -e
. /usr/share/grub/grub-mkconfig_lib
kernel=/boot/vmlinuz-linux
# L'initramfs FALLBACK (sans autodetect) : c'est l'entrée de secours, elle
# doit démarrer même si le matériel a changé depuis le dernier mkinitcpio.
initrd=/boot/initramfs-linux-fallback.img
[ -f "$initrd" ] || initrd=/boot/initramfs-linux.img
[ -f "$kernel" ] && [ -f "$initrd" ] || exit 0
# Même logique racine que 10_linux : UUID sauf refus explicite.
if [ -n "${GRUB_DEVICE_UUID:-}" ] && [ "x${GRUB_DISABLE_LINUX_UUID:-}" != xtrue ]; then
rootarg="root=UUID=$GRUB_DEVICE_UUID"
else
rootarg="root=$GRUB_DEVICE"
fi
rel_kernel="$(make_system_path_relative_to_its_root "$kernel")"
rel_initrd="$(make_system_path_relative_to_its_root "$initrd")"
cat <<EOF
menuentry 'Réparer FWS (récupération du système)' --class recovery {
$(prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | grub_add_tab)
linux $rel_kernel $rootarg rw ${GRUB_CMDLINE_LINUX:-} systemd.unit=fws-recovery.target fws.recovery=1
initrd $rel_initrd
}
EOF