X-Git-Url: https://code.delx.au/refind/blobdiff_plain/fe0f3d769a97966be67a9a8c5404f574123f7b3a..6fa3233825d299fea15eb837398ac6c9bfd05bb0:/refind-install diff --git a/refind-install b/refind-install index a59c158..0f4accd 100755 --- a/refind-install +++ b/refind-install @@ -36,9 +36,10 @@ # # Revision history: # -# 0.9.3 -- Enable running under OS X's recovery system & add warning about +# 0.10.0 -- Enable running under OS X's recovery system & add warning about # SIP & brief instructions on how to deal with it if SIP is -# detected to be enabled. +# detected to be enabled. Also change way refind_linux.conf default +# options are found; use /proc/cmdline as base. # 0.9.2 -- Added --keepname option. # 0.8.7 -- Better detection of Secure Boot mode & fixed errors when copying # Shim & MokManager files over themselves; fixed bug that caused @@ -167,11 +168,11 @@ GetParams() { echo "or --preloader! Aborting!" exit 1 fi - if [[ "$KeepName" == 1 && "$OSTYPE" != "linux-gnu" ]] ; then + if [[ "$KeepName" == 1 && "$OSTYPE" != "linux" && "$OSTYPE" != "linux-gnu" ]] ; then echo "The --keepname option is valid only under Linux! Aborting!" exit 1 fi - if [[ "$KeepName" == 1 && "$TargetDir" != "/EFI/BOOT" ]] ; then + if [[ "$KeepName" == 1 && "$TargetDir" == "/EFI/BOOT" ]] ; then echo "The --keepname option is incompatible with --usedefault! Aborting!" exit 1 fi @@ -398,13 +399,11 @@ DetermineTargetDir() { # Determine (or guess) the filesystem used on the Linux /boot filesystem. # Store the result in the BootFS global variable. SetBootFS() { - local Blkid - BootFS="" case "$OSTYPE" in - linux-gnu) - if command -v blkid 2>/dev/null; then - BootPart=`df /boot | grep dev | cut -f 1 -d " "` + linux*) + if command -v blkid &>/dev/null; then + BootPart=`df $RootDir/boot | grep dev | cut -f 1 -d " "` BootFS=`blkid -o export $BootPart 2> /dev/null | grep TYPE= | cut -f 2 -d =` fi ;; @@ -607,7 +606,7 @@ MountDefaultTarget() { else mount -t msdos "$TargetPart" "$InstallDir" fi - elif [[ $OSTYPE == linux-gnu ]] ; then + elif [[ $OSTYPE == linux* ]] ; then mount -t vfat "$TargetPart" "$InstallDir" fi if [[ $? != 0 ]] ; then @@ -691,7 +690,7 @@ SetupMacHfs() { ProductName rEFInd ProductVersion - 0.9.2 + 0.10.0 ENDOFHERE @@ -699,7 +698,8 @@ ENDOFHERE CheckForSIP() { if [[ -x "/usr/bin/csrutil" ]] ; then - local OKToInstall=`/usr/bin/csrutil status | grep "Protection status: enabled (Custom Configuration\|Apple Internal)"` + local OKToInstall=`/usr/bin/csrutil status | \ + grep "Protection status: disabled\|enabled (Apple Internal)\|NVRAM Protections: disabled"` if [[ -z "$OKToInstall" ]] ; then echo echo "**** ALERT: SIP ENABLED! ****" @@ -762,7 +762,7 @@ InstallOnOSX() { CheckForSIP Platform=`ioreg -l -p IODeviceTree | grep firmware-abi | cut -d "\"" -f 4` CopyRefindFiles - cp "$ThisDir/mountesp" /usr/local/bin + cp "$ThisDir/mountesp" /usr/local/bin &> /dev/null if [[ $InstallToEspOnMac == "1" ]] ; then bless --mount "$InstallDir" --setBoot --file "$InstallDir/$TargetDir/$Refind" --shortform elif [[ "$TargetDir" != "/EFI/BOOT" ]] ; then @@ -1074,11 +1074,6 @@ GenerateRefindLinuxConf() { echo "Existing $RLConfFile found; not overwriting." else echo "Creating $RLConfFile; edit it to adjust kernel options." - if [[ -f "$RootDir/etc/default/grub" ]] ; then - # We want the default options used by the distribution, stored here.... - source "$RootDir/etc/default/grub" - echo "Setting default boot options based on $RootDir/etc/default/grub" - fi RootFS=`df "$RootDir" | grep dev | cut -f 1 -d " "` StartOfDevname=`echo "$RootFS" | cut -b 1-7` if [[ "$StartOfDevname" == "/dev/sd" || "$StartOfDevName" == "/dev/hd" ]] ; then @@ -1088,10 +1083,19 @@ GenerateRefindLinuxConf() { 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 - echo "\"Boot with minimal options\" \"ro root=$RootFS\"" >> $RLConfFile + if [[ $RootDir == "/" ]] ; then + DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/$/ /' | sed 's/initrd=.* //g' | sed 's/ *$//'` + else + if [[ -f "$RootDir/etc/default/grub" ]] ; then + # We want the default options used by the distribution, stored here.... + source "$RootDir/etc/default/grub" + echo "Setting default boot options based on $RootDir/etc/default/grub" + fi + DefaultOptions="ro root=$RootFS $GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT" + fi + echo "\"Boot with standard options\" \"$DefaultOptions\"" > $RLConfFile + echo "\"Boot to single-user mode\" \"$DefaultOptions single\"" >> $RLConfFile + echo "\"Boot with minimal options\" \"ro root=$RootFS\"" >> $RLConfFile fi } @@ -1130,9 +1134,8 @@ InstallOnLinux() { echo "CAUTION: This Linux installation uses a 32-bit kernel. 32-bit EFI-based" echo "computers are VERY RARE. If you've installed a 32-bit version of Linux" echo "on a 64-bit computer, you should manually install the 64-bit version of" - echo "rEFInd. If you're installing on a Mac, you should do so from OS X. If" - echo "you're positive you want to continue with this installation, answer 'Y'" - echo "to the following question..." + echo "rEFInd. If you're positive you want to continue with this installation," + echo "answer 'Y' to the following question..." echo echo -n "Are you sure you want to continue (Y/N)? " ReadYesNo @@ -1190,7 +1193,7 @@ case "$OSTYPE" in fi InstallOnOSX $1 ;; - linux-gnu) + linux*) InstallOnLinux ;; *) @@ -1216,7 +1219,14 @@ fi if [[ $UnmountEsp == '1' ]] ; then echo "Unmounting install dir" - umount $InstallDir + case "$OSTYPE" in + darwin*) + diskutil unmount $InstallDir + ;; + *) + umount $InstallDir + ;; + esac fi if [[ "$InstallDir" == /tmp/refind_install ]] ; then