]> code.delx.au - refind/blob - debian/postinst
Documentation updates for 0.10.3 release.
[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 if [ -f /usr/share/debconf/confmodule ] ; then
8 . /usr/share/debconf/confmodule
9 fi
10
11 install_to_esp() {
12 # Remove any existing NVRAM entry for rEFInd, to avoid creating a duplicate.
13 ExistingEntry=`efibootmgr | grep "rEFInd Boot Manager" | cut -c 5-8`
14 if [[ -n $ExistingEntry ]] ; then
15 efibootmgr --bootnum $ExistingEntry --delete-bootnum &> /dev/null
16 fi
17
18 cd /usr/share/refind
19
20 if [[ -f /sys/firmware/efi/vars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c/data ]] ; then
21 IsSecureBoot=`od -An -t u1 /sys/firmware/efi/vars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c/data | tr -d '[[:space:]]'`
22 else
23 IsSecureBoot="0"
24 fi
25 # Note: Two find operations for ShimFile favors shim over PreLoader -- if both are
26 # present, the script uses shim rather than PreLoader.
27 declare ShimFile=`find /boot -name shim\.efi -o -name shimx64\.efi -o -name PreLoader\.efi 2> /dev/null | head -n 1`
28 if [[ ! -n $ShimFile ]] ; then
29 declare ShimFile=`find /boot -name PreLoader\.efi 2> /dev/null | head -n 1`
30 fi
31 declare SBSign=`which sbsign 2> /dev/null`
32 declare OpenSSL=`which openssl 2> /dev/null`
33
34 # Run the rEFInd installation script. Do so with the --shim option
35 # if Secure Boot mode is suspected and if a shim program can be
36 # found, or without it if not. If a shim installation is attempted
37 # and the sbsign and openssl programs can be found, do the install
38 # using a local signing key. Note that this option is undesirable
39 # for a distribution, since it would then require the user to
40 # enroll an extra MOK. I'm including it here because I'm NOT a
41 # distribution maintainer, and I want to encourage users to use
42 # their own local keys.
43 if [[ $IsSecureBoot == "1" && -n $ShimFile ]] ; then
44 if [[ -n $SBSign && -n $OpenSSL ]] ; then
45 ./refind-install --shim $ShimFile --localkeys --yes > /dev/null
46 else
47 ./refind-install --shim $ShimFile --yes > /dev/null
48 fi
49 else
50 ./refind-install --yes > /dev/null
51 fi
52 } # install_to_esp()
53
54 #
55 # Main part of script begins
56 #
57
58 case "$1" in
59 configure)
60 db_get refind/install_to_esp || true;
61 if [ x"$RET" = x"true" ]; then
62 echo "Installing rEFInd to the ESP..."
63 install_to_esp
64 else
65 echo "** Not installing rEFInd to the ESP! **"
66 echo "If you want rEFInd to control the boot process, you can do so by runing:"
67 echo ""
68 echo "dpkg-reconfigure refind"
69 echo ""
70 fi
71 ;;
72
73 reconfigure)
74 db_get refind/install_to_esp || true;
75 if [ x"$RET" = x"true" ]; then
76 echo "Installing rEFInd to the ESP..."
77 install_to_esp
78 else
79 echo "If rEFInd was previously configured to be your primary boot manager, you must"
80 echo "use efibootmgr to set the computer to boot with something else."
81 fi
82 ;;
83
84 abort-upgrade|abort-remove|abort-deconfigure)
85 exit 0
86 ;;
87
88 *)
89 echo "postinst called with unknown argument \`$1'" >&2
90 exit 0
91 ;;
92 esac
93
94 #DEBHELPER#