]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-initramfs-restore.sh): add missing default paths
authorJóhann B. Guðmundsson <johannbg@gmail.com>
Sun, 7 Nov 2021 14:19:15 +0000 (14:19 +0000)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Sat, 11 Dec 2021 15:58:18 +0000 (10:58 -0500)
Adding missing default paths.
Fixes #1628

dracut-initramfs-restore.sh

index d97030a34fc1bafbde8558bf8b4d03f3499efbd9..aa9aec9255ec63f0fd46c1f15553362cbb98bbb5 100644 (file)
@@ -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