]> code.delx.au - refind/blob - debian/postinst
Post-install script for native Debian package.
[refind] / debian / postinst
1 #!/bin/bash
2 # Post-installation script (run on USER'S system after installing the
3 # main rEFInd package)
4
5 set -e
6
7 # Remove any existing NVRAM entry for rEFInd, to avoid creating a duplicate.
8 ExistingEntry=`efibootmgr | grep "rEFInd Boot Manager" | cut -c 5-8`
9 if [[ -n $ExistingEntry ]] ; then
10 efibootmgr --bootnum $ExistingEntry --delete-bootnum
11 fi
12
13 cd /usr/share/refind-0.8.1
14
15 declare VarFile=`ls -d /sys/firmware/efi/vars/SecureBoot* 2> /dev/null`
16 # Note: Two find operations for ShimFile favors shim over PreLoader -- if both are
17 # present, the script uses shim rather than PreLoader.
18 declare ShimFile=`find /boot -name shim\.efi -o -name shimx64\.efi -o -name PreLoader\.efi 2> /dev/null | head -n 1`
19 if [[ ! -n $ShimFile ]] ; then
20 declare ShimFile=`find /boot -name PreLoader\.efi 2> /dev/null | head -n 1`
21 fi
22 declare SBSign=`which sbsign 2> /dev/null`
23 declare OpenSSL=`which openssl 2> /dev/null`
24
25 # Run the rEFInd installation script. Do so with the --shim option
26 # if Secure Boot mode is suspected and if a shim program can be
27 # found, or without it if not. If a shim installation is attempted
28 # and the sbsign and openssl programs can be found, do the install
29 # using a local signing key. Note that this option is undesirable
30 # for a distribution, since it would then require the user to
31 # enroll an extra MOK. I'm including it here because I'm NOT a
32 # distribution maintainer, and I want to encourage users to use
33 # their own local keys.
34 if [[ -n $VarFile && -n $ShimFile ]] ; then
35 if [[ -n $SBSign && -n $OpenSSL ]] ; then
36 ./install.sh --shim $ShimFile --localkeys --yes
37 else
38 ./install.sh --shim $ShimFile --yes
39 fi
40 else
41 ./install.sh --yes
42 fi