Skip to content

Commit 6cd01dd

Browse files
committed
Add Mortar compatibility for the Secure Boot DKMS script
1 parent 5f9df77 commit 6cd01dd

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

security/secure_boot_dkms.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,33 @@ if [ "${EUID}" -ne 0 ]; then
1111
exit 1
1212
fi
1313

14-
echo "Configuring MOK for DKMS kernel modules."
15-
update-secureboot-policy --enroll-key
14+
if command -v mortar-compilesigninstall &> /dev/null; then
15+
HAS_MORTAR=true
16+
else
17+
HAS_MORTAR=false
18+
fi
19+
20+
if [ "${HAS_MORTAR}" = "true" ]; then
21+
echo "Configuring DKMS to use the Mortar MOK key."
22+
sed -i 's@^# mok_signing_key=/var/lib/dkms/mok.key@mok_signing_key="/etc/mortar/private/db.key"@g; s@^# mok_certificate=/var/lib/dkms/mok.pub@mok_certificate="/etc/mortar/private/db.crt"@g' "/etc/dkms/framework.conf"
23+
else
24+
echo "Currently enrolled MOK keys:"
25+
mokutil --list-enrolled
26+
echo "Configuring MOK for DKMS kernel modules."
27+
update-secureboot-policy --enroll-key
28+
echo "New MOK keys:"
29+
mokutil --list-new
30+
fi
31+
1632
echo "Updating initramfs."
1733
update-initramfs -u
1834

19-
if command -v mortar-compilesigninstall &> /dev/null; then
20-
echo "Mortar detected. Running mortar-compilesigninstall."
35+
if [ "${HAS_MORTAR}" = "true" ]; then
36+
echo "Running mortar-compilesigninstall to update the EFI file."
2137
mortar-compilesigninstall
38+
echo "DKMS MOK configuration ready. You should now reboot."
2239
else
2340
echo "Updating GRUB configuration."
2441
update-grub
42+
echo "DKMS MOK configuration ready. You should now reboot and then input the MOK password to enroll the key."
2543
fi

0 commit comments

Comments
 (0)