From 3d8e1ad2ae1e34244ddf700beea6358c1452e05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3hann=20B=2E=20Gu=C3=B0mundsson?= Date: Sun, 7 Nov 2021 14:19:15 +0000 Subject: [PATCH] fix(dracut-initramfs-restore.sh): add missing default paths Adding missing default paths. Fixes #1628 --- dracut-initramfs-restore.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh index d97030a3..aa9aec92 100644 --- a/dracut-initramfs-restore.sh +++ b/dracut-initramfs-restore.sh @@ -17,22 +17,33 @@ KERNEL_VERSION="$(uname -r)" SKIP="$dracutbasedir/skipcpio" [[ -x $SKIP ]] || SKIP="cat" -[[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id +if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then + MACHINE_ID="Default" +elif [[ -f /etc/machine-id ]]; then + read -r MACHINE_ID < /etc/machine-id +else + MACHINE_ID="Default" +fi mount -o ro /boot &> /dev/null || true -if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \ - && [[ $MACHINE_ID ]] \ - && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then +if [[ -d /efi/loader/entries ]] || [[ -L /efi/loader/entries ]] \ + || [[ -d /efi/$MACHINE_ID ]] || [[ -L /efi/$MACHINE_ID ]]; then IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" -elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \ - && [[ $MACHINE_ID ]] \ - && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then +elif [[ -d /boot/loader/entries ]] || [[ -L /boot/loader/entries ]] \ + || [[ -d /boot/$MACHINE_ID ]] || [[ -L /boot/$MACHINE_ID ]]; then IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd" -elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then - IMG="/boot/initramfs-${KERNEL_VERSION}.img" +elif [[ -d /boot/efi/loader/entries ]] || [[ -L /boot/efi/loader/entries ]] \ + || [[ -d /boot/efi/$MACHINE_ID ]] || [[ -L /boot/efi/$MACHINE_ID ]]; then + IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then IMG="/lib/modules/${KERNEL_VERSION}/initrd" +elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then + IMG="/boot/initramfs-${KERNEL_VERSION}.img" +elif mountpoint -q /efi; then + IMG="/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" +elif mountpoint -q /boot/efi; then + IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" else echo "No initramfs image found to restore!" exit 1