+PATH=$PATH:/usr/local/bin
+# Remove any existing NVRAM entry for rEFInd, to avoid creating a duplicate.
+ExistingEntry=`efibootmgr | grep "rEFInd Boot Manager" | cut -c 5-8`
+if [[ -n $ExistingEntry ]] ; then
+ efibootmgr --bootnum $ExistingEntry --delete-bootnum
+fi
+
+cd /usr/share/refind-%{version}
+
+declare VarFile=`ls -d /sys/firmware/efi/vars/SecureBoot* 2> /dev/null`
+declare ShimFile=`find /boot -name shim\.efi 2> /dev/null | grep -v refind | head -n 1`
+declare SBSign=`which sbsign 2> /dev/null`
+declare OpenSSL=`which openssl 2> /dev/null`
+
+# Run the rEFInd installation script. Do so with the --shim option
+# if Secure Boot mode is suspected and if a shim program can be
+# found, or without it if not. If a shim installation is attempted
+# and the sbsign and openssl programs can be found, do the install
+# using a local signing key. Note that this option is undesirable
+# for a distribution, since it would then require the user to
+# enroll an extra MOK. I'm including it here because I'm NOT a
+# distribution maintainer, and I want to encourage users to use
+# their own local keys.
+if [[ -n $VarFile && -n $ShimFile ]] ; then
+ if [[ -n $SBSign && -n $OpenSSL ]] ; then
+ ./install.sh --shim $ShimFile --localkeys --yes
+ else
+ ./install.sh --shim $ShimFile --yes
+ fi
+else
+ ./install.sh --yes
+fi
+
+# CAUTION: Don't create a %preun or a %postun script that deletes the files
+# installed by install.sh, since that script will run after an update, thus
+# wiping out the just-updated files.