Blob Blame History Raw
From ccb8ce0403056fc9af5b010a8d279d3891cbc399 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 15 Aug 2014 14:58:02 +0200
Subject: [PATCH] 50-dracut.install: fixed /proc/cmdline reading

and beautified the code a bit
---
 50-dracut.install | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/50-dracut.install b/50-dracut.install
index 0282741..b0cc7c3 100755
--- a/50-dracut.install
+++ b/50-dracut.install
@@ -2,31 +2,35 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
-if [[ -f /etc/kernel/cmdline ]]; then
-    readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
-fi
+COMMAND="$1"
+KERNEL_VERSION="$2"
+BOOT_DIR_ABS="$3"
+KERNEL_IMAGE="$4"
 
-if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
-    readarray -t BOOT_OPTIONS < /proc/cmdline
-fi
+ret=0
+case "$COMMAND" in
+    add)
+        if [[ -f /etc/kernel/cmdline ]]; then
+            readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
+        fi
 
-unset noimageifnotneeded
+        if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
+            read -ar BOOT_OPTIONS < /proc/cmdline
+        fi
 
-for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
-    if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
-        noimageifnotneeded="yes"
-        break
-    fi
-done
+        unset noimageifnotneeded
 
-ret=0
-case "$1" in
-    add)
-	dracut ${noimageifnotneeded:+--noimageifnotneeded} "$3"/initrd "$2"
+        for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
+            if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
+                noimageifnotneeded="yes"
+                break
+            fi
+        done
+	dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
         ret=$?
 	;;
     remove)
-        rm -f -- "$3"/initrd
+        rm -f -- "$BOOT_DIR_ABS"/initrd
         ret=$?
 	;;
 esac