File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed
var/lib/delphix-sb-enroll Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ configure)
6969 systemctl enable delphix-rpool-upgrade.service
7070 systemctl enable delphix.target
7171
72+ systemctl unmask delphix-sb-enroll.service
73+ systemctl enable delphix-sb-enroll.service
74+
7275 if ! id -u postgres > /dev/null; then
7376 # When installing postgres, a postgres user is created unless it
7477 # already exists. To have a consistent UID accross installations
Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description =Enroll Secure Boot variables (PK/KEK/db) from .auth files
3+ Documentation =man:efi-updatevar(1)
4+ DefaultDependencies =no
5+ Before =delphix-platform.service
6+ After =var-delphix.mount local-fs.target
7+ ConditionPathExists =/var/delphix/server/sb_certs/
8+
9+ [Service]
10+ Type =oneshot
11+ Environment =SB_AUTH_DIR =/var/delphix/server/sb_certs/
12+ ExecStart =/var/lib/delphix-sb-enroll/sb-enroll-efivars.sh
13+ # Prevent accidental re-runs the same boot unless you change the inputs
14+ RemainAfterExit =no
15+
16+ [Install]
17+ WantedBy =delphix-platform.service
18+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ AUTH_DIR=" ${SB_AUTH_DIR:-/ var/ delphix/ server/ sb_certs/ } "
5+
6+ log () { printf ' [sb-enroll] %s\n' " $* " >&2 ; }
7+ die () {
8+ log " ERROR: $* "
9+ exit 1
10+ }
11+
12+ # Do nothing if Secure Boot is already enabled.
13+ sb=$( od -An -t u1 /sys/firmware/efi/efivars/SecureBoot-* | awk ' {print $NF}' )
14+ [[ $sb -eq 1 ]] && exit 0
15+
16+ #
17+ # Run only on AWS.
18+ #
19+ # Expand this logic to support additional clouds.
20+ #
21+ if [[ $( get-appliance-platform) = " aws" ]]; then
22+ log " AWS detected"
23+ else
24+ log " Not AWS; skipping Secure Boot enrollment."
25+ exit 0
26+ fi
27+
28+ [[ -d /sys/firmware/efi/efivars ]] || die " Not booted in UEFI mode (/sys/firmware/efi/efivars missing)."
29+
30+ # Ensure efivars is mounted (usually is on Ubuntu)
31+ if ! mountpoint -q /sys/firmware/efi/efivars; then
32+ log " Mounting efivarfs..."
33+ sudo mount -t efivarfs efivarfs /sys/firmware/efi/efivars
34+ fi
35+
36+ [[ -d " $AUTH_DIR " ]] || die " Auth directory not found: $AUTH_DIR "
37+
38+ apply_auth () {
39+ local var=" $1 " # db, KEK, PK
40+ local file=" $AUTH_DIR /${var} .auth"
41+
42+ sudo efi-updatevar -f " $file " " $var "
43+ log " ${var} : update submitted"
44+ }
45+
46+ apply_auth db
47+ apply_auth KEK
48+ apply_auth PK
49+
50+ log " Rebooting..."
51+ init 6
You can’t perform that action at this time.
0 commit comments