#!/bin/sh usage() { echo "usage: mkuki " } disk="$1" part="$2" ([ -z "${disk}" ] || [ -z "${part}" ]) && usage && exit 1 kernel="$3" log() { echo "========================================================================" echo "$@" echo "========================================================================" } set -e # Generates an Unified Kernel Image. kernel="${kernel:-$(uname --kernel-release)}" version="${kernel%%-gentoo*}" bootnum="$(efibootmgr | grep "BootCurrent" | awk '{ print $2 }')" log "Generating Unified Kernel Image" dracut --kver="${kernel}" --force /efi/gentoo.efi.signed log "Deleting previous UEFI entry (bootnum ${bootnum})" efibootmgr \ --delete-bootnum \ --bootnum "${bootnum}" || echo "warn: could not delete existing boot partition!" label="Gentoo (Linux ${version})" log "Creating new UEFI entry '${label}'" efibootmgr \ --create \ --label "${label}" \ --disk "${disk}" \ --part "${part}" \ --loader "\gentoo.efi.signed"