#!/bin/sh

# $Id: qfs_postpatch,v 1.4.8.1 2004/06/10 17:25:37 jp148923 Exp $

#	SAM-QFS_notice_begin
#
#	Solaris 2.x Sun Storage & Archiving Management File System
#
#	Copyright (c) 2004 Sun Microsystems, Inc.
#	All Rights Reserved.
#
#	Government Rights Notice
#	Use, duplication, or disclosure by the U.S. Government is
#	subject to restrictions set forth in the Sun Microsystems,
#	Inc. license agreements and as provided in DFARS 227.7202-1(a)
#	and 227.7202-3(a) (1995), DRAS 252.227-7013(c)(ii) (OCT 1988),
#	FAR 12.212(a)(1995), FAR 52.227-19, or FAR 52.227-14 (ALT III),
#	as applicable.  Sun Microsystems, Inc.
#
#	SAM-QFS_notice_end

echo ""
echo ""

#
# Restart sam manger daemon if necessary
#
/bin/chmod 0750 /opt/SUNWsamfs/sbin/sam-mgmtrpcd
if [ -f /opt/SUNWsamfs/.sam-mgmtrpcd ]; then
	/opt/SUNWsamfs/sbin/sam-mgmtrpcd
	rm /opt/SUNWsamfs/.sam-mgmtrpcd
fi

if [ -f /etc/sysevent/config/SUNW,SUNWsamfs,sysevent.conf ]; then
	echo "Restarting the sysevent daemon" >> $INSLOG 2>&1
	pkill -HUP syseventd >> $INSLOG 2>&1
fi

/bin/catman -w -M /opt/SUNWsamfs/man

/bin/chmod 0750 /usr/lib/fs/samfs/sam-fsd

/bin/grep -w "sam-fsd" /etc/inittab >/dev/null
if [ $? = 0 ]; then
	NUMFSD=`/bin/grep sam-fsd /etc/inittab | grep -cv "#"`
	echo " "
	if [ $NUMFSD -eq 0 ]; then
		sed -e /#*sam-fsd/s/#// < /etc/inittab > /etc/inittab.tmp
		NUMFSD=`/bin/grep sam-fsd /etc/inittab.tmp | grep -cv "#"`
		if [ $NUMFSD -eq 1 ]; then
			echo "INFO: sam-fsd entry detected in /etc/inittab"
			mv /etc/inittab.tmp etc/inittab
			chmod 644 /etc/inittab
			echo "Please ensure run levels are correct; recommended is 023456"
			/bin/grep sam-fsd /etc/inittab
			echo " "
			echo "Restarting the init process to start sam-fsd"
			kill -HUP 1
		elif [ $NUMFSD -ne 0 ]; then
			echo "WARNING multiple sam-fsd would be active if we uncommented"
			echo "the sam-fsd lines; leaving /etc/inittab as is."
			/bin/grep sam-fsd /etc/inittab
			rm /etc/inittab.tmp
		else
			mv /etc/inittab.tmp /etc/inittab
			chmod 644 /etc/inittab
		fi
	else
		echo "INFO: sam-fsd entry detected in /etc/inittab."
		echo "Please ensure run levels are correct; recommended is 023456"
		/bin/grep sam-fsd /etc/inittab
		echo " "
		echo "Restarting the init process to start sam-fsd"
		kill -HUP 1
	fi
fi

exit 0

