#!/bin/sh
#
#  Copyright(c) 1998 Sun Microsystems, Inc.
#  All rights reserved.

#ident  "@(#)cst 1.9 01/05/16  SMI"

#
#  Start/Stop Configuration and Service Tracker daemons
#

killproc() {		# kill the named process(es)
	pid=`/usr/bin/ps -e |
	     /usr/bin/grep -w $1 |
	     /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
	[ "$pid" != "" ] && kill -TERM $pid
}

case "$1" in
'start')
	`/usr/bin/pkginfo -r SUNWcst`/SUNWcst/bin/cstd -b
	# The cstsspd daemon is now started by cstd.
	exit 0
	;;
'stop')
	killproc cstsspd
	killproc cstl
	killproc newprobe
	`/usr/bin/pkginfo -r SUNWcst`/SUNWcst/bin/app_event "CST stopped" "CST tracking stopped on user request.
System events will not be tracked until CST is started again." > /dev/null
	killproc cstd
	killproc csthb
	echo " "
	echo "Warning: CST is now stopped."
	echo "For reliable tracking and statistics, it is recommended that CST"
	echo "is running at all time."
	echo " "
	exit 0
	;;
*)
	echo "Usage: /etc/init.d/cst { start | stop }"
	exit 1
	;;
esac
