nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/99-grub-mkconfig.install

8e15ce
#!/bin/bash
8e15ce
8e15ce
if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
8e15ce
    exit 0
8e15ce
fi
8e15ce
8e15ce
# PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support,
8e15ce
# also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from
8e15ce
# 10_linux. So BLS support needs to be disabled for both Xen Dom0 and DomU.
8e15ce
if [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then
8e15ce
    RUN_MKCONFIG=true
8e15ce
    DISABLE_BLS=true
8e15ce
fi
8e15ce
8e15ce
ARCH=$(uname -m)
8e15ce
# Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support
8e15ce
# so grub2-mkconfig has to be run to generate a config with menuentry commands.
8e15ce
if [[ $ARCH = "ppc64le" ]] && [ -d /sys/firmware/opal ]; then
8e15ce
8e15ce
    petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
8e15ce
8e15ce
    if test -e ${petitboot_path}; then
8e15ce
        read -r -d '' petitboot_version < ${petitboot_path}
8e15ce
        petitboot_version="$(echo ${petitboot_version//v})"
8e15ce
        major_version="$(echo ${petitboot_version} | cut -d . -f1)"
8e15ce
        minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
8e15ce
8e15ce
        if test -z ${petitboot_version} || test ${major_version} -lt 1 || \
8e15ce
           test ${major_version} -eq 1 -a ${minor_version} -lt 8; then
8e15ce
            RUN_MKCONFIG=true
8e15ce
        fi
8e15ce
    else
8e15ce
        RUN_MKCONFIG=true
8e15ce
    fi
8e15ce
fi
8e15ce
8e15ce
if [[ $DISABLE_BLS = "true" ]]; then
8e15ce
    if grep -q '^GRUB_ENABLE_BLSCFG="*true"*\s*$' /etc/default/grub; then
8e15ce
	sed -i 's/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/' /etc/default/grub
8e15ce
    fi
8e15ce
fi
8e15ce
c16371
[ -f /etc/default/grub ] && . /etc/default/grub
c16371
if [ x$GRUB_ENABLE_BLSCFG = xfalse ]; then
c16371
   RUN_MKCONFIG=true
c16371
fi
c16371
8e15ce
# A traditional grub configuration file needs to be generated only in the case when
8e15ce
# the bootloaders are not capable of populating a menu entry from the BLS fragments.
8e15ce
if [[ $RUN_MKCONFIG != "true" ]]; then
8e15ce
    exit 0
8e15ce
fi
8e15ce
8e15ce
COMMAND="$1"
8e15ce
8e15ce
case "$COMMAND" in
8e15ce
    add|remove)
8e15ce
        grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null
8e15ce
        ;;
8e15ce
    *)
8e15ce
        ;;
8e15ce
esac