:
#!/bin/sh
# 
# $Header: tcpctl.sh,v 6.6 91/04/25 16:27:25 mhill Osd<unix> $ tcpctl.sh
#
# Front-end to tcputl
#
if [ "$USER" = "" ]
then
#ifndef XENIX_386
	USER=$LOGNAME
#else
	USER=`id | awk '{print $1}' | sed -e 's/.*(//; s/)//'`
#endif
fi

if [ "$1" = "port" ]
then
	PORT="port=$2"
	shift 2
else
	PORT=""
fi

case $1 in
	start)		if [ $# -eq 1 ]
			then 
				echo "tcpctl: log file is $ORACLE_HOME/tcp/log/orasrv.log"
	                        echo "tcpctl: SID mapping file is /etc/oratab"
        	                echo "tcpctl: server will be run under $USER"
                	        echo "tcpctl: logging mode is on"
				if orasrv $PORT
				then 
					echo "tcpctl: server has been started"
				fi
			else
				shift 
				if orasrv $* $PORT
				then
					echo "tcpctl: server has been started"
				fi
			fi
			;;
	affinity)	shift
			if [ "$1" = "off" ]
			then
				tcputl F $PORT
			else
				if [ "$1" = "on" ]
				then
					tcputl N $PORT
				fi
			fi
			;;
	stat|status) 	if [ $# -gt 2 ]
			then 
				echo "Usage: tcpctl stat @hostname"
				exit 1
			fi
			shift
                        tcputl S $* $PORT
			;;
	version)	if [ $# -gt 2 ]
			then
				echo "Usage: tcpctl version @hostname"
				exit 1
			fi
			shift
		 	tcputl V $* $PORT
			;;
	stop)		if [ $# -gt 1 ]
			then
				echo "Usage: tcpctl stop"
				exit 1
			fi
                        tcputl Q $PORT
			;;
	log)		if [ $# -gt 1 ]
			then
				echo "Usage: tcpctl log"
				exit 1
			fi
			tcputl L $PORT
			;;
	debug)	 	if [ $# -gt 1 ]
			then
				echo "Usage: tcpctl debug"
				exit 1
			fi
			tcputl D $PORT
			;;
	timeout)	if [ $# -eq 1 ]
			then
				tcputl timeout $PORT
			else
				shift
				tcputl timeout=$1 $PORT
			fi
			;;
	*)		echo 'Usage: tcpctl [port <value>][ start | stat | version | stop | log | debug | timeout ]'
			echo "  start    : start orasrv"
			echo "  stat     : status of orasrv"
			echo "  version  : version number of orasrv"
			echo "  stop     : stop orasrv"
			echo "  log      : toggle logging mode"
			echo "  debug    : toggle debugging mode"
			echo "  timeout  : set or view handshake timeout"
			exit 1
			;;
esac
