Skip to content

Instantly share code, notes, and snippets.

@2xsaiko
Created November 7, 2021 13:55
Show Gist options
  • Save 2xsaiko/6b973ca295f5bf332562dcfb428befd4 to your computer and use it in GitHub Desktop.
Save 2xsaiko/6b973ca295f5bf332562dcfb428befd4 to your computer and use it in GitHub Desktop.
# /usr/local/sbin/mkbootentry
#!/bin/bash
ROOTFS=PARTUUID=90ab8cc5-82e3-c047-a162-2c8dde238121
#CMDLINE="net.ifnames=0 fbcon=font:SUN12x22 quiet"
CMDLINE="net.ifnames=0 quiet"
KERNEL=/usr/src/linux
ENTRY_NAME=Gentoo
BOOT_CONF=gentoo.conf
OLD_BOOT_CONF=gentoo.conf.old
echo -n "checking ${KERNEL} kernel version... "
cd "${KERNEL}"
kv="$(make kernelrelease)"
image="vmlinuz-${kv}"
echo "${kv}"
echo -n "checking for /boot/${image}... "
if [[ -f /boot/${image} ]]; then
echo "found"
else
echo "not found"
exit 1
fi
echo -n "checking for /lib/modules/${kv}/... "
if [[ -d /lib/modules/${kv}/ ]]; then
echo "found"
else
echo "not found"
exit 1
fi
echo -n "backing up current systemd-boot boot entries... "
cd /boot/loader/entries
if grep -q "${kv}" ${BOOT_CONF}; then
echo "skipped"
else
sed -e 's/^title .*$/title ${ENTRY_NAME} (Previous)/' ${BOOT_CONF} > ${OLD_BOOT_CONF}
echo "done"
fi
echo -n "generating systemd-boot boot entries... "
echo "title ${ENTRY_NAME}" > ${BOOT_CONF}
echo "linux /${image}" >> ${BOOT_CONF}
#echo "initrd /initramfs-${kv}.img" >> ${BOOT_CONF}
echo "options root=${ROOTFS} ${CMDLINE}" >> ${BOOT_CONF}
echo "done"
# /etc/kernel/postinst.d/mkbootentry
#!/bin/sh
export -n ARCH
exec mkbootentry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment