]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
50-dracut.install: fixed /proc/cmdline reading
authorHarald Hoyer <harald@redhat.com>
Fri, 15 Aug 2014 12:58:02 +0000 (14:58 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 15 Aug 2014 12:58:02 +0000 (14:58 +0200)
and beautified the code a bit

50-dracut.install

index 02827411f64130bc121b6eae25c68c61b37c1cce..b0cc7c3c8b456f436c41857f65b9006941cba028 100755 (executable)
@@ -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