#
#ident "@(#)postinstall 1.4 95/06/20 SMI"
#
# Copyright 1995 Sun Microsystems, Inc. All Rights Reserved
#
#
os_arch=`isainfo -k`

add_driver(){
	driver=$1
	grep "^${driver} " $BASEDIR/etc/name_to_major > /dev/null 2>&1

#	if [ $? != 0 ]; then
#		/bin/echo "adding $driver\c"
#
# Attach a 64-bit driver only on a 64-bit OS. We need to remove and
# add since the adding of SUNWpppk (the 32-bit packages) just does
# a 'add_drv -n' and not a complete add_drv. Note, that SUNWpppk is
# a pre-requisite for SUNWpppkx. The conditional clause in which we
# compare with sparcv9 will have to change for merced.
#
		if  [ $os_arch = "sparcv9" ]; then
			$REM_DRV $driver
			/bin/echo "adding $driver\c"
			$ADD_DRV $driver || exit 1
	                /bin/echo "."

		fi
#	fi
}

if [ "${BASEDIR:=/}" = "/" ]; then
	ADD_DRV="add_drv"
	REM_DRV="rem_drv"
else
	REM_DRV="rem_drv -b ${BASEDIR}"
	ADD_DRV="add_drv -b ${BASEDIR}"
fi

add_driver ipdcm
add_driver ipdptp
add_driver ipd
#
# Because we have bundled ppp we need to be sure that the module will
# not stay on /usr/kernel/strmod/sparcv9
#
BUNDLED_PPP_MODULE="/usr/kernel/strmod/sparcv9/ppp"

if [ -f "$BUNDLED_PPP_MODULE" ]; then
	#
	# Kill aspppd in case of ...
	# to be able to unload ppp
	#
	for P in `/bin/ps -e | /bin/grep '\<aspppd\>' | /bin/awk '{ print $1 }'` ; do
		/bin/kill -TERM $P > /dev/null 2>&1
	done
	#
	rm -f $BUNDLED_PPP_MODULE
	#
	# Unload the module 
	#
	modunload -i `modinfo | grep ppp | awk '{ print $1 }' ` > /dev/null 2>&1
fi

add_driver ppp

exit 0
