#!/bin/sh
# bashclub OS: bashclub-Schlüssel (MOK) einschreiben (bashclub-base)
set -eu
cert=/usr/share/bashclub/mok.der
if [ "$(id -u)" != 0 ]; then
	echo 'Please run with sudo.' >&2
	exit 1
fi
if [ ! -d /sys/firmware/efi ]; then
	echo 'Without UEFI there is no Secure Boot; nothing to do.'
	exit 0
fi
if mokutil --test-key "$cert" | grep -q 'is already enrolled'; then
	echo 'The bashclub key is already enrolled.'
	exit 0
fi
printf '%s\n%s\n' bashclub bashclub | mokutil --import "$cert"
echo 'Queued. At the next restart in the blue MokManager:
  Enroll MOK → Continue → Yes → password bashclub → Reboot'
