#!/bin/sh
DRIVER=hpt37x2
INSTALL_GRUB=false
INSTALL_LILO=false
LILOCONF=false
OSRELEASE=7.3
KERNELVER=2.4.18-3
ls -l /boot/*smp 1>/dev/null 2>/dev/null
if [ $? = '0' ];then 
SMP=smp
else
SMP=
fi
echo "Post Install for ${DRIVER} on RedHat Linux ${OSRELEASE}"
UNAME=`uname -r`
if [ ${UNAME} != '2.4.18-3BOOT' ];then
    echo
    echo "Error: not RedHat 7.3 installation environment"
    exit 1
fi
if [ -f /etc/lilo.conf ]; then
    INSTALL_LILO=true
    LILOCONF=lilo.conf
else
    INSTALL_GRUB=true
    if [ -f /etc/lilo.conf.anaconda ];then
	LILOCONF=lilo.conf.anaconda
    else
	LILOCONF=lilo.conf
    fi
fi
if [ $INSTALL_GRUB = 'true' ];then
    grep -q ${DRIVER} /boot/grub/menu.lst
    if [ $? = '0' ]; then
	echo
	echo "Error: ${DRIVER} has been found in /boot/grub/menu.lst."
	echo "Nothing changed."
	exit 1
    fi
fi
if [ -f /etc/${LILOCONF} ];then
	grep -q ${DRIVER} /etc/${LILOCONF}
	if [ $? = '0' ]; then
		echo
		echo "Error: ${DRIVER} has been found in /etc/${LILOCONF}."
		echo "Nothing changed."
		exit 1 
	fi
fi
echo "Configuring system "
if [ ! -f /boot/vmlinuz-${KERNELVER} ]; then
	echo "/boot/vmlinuz-${KERNELVER} not found."
	echo "default kernel not found, postinstall aborted."
	exit 1
fi
if [ ! -f /boot/vmlinuz.${DRIVER} ]; then
	echo "/boot/vmlinuz.${DRIVER} not found."
	echo "copy kernel first, then rerun postinstall."
	exit 1
fi
mv /boot/vmlinuz-${KERNELVER} /boot/vmlinuz-${KERNELVER}.old
ln -s /boot/vmlinuz.${DRIVER} /boot/vmlinuz-${KERNELVER}
if [ ${SMP} = 'smp' ];then
if [ ! -f /boot/vmlinuz-${KERNELVER}smp ]; then
	echo "/boot/vmlinuz-${KERNELVER}smp not found."
	echo "default kernel not found, postinstall aborted."
	exit 1
fi
if [ ! -f /boot/vmlinuz.${DRIVER}smp ]; then
	echo "/boot/vmlinuz.${DRIVER}smp not found."
	echo "copy kernel first, then rerun postinstall."
	exit 1
fi
mv /boot/vmlinuz-${KERNELVER}smp /boot/vmlinuz-${KERNELVER}smp.old
ln -s /boot/vmlinuz.${DRIVER}smp /boot/vmlinuz-${KERNELVER}smp
fi
if [ $INSTALL_LILO = 'true' ];then
    /sbin/lilo
fi
echo "End of ${DRIVER} Post Install"
echo "type \"umount /mnt/floppy\" then remove the driver disc from floppy"
