#!/bin/bash

[ -b "$1" ] || { echo "Invalid boot device specified" ; exit 0; }
[ -b "$2" ] || { echo "Invalid root device specified for image1" ; exit 0; }
[ -b "$3" ] || { echo "Invalid root device specified for image2" ; exit 0; }

boot=$1
root1=$2
root2=$3

[ -f /etc/lilo.conf.rh ] || cp /etc/lilo.conf /etc/lilo.conf.rh
echo boot=$boot                                             >  /etc/lilo.conf.1
echo map=/space1/boot/map                                   >> /etc/lilo.conf.1
echo install=/space1/boot/boot.b                            >> /etc/lilo.conf.1
echo prompt                                                 >> /etc/lilo.conf.1
echo timeout=30                                             >> /etc/lilo.conf.1
echo lba32                                                  >> /etc/lilo.conf.1
echo "append=\"console=ttyS0\""                             >> /etc/lilo.conf.1
echo "read-only"                                            >> /etc/lilo.conf.1
echo default=image1                                         >> /etc/lilo.conf.1
echo                                                        >> /etc/lilo.conf.1
echo image=/boot/vmlinuz                                    >> /etc/lilo.conf.1
echo -e "\tlabel=image1"                                    >> /etc/lilo.conf.1
echo -e "\troot=$root1"                                     >> /etc/lilo.conf.1
echo                                                        >> /etc/lilo.conf.1
echo image=/altroot/boot/vmlinuz                            >> /etc/lilo.conf.1
echo -e "\tlabel=image2"                                    >> /etc/lilo.conf.1
echo -e "\troot=$root2"                                     >> /etc/lilo.conf.1

echo boot=$boot                                             >  /etc/lilo.conf.2
echo map=/space1/boot/map                                   >> /etc/lilo.conf.2
echo install=/space1/boot/boot.b                            >> /etc/lilo.conf.2
echo prompt                                                 >> /etc/lilo.conf.2
echo timeout=50                                             >> /etc/lilo.conf.2
echo lba32                                                  >> /etc/lilo.conf.2
echo "append=\"console=ttyS0\""                             >> /etc/lilo.conf.2
echo "read-only"                                            >> /etc/lilo.conf.2
echo default=image2                                         >> /etc/lilo.conf.2
echo                                                        >> /etc/lilo.conf.2
echo image=/boot/vmlinuz                                    >> /etc/lilo.conf.2
echo -e "\tlabel=image2"                                    >> /etc/lilo.conf.2
echo -e "\troot=$root2"                                     >> /etc/lilo.conf.2
echo                                                        >> /etc/lilo.conf.2
echo image=/altroot/boot/vmlinuz                            >> /etc/lilo.conf.2
echo -e "\tlabel=image1"                                    >> /etc/lilo.conf.2
echo -e "\troot=$root1"                                     >> /etc/lilo.conf.2

