#!/sbin/sh
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)gdevsync	1.10	05/03/28 SMI"

# Check if SMF is present
INCLUDE_FILE="/lib/svc/share/smf_include.sh"
if [ -f $INCLUDE_FILE ]
then
	. $INCLUDE_FILE

	#Save a copy of file descriptors to the
	#Greenline logs
	exec 4>&1 5>&2
else
	exec 4>/dev/null 5>&4
fi

#Set up stdout and stderr to write to the console
exec 1>/dev/msglog 2>&1

CMD="/usr/cluster/bin/scgdevs"

# test whether we are a cluster and exit if not a cluster
/usr/sbin/clinfo > /dev/null 2>&1
if [ $? != 0 ] ; then
	if [ -f $INCLUDE_FILE ] ; then
		svcadm mark -t maintenance $SMF_FMRI
	fi
        exit 0
fi

if [ -x "$CMD" ]; then
	# Confirm if global namespace is up to date.
	$CMD -v 2>&1

	# If it is not up to date, reconfig.
	if [ $? -ne 0 ]; then
		$CMD -g 2>&1 | tee /dev/msglog 1>&4
	fi
fi
