Files
packages/anda/tools/sbctl/91-sbctl-rm
T
Pornpipat Popum bbca6283c4 Attempt to fix sbctl again (#7154)
* Attempt to fix sbctl

* debug: enable xtrace in verbosity

* bump package release

* Also add removal script
2025-11-06 13:20:12 -06:00

42 lines
982 B
Bash

#!/usr/bin/sh
# This file is part of sbctl.
# Patched for Fedora, for the Terra repository
#shellcheck disable=SC2034
# Enable xtrace if we're verbose
if [ "${KERNEL_INSTALL_VERBOSE:-0}" = "1" ]; then
set -x
fi
ver=${1}
img=${2}
die() {
echo -e " ${NOCOLOR-\e[1;31m*\e[0m }${*}" >&2
exit 1
}
einfo() {
echo -e " ${NOCOLOR-\e[1;32m*\e[0m }${*}"
}
main() {
# re-define for subst to work
[[ -n ${NOCOLOR+yes} ]] && NOCOLOR=
einfo "Unregistering kernel file from sbctl"
# do nothing if secureboot key directory doesn't exist
if ! [ "$(sbctl setup --print-state --json | awk '/installed/ { gsub(/,$/,"",$2); print $2 }')" = "true" ]; then
einfo "Secureboot key directory doesn't exist, not signing!"
exit 0
fi
[[ ${EUID} -eq 0 ]] || die "Please run this script as root"
einfo "sbctl: Unregistering kernel $img"
sbctl remove-file $img
}
main