#!/bin/ksh

#pragma ident   "@(#)postinstall 1.25     02/09/05 SMI"

# Post-installation script for DOLPHIN,sci
# SMCC Cluster Server Engineering

_basedir=`pkgparam ${PKGINST} BASEDIR`
_productdir=`pkgparam ${PKGINST} PRODUCTDIR`
_rsmlibdir=/usr/platform/`uname -i`/lib/rsmlib

SAVEBASE=$BASEDIR
BASEDIR=""; export BASEDIR

PATH=/usr/bin:/usr/sbin
export PATH

# This function installs the PCI driver
install_pci_driver() {

	echo "  ... SUNWsci: PCI SCI cards found. Configuring into system..."
	cd ${PKG_INSTALL_ROOT}/kernel/drv

	sync
	pci_aliases='"pci11c8,d665" "pci11c8,0" "pci0,11c8"'
	if [ "${PKG_INSTALL_ROOT}" != "" ] ; then
		add_drv -b ${PKG_INSTALL_ROOT} -m '* 0666 root sys' -i "${pci_aliases}" sci
	else
		add_drv -m '* 0666 root sys' -i "${pci_aliases}" sci
	fi

	#	We don't program SCI cards here any more, if it has a valid
	#	node ID, that will be retained, if not user should program
	#	node ID before use.
} #install_pci_driver()


if prtconf 2>/dev/null | grep 'DOLPHIN,sci' >/dev/null 2>&1;
then
	echo " ***"
	echo " *** WARNING ! "
	echo " *** SUNWsci does not support Sbus SCI cards! "
	echo " *** Only PCI SCI cards are supported in this release."
	echo " ***"
elif prtconf 2>/dev/null | egrep 'pci11c8,|pci0,11c8' >/dev/null 2>&1
then
	install_pci_driver
else
	# Just get a major number assigned.
	add_drv sci 2>/dev/null;
fi

# create rsmlib and rsmlib/sparcv9 directory if it does not exist
if [ ! -d ${PKG_INSTALL_ROOT}/${_rsmlibdir}/sparcv9 ]; then
	mkdir -p ${PKG_INSTALL_ROOT}/${_rsmlibdir}/sparcv9
fi

# create a symbolic link to point to the sci rsm-plugin library
ln -s ${PKG_INSTALL_ROOT}/${_basedir}/opt/${_productdir}/lib/librsmsci.so ${PKG_INSTALL_ROOT}/${_rsmlibdir}/sci.so
ln -s ${PKG_INSTALL_ROOT}/${_basedir}/opt/${_productdir}/lib/sparcv9/librsmsci.so ${PKG_INSTALL_ROOT}/${_rsmlibdir}/sparcv9/sci.so
	
# the following 'touch /reconfigure' is to cause the next reboot
#  to perform a reconfiguration
touch ${PKG_INSTALL_ROOT}/reconfigure
sync

echo
echo "  ... SUNWsci: postinstall complete"
echo

BASEDIR=$SAVEBASE; export BASEDIR
