]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat(dracut.sh): populate uefi_cmdline if no other cmdline is given
authorPavel Valena <pvalena@redhat.com>
Mon, 29 Aug 2022 01:59:49 +0000 (03:59 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Mon, 26 Sep 2022 10:05:33 +0000 (10:05 +0000)
When creating uefi image in hostonly mode (with using --hostonly-cmdline),
it makes sense to copy current kernel commandline from /proc/cmdline,
in case there are no other options specified.

Usually, the cmdline.d/*.conf file is generated by module rootfs-block
(or other modules), but it might, not handle all cases correctly,
and specifying --kernel-cmdline every time is not much user-friendly.

dracut.sh

index 4f4fb8a0d95b4e3a50a7acda24bf462e5a36b0db..c612a296aee2e65b7dfcc365065ab308fab49452 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -2598,14 +2598,18 @@ umask 077
 if [[ $uefi == yes ]]; then
     if [[ $kernel_cmdline ]]; then
         echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt"
-    elif [[ $hostonly_cmdline == yes ]] && [ -d "$initdir/etc/cmdline.d" ]; then
-        for conf in "$initdir"/etc/cmdline.d/*.conf; do
-            [ -e "$conf" ] || continue
-            printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt"
-        done
+    elif [[ $hostonly_cmdline == yes ]]; then
+        if [ -d "$initdir/etc/cmdline.d" ]; then
+            for conf in "$initdir"/etc/cmdline.d/*.conf; do
+                [ -e "$conf" ] || continue
+                printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt"
+            done
+        elif [ -e "/proc/cmdline" ]; then
+            printf "%s " "$(< "/proc/cmdline")" > "$uefi_outdir/cmdline.txt"
+        fi
     fi
 
-    if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline == yes && -d "$initdir/etc/cmdline.d" ]]; then
+    if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline == yes && -e "${uefi_outdir}/cmdline.txt" ]]; then
         echo -ne "\x00" >> "$uefi_outdir/cmdline.txt"
         dinfo "Using UEFI kernel cmdline:"
         dinfo "$(tr -d '\000' < "$uefi_outdir/cmdline.txt")"