summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-boot/refind-bin/files/refind-install')
-rwxr-xr-xsys-boot/refind-bin/files/refind-install80
1 files changed, 80 insertions, 0 deletions
diff --git a/sys-boot/refind-bin/files/refind-install b/sys-boot/refind-bin/files/refind-install
new file mode 100755
index 0000000..35b1a01
--- /dev/null
+++ b/sys-boot/refind-bin/files/refind-install
@@ -0,0 +1,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