Skip to content

Instantly share code, notes, and snippets.

@FoxBuru
Created September 28, 2020 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoxBuru/6a134d74824df5e5438343285bf4dbdd to your computer and use it in GitHub Desktop.
Save FoxBuru/6a134d74824df5e5438343285bf4dbdd to your computer and use it in GitHub Desktop.
Small script to hook MOK signing on Pop! OS for Secure Boot purposes, rEFInd needed
#!/bin/sh -e
# Detect root GUID partition
GUID=$(cat /proc/cmdline | grep -oP "root=UUID=\K(.*)(?= ro)")
REFIND_KEYS=/etc/refind.d/keys
EFIBASE=/boot/efi/EFI
die() { echo "$*" 1>&2 ; exit 1; }
# Check correct vmlinuz.efi path
[ -d ${EFIBASE}/Pop_OS-${GUID} ] || die "Cannot detect Pop! OS install on EFI"
[ -f ${EFIBASE}/Pop_OS-${GUID}/vmlinuz.efi ] || die "Cannot detect vmlinuz.efi on expected path"
# Check if binary is actually signed with our MOK key, to skip this step if needed
/usr/bin/sbverify --cert ${REFIND_KEYS}/refind_local.crt ${EFIBASE}/Pop_OS-${GUID}/vmlinuz.efi >/dev/null 2>&1 && die "vmlinuz.efi already signed. Exiting..."
/usr/bin/sbsign --key ${REFIND_KEYS}/refind_local.key --cert ${REFIND_KEYS}/refind_local.crt --output ${EFIBASE}/Pop_OS-${GUID}/vmlinuz.efi ${EFIBASE}/Pop_OS-${GUID}/vmlinuz.efi >/dev/null 2>&1 && echo "vmlinuz was found and signed correctly"
@FoxBuru
Copy link
Author

FoxBuru commented Sep 28, 2020

Instructions

  1. Put this file on /etc/kernel/postinst.d/zzz-sign-efi
  2. Change file permissions mode to 0755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment