#!/bin/bash

. /usr/share/preupgrade/common.sh

#END GENERATED SECTION
FILE_NAME="splash.xpm.gz"

if [[ -f "/boot/grub/$FILE_NAME" ]]; then
    POSTUPGRADE_DIR="$VALUE_TMP_PREUPGRADE/postupgrade.d/grub"
    if [[ ! -d "$POSTUPGRADE_DIR" ]]; then
        mkdir -p "$POSTUPGRADE_DIR"
    fi
    SCRIPT_NAME="postupgrade-grub.sh"
    POST_SCRIPT="postupgrade.d/$SCRIPT_NAME"
    cp -f $POST_SCRIPT $POSTUPGRADE_DIR/$SCRIPT_NAME
    cp -f /boot/grub/$FILE_NAME $POSTUPGRADE_DIR/$FILE_NAME

    {
        echo
        echo -n "The /boot/grub/splash.xpm.gz file will be preserved"
        echo -n " to work around the behavior of the existing GRUB. You"
        echo -n " can delete this file safely only after your GRUB 2 setup is"
        echo -n " working."
    } >> grub.txt

fi

log_high_risk "Back up the grub RPM manually before the upgrade. See the remediation instructions for more info."
log_medium_risk "After the upgrade, migrate GRUB to GRUB 2 manually."
exit_fail

