#ident	"@(#)postinstall	1.2	92/11/04	JPB"

#	Copyright (c) 1990  Intel Corporation
#	All Rights Rreserved
#
#	INTEL CORPORATION PROPRIETARY INFORMATION
#
#	This software is supplied to AT & T under the terms of a license 
#	agreement with Intel Corporation and may not be copied nor 
#	disclosed except in accordance with the terms of that agreement.
#

#ident	"@(#)/usr/src/add-on/pkg.wd/postinstall.sl 1.1 4.0 12/08/90 14079 AT&T-USL"

FAILURE=1	# fatal error

CONFDIR=/etc/conf
CONFBIN=${CONFDIR}/bin
TMP=/tmp/wd.err
ERROR1=" Errors have been written to the file ${TMP}."

BASE1="ERROR: The ${NAME} is not compatible with this release \
of the AT&T UNIX System V operating system \
and can not be used with this system."

NOTOOLS="ERROR: The Installable Driver feature has been removed.\
The ${NAME} cannot be installed."

#this function edits the /etc/strcf to configure the network device
#for this driver

do_strcf() {
if [ -f /etc/inet/strcf ]
then 
	cp /etc/inet/strcf /etc/inet/.strcf.old
	sed "/\# i386\/${1}/s/^#//" < /etc/inet/.strcf.old > /etc/inet/strcf
fi
}

# determine that ID/TP tools are available

if
	[ -x ${CONFBIN}/idbuild -a -x ${CONFBIN}/idinstall ]
then
	:
else
	message ${NOTOOLS}
	exit ${FAILURE}
fi

cd /tmp/wd

OSVER=`uname -a | cut -d " " -f3`

case ${OSVER} in

	4.0*) ;;
	4.1*) ;;
	*) message ${BASE1};
	   exit ${FAILURE};;
esac

#
# Now install if that is to be done
#

${CONFBIN}/idinstall -a wd 2> ${TMP}
if [ "$?" != "0" ]
then
	${CONFBIN}/idinstall -u wd 2> ${TMP}
	if [ "$?" != "0" ]
	then
		message "The installation cannot be completed due to an error \
in the driver installation.  $ERROR1"
		exit ${FAILURE}
	fi
fi

do_strcf  wd8003

#
# now build
#
${CONFBIN}/idbuild 2>> $TMP
if [ $? != 0 ]
then
        message "The installation cannot be completed due to an error in the \
kernel reconfiguration. $ERROR1  Please try the installation again.  If the \
error occurs again, contact your Service Representative." 
	exit $FAILURE
fi

errflag=`expr ${errflag:=0} + 10`

installf -f $PKGINST

#
# Now clean up
#
removef $PKGINST /tmp/wd/* >/dev/null 2>&1
for i in Driver.o Master Space.c System Node
do
	removef $PKGINST /tmp/wd/$i >/dev/null 2>&1
done
removef $PKGINST /tmp/wd >/dev/null 2>&1
removef -f $PKGINST >/dev/null 2>&1
rm -f $TMP 1>/dev/null 2>&1
exit ${errflag} 

