Skip to content

Commit 641f003

Browse files
nfrayerlsandov1
authored andcommitted
grub2-mkconfig: Ensure grub cfg stub is not overwritten
/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 <mlewando@redhat.com> Signed-off-by: Nicolas Frayer <nfrayer@redhat.com>
1 parent e4ab9b3 commit 641f003

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

util/grub-mkconfig.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ do
109109
esac
110110
done
111111

112+
os_name=$(grep '^ID=' /etc/os-release | sed 's/ID=//')
113+
if test "$os_name" = '"rhel"'; then
114+
os_name=redhat
115+
elif test "$os_name" = '"centos"'; then
116+
os_name=centos
117+
fi
118+
if test "x${grub_cfg}" = "x/boot/efi/EFI/$os_name/grub.cfg" &&\
119+
mountpoint -q /boot/efi; then
120+
gettext_printf "Running \`grub2-mkconfig -o %s' will overwrite the GRUB wrapper.\n" "$grub_cfg" 1>&2
121+
gettext_printf "Please run \`grub2-mkconfig -o /boot/grub2/grub.cfg' instead to update grub.cfg.\n" 1>&2
122+
gettext_printf "GRUB configuration file was not updated.\n" 1>&2
123+
exit 1
124+
fi
125+
112126
if [ "x$EUID" = "x" ] ; then
113127
EUID=`id -u`
114128
fi

0 commit comments

Comments
 (0)