+} # ReSignBinaries()
+
+# Locate and mount an ESP, if possible, based on parted output.
+# Should be called only if /boot/efi is NOT an acceptable ESP.
+# Sets InstallDir to the mounted ESP's path ($RootDir/boot/efi)
+# and EspFilesystem the filesystem (always "vfat")
+FindLinuxESP() {
+ echo "The ESP doesn't seem to be mounted! Trying to find it...."
+ local Drive
+ local PartNum
+ local TableType
+ local DmStatus
+ local SkipIt
+ for Drive in `ls /dev/[sh]d?` ; do
+ SkipIt=0
+ if [ -x `which dmraid` ] ; then
+ DmStatus=`dmraid -r | grep $Drive`
+ if [ -n "$DmStatus" ] ; then
+ echo "$Drive seems to be part of a RAID array; skipping!"
+ SkipIt=1
+ fi
+ fi
+ TableType=`parted $Drive print -m -s 2>/dev/null | awk -F: '$1 == "'$Drive'" { print $6 }'`
+ if [[ $TableType == 'gpt' && $SkipIt == 0 ]] ; then # read only GPT disks that aren't part of dmraid array
+ PartNum=`LANG=C parted $Drive print -m -s 2>/dev/null | awk -F: '$7 ~ "(^boot| boot)" { print $1 }' | head -n 1`
+ if [ "$PartNum" -eq "$PartNum" ] 2> /dev/null ; then
+ InstallDir="$RootDir/boot/efi"
+ mkdir -p $InstallDir
+ mount $Drive$PartNum $InstallDir
+ EspFilesystem=`grep "$Drive$PartNum.*/boot/efi" /etc/mtab | uniq | grep -v autofs | cut -d " " -f 3`
+ if [[ $EspFilesystem != 'vfat' ]] ; then
+ umount $InstallDir
+ else
+ echo "Mounting ESP at $InstallDir"
+ break;
+ fi
+ fi # $PartNum -eq $PartNum
+ fi # TableType
+ done
+} # FindLinuxESP()