]> code.delx.au - refind/blobdiff - mkrlconf
Merge remote-tracking branch 'tianon/master'
[refind] / mkrlconf
index 031c82a6012af41e2e74f759eb64f67ba520814a..543ce0ac7bb75d7f994cca806489620725604481 100755 (executable)
--- a/mkrlconf
+++ b/mkrlconf
 
 # Revision history:
 #
-#  0.10.0 -- Renamed from mkrlconf.sh to mkrlconf; changed to get $DefaultOptions
+# 0.10.1  -- Improve extraction of kernel options from /proc/cmdline
+# 0.10.0  -- Renamed from mkrlconf.sh to mkrlconf; changed to get $DefaultOptions
 #            from /proc/cmdline rather than from GRUB
-#  0.9.0  -- Added check for OS type, to keep from running pointlessly on OS X
-#  0.7.7  -- Fixed bug that caused stray PARTUUID= and line breaks in generated file
-#  0.5.1  -- Initial release
+# 0.9.0   -- Added check for OS type, to keep from running pointlessly on OS X
+# 0.7.7   -- Fixed bug that caused stray PARTUUID= and line breaks in generated file
+# 0.5.1   -- Initial release
 #
 # Note: mkrlconf version numbers match those of the rEFInd package
 # with which they first appeared.
@@ -45,7 +46,12 @@ if [[ ! -f $RLConfFile || $1 == "--force" ]] ; then
             RootFS=$Uuid
         fi
     fi
-    DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/$/ /' | sed 's/initrd=.* //g' | sed 's/ *$//'`
+    FirstCmdlineOption=`cat /proc/cmdline | cut -d ' ' -f 1`
+    if [[ "$FirstCmdlineOption" =~ (vmlinuz|bzImage|kernel) ]] ; then
+        DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'`
+    else
+        DefaultOptions=`cat /proc/cmdline | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'`
+    fi
     echo "\"Boot with standard options\"  \"$DefaultOptions\"" > $RLConfFile
     echo "\"Boot to single-user mode\"    \"$DefaultOptions single\"" >> $RLConfFile
     echo "\"Boot with minimal options\"   \"ro root=$RootFS\"" >> $RLConfFile