#!/bin/sh

#############################################################################
# Copyright (C)2004-2005, Sun Microsystems Inc. All rights reserved.
# Use is subject to license terms.
#
# Name: cc-transport
# Description: CNS framework control script for the "transport".
#
# pragma ident	"$Id: cc-transport,v 1.1.2.4 2005/04/28 21:26:28 rc5273 Exp $"
##############################################################################

##############################################################################
#  Function: 
#  1. Starts the transport executable if the param received is 'start'
#  2. Stops the transport executable if the param received is 'stop'
###############################################################################

pid_file=/var/run/cctpx.pid
watchdog=`/usr/lib/cc-cfw/framework/lib/get_interface WATCHDOG`
prog=/usr/lib/cc-cfw/platform/transport/bin/cctrunner 

case "$1" in
'start')
	echo "Starting cctransport"

	# make sure the watchdog program is there
	if [ ! -x $watchdog ] ; then
		echo "Not executable $watchdog"
		exit 1
	fi

	# start the proxy as a daemon process
	$watchdog $prog 1 $pid_file &
	;;

'stop')
	echo "Stopping cctransport"
    
	# stop the proxy by killing its watchdog process
	if [ -f  $pid_file ] ; then
		kill -TERM `cat $pid_file` > /dev/null 2>&1
		sleep 10
		rm -f $pid_file
	fi
	;;

 *)
    echo "Usage : `basename $0` { start | stop }"
    ;;
esac

exit 0
