]> code.delx.au - refind/blobdiff - mkrlconf
Updated mkrlconf, refind-install, and addition of @/boot to standard
[refind] / mkrlconf
index f6369c7a70bdf71dcfbe221aed471668b45b7cd2..031c82a6012af41e2e74f759eb64f67ba520814a 100755 (executable)
--- a/mkrlconf
+++ b/mkrlconf
 
 # Revision history:
 #
-#  0.9.3 -- Renamed from mkrlconf.sh to mkrlconf
-#  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.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
 #
 # Note: mkrlconf version numbers match those of the rEFInd package
 # with which they first appeared.
 RLConfFile="/boot/refind_linux.conf"
 
 if [[ `uname -s` != "Linux" ]] ; then
-   echo "This script is intended to be run from Linux. Aborting!"
-   echo ""
-   exit 1
+    echo "This script is intended to be run from Linux. Aborting!"
+    echo ""
+    exit 1
 fi
 
 if [[ ! -f $RLConfFile || $1 == "--force" ]] ; then
-   if [[ -f /etc/default/grub ]] ; then
-      # We want the default options used by the distribution, stored here....
-      source /etc/default/grub
-   fi
-   RootFS=`df / | grep dev | cut -f 1 -d " "`
-   StartOfDevname=`echo $RootFS | cut -b 1-7`
-   if [[ $StartOfDevname == "/dev/sd" || $StartOfDevName == "/dev/hd" ]] ; then
-      # Identify root filesystem by UUID rather than by device node, if possible
-      Uuid=`blkid -o export -s UUID $RootFS 2> /dev/null | grep UUID=`
-      if [[ -n $Uuid ]] ; then
-         RootFS=$Uuid
-      fi
-   fi
-   DefaultOptions="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT"
-   echo "\"Boot with standard options\"        \"ro root=$RootFS $DefaultOptions \"" > $RLConfFile
-   echo "\"Boot to single-user mode\"          \"ro root=$RootFS $DefaultOptions single\"" >> $RLConfFile
-   echo "\"Boot with minimal options\"         \"ro root=$RootFS\"" >> $RLConfFile
+    RootFS=`df / | grep dev | cut -f 1 -d " "`
+    StartOfDevname=`echo $RootFS | cut -b 1-7`
+    if [[ $StartOfDevname == "/dev/sd" || $StartOfDevName == "/dev/hd" ]] ; then
+        # Identify root filesystem by UUID rather than by device node, if possible
+        Uuid=`blkid -o export -s UUID $RootFS 2> /dev/null | grep UUID=`
+        if [[ -n $Uuid ]] ; then
+            RootFS=$Uuid
+        fi
+    fi
+    DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/$/ /' | sed 's/initrd=.* //g' | sed 's/ *$//'`
+    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
 else
-   echo "Existing $RLConfFile found! Not overwriting!"
-   echo "To force overwriting, pass the --force option."
-   echo ""
+    echo "Existing $RLConfFile found! Not overwriting!"
+    echo "To force overwriting, pass the --force option."
+    echo ""
 fi