#! /bin/bash
# support for GRUB version 2 (1.98-1)

error=0 ; trap "error=$((error|1))" ERR

set -a

# during softupdate use this file
[ -r $LOGDIR/disk_var.sh ] && . $LOGDIR/disk_var.sh

[ -z "$BOOT_DEVICE" ]    && exit 701

$ROOTCMD grub-mkdevicemap --no-floppy
# needed for ubuntu
$ROOTCMD grub-mkconfig -o /boot/grub/grub.cfg

GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
# see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=606035
GROOT=$(echo $GROOT | sed 's:md/:md:g')

$ROOTCMD grub-install --no-floppy "$GROOT"
echo "Grub installed on $BOOT_DEVICE = $GROOT"

$ROOTCMD update-grub


exit $error
