Skip to content

Commit

Permalink
grub2-mkconfig: Ensure grub cfg stub is not overwritten
Browse files Browse the repository at this point in the history
/boot/efi/EFI/$os_name/grub.cfg contains a grub cfg stub
that should not be overwritten by grub2-mkconfig.
Ensure that we prevent this from happening.

Signed-off-by: Marta Lewandowska <[email protected]>
Signed-off-by: Nicolas Frayer <[email protected]>
  • Loading branch information
nfrayer committed Jul 16, 2024
1 parent 6b8cb20 commit 2b9a830
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions util/grub-mkconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ do
esac
done

os_name=$(grep '^ID=' /etc/os-release | sed 's/ID=//')
if test "$os_name" = '"rhel"'; then
os_name=redhat
elif test "$os_name" = '"centos"'; then
os_name=centos
fi
if test "x${grub_cfg}" = "x/boot/efi/EFI/$os_name/grub.cfg" &&\
mountpoint -q /boot/efi; then
gettext_printf "Running \`grub2-mkconfig -o %s' will overwrite the GRUB wrapper.\n" "$grub_cfg" 1>&2
gettext_printf "Please run \`grub2-mkconfig -o /boot/grub2/grub.cfg' instead to update grub.cfg.\n" 1>&2
gettext_printf "GRUB configuration file was not updated.\n" 1>&2
exit 1
fi

if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
Expand Down

0 comments on commit 2b9a830

Please sign in to comment.