#
#ident "%Z%%M% %I% %E% 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"
#
# Don't try to attach a 32-bit driver in a 64-bit OS.
# The conditional clause will have to change for 64-bit OS running on
# merced.
#
		if  [ $os_arch = "sparcv9" ]; then
			$ADD_DRV -n $driver || exit 1
		else
			$ADD_DRV $driver || exit 1
		fi
		/bin/echo "."
	fi
}

if [ "${BASEDIR:=/}" = "/" ]; then
	ADD_DRV="add_drv"
else
	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
#
BUNDLED_PPP_MODULE="/usr/kernel/strmod/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
