#! /bin/sh -e

# update-grub helper script.
# Copyright (C) 2006,2007,2008  Free Software Foundation, Inc.
#
#
# GRUB_DEVICE - Device containing our userland.  Typically used for root= parameter.
# GRUB_FS - Filesystem for the device containing our userland
# GRUB_DRIVE - GRUB path to /.  Only used for "set root=".  Not critical.
# GRUB_DRIVE_BOOT - GRUB path to /boot
# GRUB_DRIVE_BOOT_GRUB - GRUB path to /boot/grub
#
. /etc/sysconfig/grub2

_MENUENTRY_NAME=$(cat /etc/altlinux-release)

ROOT_UUID=$(blkid -o value $GRUB_DEVICE | sed -n '2p')


test -h /boot/vmlinuz && test -h /boot/initrd.img && cat << E_O_F
menuentry "${_MENUENTRY_NAME}" {
	linux ${GRUB_DRIVE_BOOT}/vmlinuz root=UUID=${ROOT_UUID} $APPEND
	initrd ${GRUB_DRIVE_BOOT}/initrd.img
}
E_O_F

for kernel in $(ls /boot/vmlinuz* | sed 's|/boot/vmlinuz-||g' | grep -v vmlinuz)
do
cat << E_O_F
menuentry "${_MENUENTRY_NAME} ${kernel}" {
	linux ${GRUB_DRIVE_BOOT}/vmlinuz-${kernel} root=UUID=${ROOT_UUID} $APPEND
	initrd ${GRUB_DRIVE_BOOT}/initrd-${kernel}.img
}	
E_O_F
done
