#!/bin/sh
# Generate grub config file
# First arg is path to output file, second is path to input file, third is default boot value
# Will add the default line to the top of "grub.lst" which should exsist in this dir

VAL_GRUB_DEFAULT_BOOT="0"

if [ "$#" -lt 2 ]
then
        echo "Usage: ./bootgen.sh outputfile inputfile [defaultOSval]"
	exit 1
fi

OUTPUT_GRUBCONFIG=$1
INPUT_GRUBCONFIG=$2

if [ "$#" -lt 3 ]
then
        echo "No default boot specified, using 0"
	OUTPUT_GRUBCONFIG="testconfig"
	VAL_GRUB_DEFAULT_BOOT="0"
else
	VAL_GRUB_DEFAULT_BOOT=$3
fi


#######
# Start grub config file output
#######

echo "default=$VAL_GRUB_DEFAULT_BOOT
`cat $INPUT_GRUBCONFIG`" > $OUTPUT_GRUBCONFIG

#######
# End grub config file output
#######
