#!/bin/sh -e

# do UID checking here so someone can at least get usage instructions
if [ "$EUID" != "0" ]; then
    echo "error: This script must be run as root."
    exit 1
fi

  if [ `readlink /boot/kernel26.img` ] ;
  then
    echo "removing backward-symlink"
    rm -v /boot/kernel26.img
  fi
  if [ `readlink /boot/kernel26-lts.img` ] ;
  then
    echo "removing backward-symlink"
    rm -v /boot/kernel26-lts.img
  fi
  if [ `readlink /boot/vmlinuz26` ] ;
  then
    echo "removing backward-symlink"
    rm -v /boot/vmlinuz26
  fi
  if [ `readlink /boot/vmlinuz26-lts` ] ;
  then
    echo "removing backward-symlink"
    rm -v /boot/vmlinuz26-lts
  fi

echo "Updating /boot/grub/grub.cfg"
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
