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

# Check if SMF is present 
INCLUDE_FILE="/lib/svc/share/smf_include.sh"
if [ -f $INCLUDE_FILE ] ; then
	. $INCLUDE_FILE
	svcprop -q -p system/reconfigure system/svc/restarter:default
	if [ $? -eq 0 ]
	then
		_INIT_RECONFIG=set
	fi

	#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
RET=$?
if [ $RET != 0 -a -n "$_INIT_RECONFIG" ]; then
	echo "Note: path_to_inst was not be updated. Please 'boot -r' as needed to update." | tee /dev/msglog 1>&4
	exit 0

elif [  $RET != 0 ]; then
	if [ -f $INCLUDE_FILE ] ; then
		svcadm mark -t maintenance $SMF_FMRI
	fi
	exit 0
fi

if [ -n "$_INIT_RECONFIG" -a -x "$CMD" ]; then
	$CMD -l 2>&1 | tee /dev/msglog 1>&4
fi
