X-Git-Url: https://code.delx.au/refind/blobdiff_plain/d621a172f5c2ce0a0aea09c1bd9041c1c2e9787d..7c898f4a26b66344e4cc8ed5c2e272d5ea0a71dc:/install.sh diff --git a/install.sh b/install.sh old mode 100755 new mode 100644 index 479cef7..d77b8b0 --- a/install.sh +++ b/install.sh @@ -17,6 +17,10 @@ # # Revision history: # +# 0.4.5 -- Fixed check for rEFItBlesser in OS X +# 0.4.2 -- Added notice about BIOS-based OSes & made NVRAM changes in Linux smarter +# 0.4.1 -- Added check for rEFItBlesser in OS X +# 0.3.3.1 -- Fixed OS X 10.7 bug; also works as make target # 0.3.2.1 -- Check for presence of source files; aborts if not present # 0.3.2 -- Initial version # @@ -30,11 +34,34 @@ TargetDir=/EFI/refind # # Abort if the rEFInd files can't be found. +# Also sets $ConfFile to point to the configuration file, and +# $IconsDir to point to the icons directory CheckForFiles() { - if [[ ! -f $SourceDir/refind_ia32.efi || ! -f $SourceDir/refind_x64.efi || ! -f $SourceDir/refind.conf-sample || ! -d $SourceDir/icons ]] ; then - echo "One or more files missing! Aborting installation!" + # Note: This check is satisfied if EITHER the 32- or the 64-bit version + # is found, even on the wrong platform. This is because the platform + # hasn't yet been determined. This could obviously be improved, but it + # would mean restructuring lots more code.... + if [[ ! -f $RefindDir/refind_ia32.efi && ! -f $RefindDir/refind_x64.efi ]] ; then + echo "The rEFInd binary file is missing! Aborting installation!" exit 1 fi + + if [[ -f $RefindDir/refind.conf-sample ]] ; then + ConfFile=$RefindDir/refind.conf-sample + elif [[ -f $ThisDir/refind.conf-sample ]] ; then + ConfFile=$ThisDir/refind.conf-sample + else + echo "The sample configuration file is missing! Aborting installation!" + exit 1 + fi + + if [[ -d $RefindDir/icons ]] ; then + IconsDir=$RefindDir/icons + elif [[ -d $ThisDir/icons ]] ; then + IconsDir=$ThisDir/icons + else + echo "The icons directory is missing! Aborting installation!" + fi } # CheckForFiles() # Copy the rEFInd files to the ESP or OS X root partition. @@ -42,13 +69,13 @@ CheckForFiles() { CopyRefindFiles() { mkdir -p $InstallPart/$TargetDir &> /dev/null if [[ $Platform == 'EFI32' ]] ; then - cp $SourceDir/refind_ia32.efi $InstallPart/$TargetDir + cp $RefindDir/refind_ia32.efi $InstallPart/$TargetDir if [[ $? != 0 ]] ; then Problems=1 fi Refind="refind_ia32.efi" elif [[ $Platform == 'EFI64' ]] ; then - cp $SourceDir/refind_x64.efi $InstallPart/$TargetDir + cp $RefindDir/refind_x64.efi $InstallPart/$TargetDir if [[ $? != 0 ]] ; then Problems=1 fi @@ -64,7 +91,7 @@ CopyRefindFiles() { mv -f $InstallPart/$TargetDir/icons $InstallPart/$TargetDir/icons-backup echo "Notice: Backed up existing icons directory as icons-backup." fi - cp -r $SourceDir/icons $InstallPart/$TargetDir + cp -r $IconsDir $InstallPart/$TargetDir if [[ $? != 0 ]] ; then Problems=1 fi @@ -72,7 +99,7 @@ CopyRefindFiles() { echo "Existing refind.conf file found; copying sample file as refind.conf-sample" echo "to avoid collision." echo "" - cp -f $SourceDir/refind.conf-sample $InstallPart/$TargetDir + cp -f $ConfFile $InstallPart/$TargetDir if [[ $? != 0 ]] ; then Problems=1 fi @@ -80,7 +107,7 @@ CopyRefindFiles() { echo "Copying sample configuration file as refind.conf; edit this file to configure" echo "rEFInd." echo "" - cp -f $SourceDir/refind.conf-sample $InstallPart/$TargetDir/refind.conf + cp -f $ConfFile $InstallPart/$TargetDir/refind.conf if [[ $? != 0 ]] ; then Problems=1 fi @@ -99,7 +126,7 @@ CopyRefindFiles() { MountOSXESP() { # Identify the ESP. Note: This returns the FIRST ESP found; # if the system has multiple disks, this could be wrong! - Temp=`diskutil list | grep EFI` + Temp=`diskutil list | grep " EFI "` Esp=/dev/`echo $Temp | cut -f 5 -d ' '` # If the ESP is mounted, use its current mount point.... Temp=`df | grep $Esp` @@ -136,11 +163,29 @@ InstallOnOSX() { if [[ $? != 0 ]] ; then Problems=1 fi + if [[ -f /Library/StartupItems/rEFItBlesser || -d /Library/StartupItems/rEFItBlesser ]] ; then + echo + echo "/Library/StartupItems/rEFItBlesser found!" + echo "This program is part of rEFIt, and will cause rEFInd to fail to work after" + echo -n "its first boot. Do you want to remove rEFItBlesser (Y/N)? " + read YesNo + if [[ $YesNo == "Y" || $YesNo == "y" ]] ; then + echo "Deleting /Library/StartupItems/rEFItBlesser..." + rm -r /Library/StartupItems/rEFItBlesser + else + echo "Not deleting rEFItBlesser." + fi + fi echo echo "WARNING: If you have an Advanced Format disk, *DO NOT* attempt to check the" echo "bless status with 'bless --info', since this is known to cause disk corruption" echo "on some systems!!" echo + echo "NOTE: If you want to boot an OS via BIOS emulation (such as Windows or some" + echo "Linux installations), you *MUST* edit the $InstallPart/$TargetDir/refind.conf" + echo "file's 'scanfor' line to include the 'hdbios' option, and perhaps" + echo "'biosexternal' and 'cd', as well." + echo } # InstallOnOSX() @@ -166,6 +211,7 @@ FindLinuxESP() { # Uses efibootmgr to add an entry for rEFInd to the EFI's NVRAM. # If this fails, sets Problems=1 AddBootEntry() { + InstallIt="0" Efibootmgr=`which efibootmgr 2> /dev/null` if [[ $Efibootmgr ]] ; then modprobe efivars &> /dev/null @@ -173,17 +219,27 @@ AddBootEntry() { PartNum=`grep $InstallPart /etc/mtab | cut -d " " -f 1 | cut -c 9-10` EntryFilename=$TargetDir/$Refind EfiEntryFilename=`echo ${EntryFilename//\//\\\}` - ExistingEntry=`$Efibootmgr -v | grep $Refind` + EfiEntryFilename2=`echo ${EfiEntryFilename} | sed s/\\\\\\\\/\\\\\\\\\\\\\\\\/g` + ExistingEntry=`$Efibootmgr -v | grep $EfiEntryFilename2` if [[ $ExistingEntry ]] ; then - echo "An existing EFI boot manager entry for rEFInd seems to exist:" - echo - echo "$ExistingEntry" - echo - echo "This entry is NOT being modified, and no new entry is being created." + 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 it!" $Efibootmgr -c -l $EfiEntryFilename -L rEFInd -d $InstallDisk -p $PartNum &> /dev/null if [[ $? != 0 ]] ; then - EfibootmgrProblems=1 + EfibootmgrProblems=1 Problems=1 fi fi @@ -239,9 +295,10 @@ InstallOnLinux() { # install under OS X or Linux, depending on the detected platform. # -ThisScript=`readlink -f $0` OSName=`uname -s` -SourceDir=`dirname $ThisScript`/refind +ThisDir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +RefindDir="$ThisDir/refind" +ThisScript="$ThisDir/`basename $0`" CheckForFiles if [[ `whoami` != "root" ]] ; then echo "Not running as root; attempting to elevate privileges via sudo...."