#!/bin/sh -e
# Copyright (C) 2010-2012 Eugene Prokopiev  <enp@altlinux.org>
# Copyright (C) 2011-2013      Michael Pozhidaev <msp@altlinux.org>

THIS=${0##*/}

BOOT_DEV="$1"
ROOT_DEV="$2"

[ -z "$BOOT_DEV" ] && echo "$THIS:boot device is not mentioned" >&2 && exit 1
[ -z "$ROOT_DEV" ] && echo "$THIS:root device is not mentioned" >&2 && exit 1

if grep -q "$(basename $BOOT_DEV) : active raid1" /proc/mdstat ; then
    MD_OPTION_LILO="raid-extra-boot=\"mbr-only\""
fi

/bin/cat << EOF
map="/boot/map"
lba32
compact
boot="$BOOT_DEV"
default="linux"
$MD_OPTION_LILO

image="/boot/vmlinuz"
	label="linux"
	initrd="/boot/initrd.img"
	root="$ROOT_DEV"
	read-only
EOF
