#!/bin/bash

. /usr/share/volatile/common.sh

set -x

OEM_MKGRUB_CALLBACK()
{
    echo $@ > /tmp/grub-updated
}

# Update GRUB config and reboot if necessary
export OEMTASK=earlytask
export -f OEM_MKGRUB_CALLBACK
update-grub

if [ -f /tmp/grub-updated ]; then
    cp /tmp/grub-updated /usr/share/volatile/gurb-updated
    trigger_reboot
fi
