]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut.sh): always check that MACHINE_ID is not empty
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Tue, 3 May 2022 13:26:53 +0000 (15:26 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Tue, 3 May 2022 22:12:13 +0000 (22:12 +0000)
On new installations, /etc/machine-id may exist and be empty, and
also /efi or /boot/efi may be a mount point, leading to an invalid
initramfs output file.

dracut.sh

index 524ac115fb89a8973a7d3c1c687a3d527a8e1edc..30eea1a55bfa2818a546dd34d2f0581d042a11dc 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1089,9 +1089,13 @@ if ! [[ $outfile ]]; then
             outfile="$dracutsysrootdir/lib/modules/${kernel}/initrd"
         elif [[ -e $dracutsysrootdir/boot/vmlinuz-${kernel} ]]; then
             outfile="$dracutsysrootdir/boot/initramfs-${kernel}.img"
-        elif [[ -z $dracutsysrootdir ]] && mountpoint -q /efi; then
+        elif [[ -z $dracutsysrootdir ]] \
+            && [[ $MACHINE_ID ]] \
+            && mountpoint -q /efi; then
             outfile="/efi/${MACHINE_ID}/${kernel}/initrd"
-        elif [[ -z $dracutsysrootdir ]] && mountpoint -q /boot/efi; then
+        elif [[ -z $dracutsysrootdir ]] \
+            && [[ $MACHINE_ID ]] \
+            && mountpoint -q /boot/efi; then
             outfile="/boot/efi/${MACHINE_ID}/${kernel}/initrd"
         else
             outfile="$dracutsysrootdir/boot/initramfs-${kernel}.img"