#! /bin/sh
#
# Copyright (c) 1991, by Sun Microsystems, Inc.
#
#

#
# Give up if /usr not mounted
#
if [ ! -d /usr/bin ]
then			# /usr not mounted
	exit
fi

PATH="/bin:/usr/ucb:/usr/bin:/etc"
export PATH

# echo "debug: BEGINNING OF POSTINSTALL"

#
# Start the daemons
#
if [ $DO_PCNFSD -eq 1 ]
then
	echo ""
	echo "Starting PC-NFS daemon...."
	echo ""
	/usr/lib/nfs/rpc.pcnfsd &
fi

if [ $DO_MSG -eq 1 ]
then
	echo ""
	echo "Starting PC-NFS console messaging server...."
	echo ""
	/usr/lib/nfs/msgserv &
fi


#
# Then do all the yucky slip stuff!
#
if [ $DO_SLIP -eq 1 ]
then
	echo ""
	echo "Adding slip driver...."
	echo ""
	slid=`grep 'type=ddi_pseudo;name=sl' /etc/devlink.tab`
	if [ "$slid" = "" ]
	then
		if [ ! -f /etc/devlink.tab.pre-pcnfs ] ;
		then 
			echo ""
			echo "Saving existing /etc/devlink.tab as /etc/devlink.tab.pre-pcnfs...."
			echo ""
			cp /etc/devlink.tab /etc/devlink.tab.pre-pcnfs
		fi
		echo ""
		echo "Updating /etc/devlink.tab...."
		echo ""
		echo 'type=ddi_pseudo;name=sl	\M0' >> /etc/devlink.tab
	fi
	SAVEDIR=$BASEDIR
	BASEDIR=/	
	export BASEDIR
	/usr/sbin/add_drv sl
	BASEDIR=$SAVEDIR
	export BASEDIR
	if [ -f /etc/gateways ] ;
	then
		if [ ! -f /etc/gateways.pre-pcnfs ];
		then 
			echo ""
			echo "Saving existing /etc/gateways as /etc/gateways.pre-pcnfs...."
			echo ""
			mv /etc/gateways /etc/gateways.pre-pcnfs
		fi
	fi
	echo ""
	echo "Updating /etc/gateways...."
	echo ""
	rm -f /etc/gateways
	num=0
	while [ $num -lt $NDEVICES ]
	do
		val="sl$num"
		echo "norip $val" >> /etc/gateways
		num=`expr $num + 1`
	done
#
#	echo 'norip sl0' >> /etc/gateways
#
	if [ -f /usr/sbin/in.rdisc ] ;
	then 
		if [ ! -f /usr/sbin/in.rdisc.pre-pcnfs ] ;
		then
			echo ""
			echo "Saving existing /usr/sbin/in.rdisc as /usr/sbin/in.rdisc.pre-pcnfs...."
			echo ""
			mv /usr/sbin/in.rdisc /usr/sbin/in.rdisc.pre-pcnfs
		fi
	fi
	chmod ug+s /etc/sunslip
fi

#
# And we're all done!
#
echo ""
echo "Installation complete...."
if [ $DO_SLIP -eq 1 ] ;
then
	echo ""
	echo "NOTE: YOU NEED TO REBOOT YOUR MACHINE BEFORE RUNNING SLIP."
	echo ""
fi
echo ""

# echo "debug: END OF POSTINSTALL"
