#/bin/sh


DetermineFilePath() {
	RC_DIR=/etc/rc.d
	if [ -d /etc/rc.d/init.d ]; then
		RC_DIR=/etc/rc.d/init.d
	fi
}

RunLevel() {
	if [ -f $RC_DIR/$1 ]; then
		if [ "$3" != "" ]; then
			$RC_DIR/$1 $2 > $3 2> $3 
		else 
			$RC_DIR/$1 $2
		fi
	fi
}

DetermineFilePath

if [ "$1" = "start" ]; then
	echo "Starting all hp ProLiant Agents..."
	RunLevel cmafdtn $1 /dev/null
	RunLevel cmasvr $1 /dev/null
	RunLevel cmastor $1 /dev/null
	RunLevel cmanic $1 /dev/null
else
	echo "Stopping all hp ProLiant Agents..."
	RunLevel cmanic $1 /dev/null
	RunLevel cmastor $1 /dev/null
	RunLevel cmasvr $1  /dev/null
	RunLevel cmafdtn $1  /dev/null
fi

if [ "$2" != "" ]; then
	RunLevel $2 $1 
fi	
