#!/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 'Ejecútelo con sudo.' >&2
	exit 1
fi
if [ ! -d /sys/firmware/efi ]; then
	echo 'Sin UEFI no hay Secure Boot; nada que hacer.'
	exit 0
fi
if mokutil --test-key "$cert" | grep -q 'is already enrolled'; then
	echo 'La clave bashclub ya está registrada.'
	exit 0
fi
printf '%s\n%s\n' bashclub bashclub | mokutil --import "$cert"
echo 'Pendiente. En el próximo reinicio, en el MokManager azul:
  Enroll MOK → Continue → Yes → contraseña bashclub → Reboot'
