blob: 35b1a0190a4969f7fb308d87335eaecac3d319b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#!/bin/bash
#
# script to install rEFInd
#
# Usage:
#
# refind-install
#
# This program is copyright (c) 2012 by David P. Crandall
# It is released under the terms of the GNU GPL, version 3.
# It is based on the work of Roderick W. Smith from the
# install.sh script in the rEFInd package.
#
# Revision history:
#
# 0.4.5 -- Initial version
#
# Note: version numbers match those of the rEFInd package
# with which this script first appeared.
InstallIt="0"
CpuType=$(uname -m)
if [[ $CpuType == 'x86_64' ]] ; then
Refind="refind_x64.efi"
elif [[ $CpuType == 'i386' || $CpuType == 'i486' || $CpuType == 'i586' || $CpuType == 'i686' ]] ; then
Refind="refind_ia32.efi"
ewarn "CAUTION: This Linux installation uses a 32-bit kernel. 32-bit EFI-based"
ewarn "computers are VERY RARE. If you've installed a 32-bit version of Linux"
ewarn "on a 64-bit computer, you should manually install the 64-bit version of"
ewarn "rEFInd. Installation will now proceed presuming a 32-bit EFI."
else
echo
echo "Unknown CPU type '$CpuType'; aborting!"
echo
exit
fi
Efibootmgr=$(which efibootmgr 2> /dev/null)
if [[ $Efibootmgr ]] ; then
modprobe efivars &> /dev/null
EspLine=$(df /boot/efi | grep boot)
InstallPart=$(echo $EspLine | cut -d " " -f 6)
InstallDisk=$(grep $InstallPart /etc/mtab | cut -d " " -f 1 | cut -c 1-8)
PartNum=$(grep $InstallPart /etc/mtab | cut -d " " -f 1 | cut -c 9-10)
TargetDir="/EFI/refind"
EntryFilename=$TargetDir/$Refind
EfiEntryFilename=$(echo ${EntryFilename//\//\\\})
EfiEntryFilename2=$(echo ${EfiEntryFilename} | sed s/\\\\\\\\/\\\\\\\\\\\\\\\\/g)
ExistingEntry=$($Efibootmgr -v | grep $EfiEntryFilename2)
if [[ $ExistingEntry ]] ; then
ExistingEntryBootNum=$(echo $ExistingEntry | cut -c 5-8)
FirstBoot=$($Efibootmgr | grep BootOrder | cut -c 12-15)
if [[ $ExistingEntryBootNum != $FirstBoot ]] ; then
echo "An existing rEFInd boot entry exists, but isn't set as the default boot"
echo "manager. The boot order is being adjusted to make rEFInd the default boot"
echo "manager. If this is NOT what you want, you should use efibootmgr to"
echo "manually adjust your EFI's boot order."
$Efibootmgr -b $ExistingEntryBootNum -B &> /dev/null
InstallIt="1"
fi
else
InstallIt="1"
fi
if [[ $InstallIt == "1" ]] ; then
echo "Installing rEFInd as default boot manager"
$Efibootmgr -c -l $EfiEntryFilename -L rEFInd -d $InstallDisk -p $PartNum &> /dev/null
if [[ $? != 0 ]] ; then
echo
echo "ALERT: There were problems running the efibootmgr program! You may need to"
echo "rename the rEFInd binary to the default name (EFI/boot/bootx64.efi"
echo "on x86-64 systems or EFI/boot/bootia32.efi on x86 systems) to have it run!"
echo
fi
fi
else
echo
echo "Could not locate the efibootmgr program."
echo
fi
|