]> code.delx.au - refind/blob - mkrlconf
Added new "csr_rotate" option for "showtools", and matching
[refind] / mkrlconf
1 #!/bin/bash
2
3 # Script to create a refind_linux.conf file for the current Linux
4 # installation.
5
6 # copyright (c) 2012-2015 by Roderick W. Smith
7 #
8 # This program is licensed under the terms of the GNU GPL, version 3,
9 # a copy of which should be distributed with this program.
10
11 # Usage:
12 #
13 # ./mkrlconf [--force]
14 #
15 # Options:
16 #
17 # --force -- Overwrite an existing file (default is to not replace existing file)
18
19 # Revision history:
20 #
21 # 0.9.3 -- Renamed from mkrlconf.sh to mkrlconf
22 # 0.9.0 -- Added check for OS type, to keep from running pointlessly on OS X
23 # 0.7.7 -- Fixed bug that caused stray PARTUUID= and line breaks in generated file
24 # 0.5.1 -- Initial release
25 #
26 # Note: mkrlconf version numbers match those of the rEFInd package
27 # with which they first appeared.
28
29 RLConfFile="/boot/refind_linux.conf"
30
31 if [[ `uname -s` != "Linux" ]] ; then
32 echo "This script is intended to be run from Linux. Aborting!"
33 echo ""
34 exit 1
35 fi
36
37 if [[ ! -f $RLConfFile || $1 == "--force" ]] ; then
38 if [[ -f /etc/default/grub ]] ; then
39 # We want the default options used by the distribution, stored here....
40 source /etc/default/grub
41 fi
42 RootFS=`df / | grep dev | cut -f 1 -d " "`
43 StartOfDevname=`echo $RootFS | cut -b 1-7`
44 if [[ $StartOfDevname == "/dev/sd" || $StartOfDevName == "/dev/hd" ]] ; then
45 # Identify root filesystem by UUID rather than by device node, if possible
46 Uuid=`blkid -o export -s UUID $RootFS 2> /dev/null | grep UUID=`
47 if [[ -n $Uuid ]] ; then
48 RootFS=$Uuid
49 fi
50 fi
51 DefaultOptions="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT"
52 echo "\"Boot with standard options\" \"ro root=$RootFS $DefaultOptions \"" > $RLConfFile
53 echo "\"Boot to single-user mode\" \"ro root=$RootFS $DefaultOptions single\"" >> $RLConfFile
54 echo "\"Boot with minimal options\" \"ro root=$RootFS\"" >> $RLConfFile
55 else
56 echo "Existing $RLConfFile found! Not overwriting!"
57 echo "To force overwriting, pass the --force option."
58 echo ""
59 fi