#!/bin/ksh

BASEDIR=${BASEDIR:=/usr}
PATH="/usr/bin:/usr/sbin:${PATH}"

DRVMOD="rdc"
DRVDIR=$BASEDIR/kernel/drv
DRVDIR64=$DRVDIR/sparcv9

MISCMOD="rdcsrv"
MISCDIR=$BASEDIR/kernel/misc
MISCDIR64=$BASEDIR/kernel/misc/sparcv9

LIBMOD="sndrsyncd"
LIBDIR=$BASEDIR/opt/SUNWrdc/lib

PKGINST="SUNWrdcu"
OS_VER=`eval uname -r`

#
# Solaris 8 sndr modules work with Solaris 9
#
if [ "$OS_VER" = "5.9" ]
then
        OS_VER=5.8
fi

#
# install modules
#
mv ${DRVDIR}/${DRVMOD}-${OS_VER} ${DRVDIR}/${DRVMOD}
mv ${MISCDIR}/${MISCMOD}-${OS_VER} ${MISCDIR}/${MISCMOD}
mv ${LIBDIR}/${LIBMOD}-${OS_VER} ${LIBDIR}/${LIBMOD}

if [ "$OS_VER" != "5.6" ]
then
	mv ${DRVDIR64}/${DRVMOD}-${OS_VER} ${DRVDIR64}/${DRVMOD} >/dev/null 2>&1
	mv ${MISCDIR64}/${MISCMOD}-${OS_VER} ${MISCDIR64}/${MISCMOD} >/dev/null 2>&1
fi

#
# update package database
#
removef ${PKGINST} ${DRVDIR}/${DRVMOD}-${OS_VER} >/dev/null 2>&1
removef ${PKGINST} ${MISCDIR}/${MISCMOD}-${OS_VER} >/dev/null 2>&1
if [ "$OS_VER" != "5.6" ]
then
	removef ${PKGINST} ${DRVDIR64}/${DRVMOD}-${OS_VER} >/dev/null 2>&1
	removef ${PKGINST} ${MISCDIR64}/${MISCMOD}-${OS_VER} >/dev/null 2>&1
fi
removef -f ${PKGINST} >/dev/null 2>&1

installf ${PKGINST} ${DRVDIR}/${DRVMOD}
installf ${PKGINST} ${MISCDIR}/${MISCMOD}
if [ "$OS_VER" != "5.6" ]
then
	installf ${PKGINST} ${DRVDIR64}/${DRVMOD} 
	installf ${PKGINST} ${MISCDIR64}/${MISCMOD} 
fi
installf -f ${PKGINST}
