Commit 2f0f4d58 authored by Mike Hibler's avatar Mike Hibler

CentOS 7 puts grub config in /boot/grub2/ instead of /boot/grub/.

Also, fix the parsing and fixup of grub boot device string in FBSD version.
parent feba4d40
......@@ -1002,11 +1002,13 @@ dolinux() {
#
needfsck=0
fgconf=""
for f in grub.conf grub.cfg menu.lst; do
if [ -z "$fgconf" -a -r /mnt/boot/grub/$f ]; then
fgconf=/boot/grub/$f
gconf=/mnt$fgconf
fi
for d in grub2 grub; do
for f in grub.conf grub.cfg menu.lst; do
if [ -z "$fgconf" -a -r /mnt/boot/$d/$f ]; then
fgconf=/boot/$d/$f
gconf=/mnt$fgconf
fi
done
done
if [ -n "$fgconf" -a -r "$gconf" ]; then
echo " updating $fgconf"
......@@ -1033,9 +1035,13 @@ dolinux() {
# Ditto for UUID if we have one and grub conf uses it
if [ -n "$RUUID" ] && \
grep -q '[br]oot=\)UUID=[^ ]* ' $tgconf 2>/dev/null; then
echo " fixing root (UUID)"
sed -i '' -e "s;\([br]oot=\)UUID=[^ ]* ;\1UUID=$RUUID ;" $tgconf
grep -q -E '[br]oot=UUID=[^ ]+ ' $tgconf 2>/dev/null; then
OUUID=`grep -E -m 1 '[br]oot=UUID=[^ ]+ ' $tgconf | \
sed -e 's;.*UUID=\([^ ]*\) .*;\1;'`
if [ -n "$OUUID" -a $RUUID -ne $OUUID ]; then
echo " fixing root (UUID)"
sed -i '' -e "s;$OUUID;$RUUID;g" $tgconf
fi
fi
#
......@@ -1082,6 +1088,11 @@ dolinux() {
echo " setting grub2 root to (hd${gdisk},${part})"
sed -i '' -e "s;set root='(hd[0-9],[^)]*)';set root='(hd${gdisk},${part})';" $tgconf
fi
# maybe no parens around the expression
if grep -q "^[^#].*set root='hd[0-9],[^']*'" $tgconf 2>/dev/null; then
echo " setting grub2 root to hd${gdisk},${part}"
sed -i '' -e "s;set root='hd[0-9],[^']*';set root='hd${gdisk},${part}';" $tgconf
fi
#
# Console.
......
......@@ -1026,7 +1026,9 @@ sub main
# HACK: there's no simple way to distinguish grub2 from grub
# by the boot sector.
if ($bootloader eq 'grub' && -f "$imageroot/boot/grub/grub.cfg") {
if ($bootloader eq 'grub' &&
(-f "$imageroot/boot/grub2/grub.cfg" ||
-f "$imageroot/boot/grub/grub.cfg")) {
$bootloader = 'grub2';
}
......@@ -1047,7 +1049,7 @@ sub main
}
elsif ($bootloader eq 'grub2') {
for (qw#/boot/grub/grub.cfg#) {
for (qw#/boot/grub2/grub.cfg /boot/grub/grub.cfg#) {
if (-f "$imageroot/$_") {
$grub_config = $_;
last;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment