aports/main/grub/grub.post-upgrade
Natanael Copa 252422bfa2 main/grub: run /etc/grub-autoinstall on upgrades
When grub is updated we may need to re-run grub-install or we may end up
with an unbootable system. Instead of trying to figure out what the
exact args are we simply execute the /etc/grub-autoinstall if it exists.

ref: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/53133
ref: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/58567
2024-01-26 14:27:32 +00:00

22 lines
442 B
Bash

#!/bin/sh
if [ -f /etc/default/grub ]; then
. /etc/default/grub
fi
if [ -z "$GRUB_CMDLINE_LINUX_DEFAULT" ]; then
set -- $(cat /proc/cmdline)
bootopts=
for opt; do
case "$opt" in
initrd=*|BOOT_IMAGE=*|root=*|rootflags=*) ;;
*) bootopts="$bootopts $opt";;
esac
done
mkdir -p /etc/default
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$bootopts\"" >> /etc/default/grub
fi
if [ -e /etc/grub-autoinstall ]; then
. /etc/grub-autoinstall
fi