:
#      @(#)sco_nb	5.1.1.5 Lachman System V STREAMS TCP  source
#      SCCS IDENTIFICATION
#
#	System V STREAMS TCP - Release 4.0
#
#	Copyright 1987, 1988, 1989 Lachman Associates, Incorporated (LAI)
#
#	All Rights Reserved.
#
#	The copyright above and this notice must be preserved in all
#	copies of this source code.  The copyright above does not
#	evidence any actual or intended publication of this source
#	code.
#
#	This is unpublished proprietary trade secret source code of
#	Lachman Associates.  This source code may not be copied,
#	disclosed, distributed, demonstrated or licensed except as
#	expressly authorized by Lachman Associates.
#
#	System V STREAMS TCP was jointly developed by Lachman
#	Associates and Convergent Technologies.
#
#
: ${OK=0} ${FAIL=1} ${RELINK=2}
PATH=/bin:/usr/bin:/etc:/etc/conf/bin

LOWER_PRD=$1
LOWER_IF=$2
UPPER_PRD=$3
UPPER_IF=$4
CONFIGURE=$5

tmp=/tmp/sco_nb$$
LKPERM=/etc/perms/inst			# OS (link kit) permlist

# Function declarations

##############################################################################
#
# Test to see if link kit is installed
#
chklinkkit() {
	cd /
	fixperm -i -d LINK $LKPERM 2> /dev/null
	case $? in
	0)	return 0
		;;
	3|4)	echo "The Link Kit is not installed." >&2
		cleanup $FAIL
		;;
	5)	echo "The Link Kit is only partially installed." >&2
		echo "Attempting to remove TPI NetBIOS package anyway." >&2
		return 0
		;;
	*)	echo "Error testing for Link Kit. Exiting."
		cleanup $FAIL
		;;
	esac
}

##############################################################################
#
# Remove temp files and exit with the status passed as argument
#
cleanup() {
	cd $cwd
	trap '' 1 2 3 15
	[ "$tmp" ] && rm -f $tmp*
	exit $1
}

##############################################################################
#
# main()
#
trap "cleanup $FAIL" 1 2 3 15

if [ "$CONFIGURE" = "N" ] ; then
	cleanup $OK
fi

# Check to see that link kit is installed
chklinkkit

# stop netbios
if [ -x /etc/netbios ]
then 
	echo "Stopping TPI NetBIOS ... \c"
	/etc/netbios stop >/dev/null 2>&1
	echo "done."
fi
# Remove links to NetBIOS start/stop scripts
rm -f /etc/rc2.d/S86netbios /etc/rc0.d/K72netbios

# Remove the entries made to the /etc/default/nbconf file by the init script.

if [ -f /etc/default/nbconf ]
then
	sed '/NB_HOST/,$d' /etc/default/nbconf > /tmp/nbconf$$ 
	mv /tmp/nbconf$$ /etc/default/nbconf
fi

echo "Removing TPI NetBIOS drivers ... \c"
idinstall -d -e nb >/dev/null 2>&1
/etc/conf/bin/idinstall -d -e nbcots >/dev/null 2>&1
/etc/conf/bin/idinstall -d -e nbclts >/dev/null 2>&1
rm -f /dev/nb
rm -f /dev/nb-dg
rm -f /dev/nbclts
rm -f /dev/nbcots
rm -f /dev/netbios
rm -f /dev/netbios0

echo "done."

cleanup $RELINK	# Ensure kernel is relinked be netconfig
