#
# If the patch update script exists, then run it.
#
PATH=/usr/bin:/bin:/usr/sbin
mount wilbur:/usr/export/vol/patches /mnt
case $1 in
'start')
	PATCH_DIR=/mnt/`uname -s``uname -r`
	NOLOGIN=/etc/nologin
	umask 022

	# choose one of the following
	PATCH_OPTS=	# servers: old versions saved
	# PATCH_OPTS=-d	# clients: nothing saved
	
	if [ -f $NOLOGIN ]; then
		rm $NOLOGIN
	fi
	
	if [ ! -d $PATCH_DIR ]; then
		echo "No patch directory found: $PATCH_DIR"
		exit 0
	fi
	
	REBOOT_FLAG=0
	echo "OS patches being installed" > $NOLOGIN
	cd $PATCH_DIR
	for i in 1*
	{
		if [ -d /var/sadm/patch/$i ]; then
			echo "Patch $i already installed."
		else
			echo "Installing patch $i..."
			$PATCH_DIR/$i/installpatch -u $PATCH_OPTS $PATCH_DIR/$i
			if [ $? = 0 ]; then
				REBOOT_FLAG=1
			fi
		fi
	}
	rm $NOLOGIN
	if [ $REBOOT_FLAG = 1 ]; then
		echo "Patches installed... rebooting" >> /var/adm/messages
		init 6
	fi
	;;
'stop')
	;;
*)
	echo "usage: /etc/rc2.d/S99patches {start|stop}"
	;;
esac