]> code.delx.au - refind/commitdiff
Script to generate sample refind_linux.conf file.
authorsrs5694 <srs5694@users.sourceforge.net>
Wed, 12 Dec 2012 01:47:38 +0000 (20:47 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Wed, 12 Dec 2012 01:47:38 +0000 (20:47 -0500)
mkrlconf.sh [new file with mode: 0755]

diff --git a/mkrlconf.sh b/mkrlconf.sh
new file mode 100755 (executable)
index 0000000..ed1759b
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# Script to create a refind_linux.conf file for the current Linux
+# installation.
+
+# copyright (c) 2012 by Roderick W. Smith
+#
+# This program is licensed under the terms of the GNU GPL, version 3,
+# a copy of which should be distributed with this program.
+
+# Usage:
+#
+# ./mkrlconf.sh [--overwrite]
+#
+# Options:
+#
+#   --force  -- Overwrite an existing file (default is to not replace existing file)
+
+# Revision history:
+#
+#  0.5.1 -- Initial release
+#
+# Note: mkrlconf.sh version numbers match those of the rEFInd package
+# with which they first appeared.
+
+RLConfFile="/boot/refind_linux.conf"
+
+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 $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
+else
+   echo "Existing $RLConfFile found! Not overwriting!"
+   echo "To force overwriting, pass the --force option."
+   echo ""
+fi