# #################################################################################
# Exceed TurboX Connection Node
# © Rocket Software, Inc. or its affiliates. All Rights Reserved.
# ROCKET SOFTWARE, INC. CONFIDENTIAL
# #################################################################################
# otetxcn_functions
# File Version = 1
# #################################################################################

read_yesno()
{
# accepts y, n, yes, no; converts input to lowercase
# by default null input is "no", $1 overrides yndefault (n, y, none, block)
# yes: returns 0 (useful for: if read_yesno ; then )
# no: returns 1; Enter: returns default: 0, 1, or 2

	# set default answer if null response
	yndefault=$1
	if [ -z "${yndefault}" ] ; then
		yndefault=n
	fi
	
	while true ; do
		
		read answer
		#convert to lowercase
		answer=`${ECHO} ${answer}| ${TR} [:upper:] [:lower:]`
		${ECHO}
		
		case "${answer}" in
			y|yes )
				return 0
				;;
			n|no )
				return 1
				;;
			"" )
				case "${yndefault}" in
					y ) return 0 ;;
					n ) return 1 ;;
					none ) return 2 ;;
					block )
						${ECHO} "Invalid input. Please try again: \c"
						;;
				esac
				;;
			* )
				${ECHO} "Invalid input '${answer}'. Please try again: \c"
				;;
		esac
	
	done
}

read_noyes()
{
# no: returns 0 (useful for: if read_noyes ; then )

	read_yesno $*
	resp=$?
	if [ $resp -eq 0 ] ; then
		return 1
	elif [ $resp -eq 1 ] ; then
		return 0
	else
		return $resp
	fi
}

silent_echo()
{
	if [ ! "${bSilent}" = "1" ] ; then
		echo $*
	fi
}

getOptions()
{
	Quiet=1
	
	for param in "$@"
	do
		case ${param} in
			-q)
				Quiet=2 
				bSilent=1
				;;
			-v)
				Quiet=0 
				;;
		esac
	done
	
	if [ ! "${Quiet}" = "0" ] ; then
		QuietArg="-q"
	fi
	
}

test_TR()
{
	echo "aaAA" | ${TR} [:upper:] [:lower:]  > /dev/null 2>&1
	if [ $? -gt 0 ] ; then
		return 1
	else
		return 0
	fi
}

find_good_TR()
{
	TR=`which tr`
	test_TR
	if [ $? -gt 0 ] ; then
		TR=/usr/bin/tr
		test_TR
		if [ $? -gt 0 ] ; then
			TR=/usr/xpg4/bin/tr
			test_TR
			if [ $? -gt 0 ] ; then
				TR=/usr/ucb/tr
				test_TR
				if [ $? -gt 0 ] ; then
					${ECHO} "FATAL ERROR: The tr version on this machine is too old.  It needs to be equivalent to GNU tr."
					cd_and_exit 1
				fi
			fi
		fi
	fi
	export TR
	return
}

test_ECHO()
{
	${ECHO} -e "test\c" | grep "\-e" > /dev/null
	if [ $? -gt 0 ] ; then
		# -e is supported so add it
		ECHO="${ECHO} -e"
	fi
}

find_good_ECHO()
{
	ECHO=`which echo`
	test_ECHO
	export ECHO
}

setGlobalVars()
{
	getOptions ${3} ${4}
	thisETXCNService="`basename ${0}`"
	Installpath="${1}"
	
	thisVersion=
	serverName="Exceed TurboX Connection Node"
	thisServer="${serverName}${thisVersion}"
	homeServer="${thisServer} at ${Installpath}"
	
	thisETXPMControl=${Installpath}/bin/etxpmctl
	thisETXCNnodecmds=${Installpath}/bin/nodecmds
	thisBoottime=${Installpath}/bin/sys/boottime
	
	systemdUnitFile="${Installpath}/installlogs/systemd.unit.name"
	systemdUnit=
	if [ -f "$systemdUnitFile" ]; then
		read systemdUnit <"$systemdUnitFile"
	fi

	ETXCNLOGDIR="${Installpath}/runtime/logs"
	# ETX 12 + to investigate startup issues uncomment this line
	# STARTUPLOG="${ETXCNLOGDIR}/otetxcn-`date +%Y-%m-%d--%H.%M.%S`.log"
	STARTUPLOG=/dev/null
	ETXCNOPTIONS=""
	
	MAX_PILLS=30
	PILLS_USED=0
	
	nspaces="    "
	
	sessionManagerPID=""
	
	LIBPATH="${Installpath}/bin/sys/:${LIBPATH}"
	
	find_good_ECHO
	find_good_TR
	
	getThisPlatform
	
	if [ ! "${thisOS}" = "${osAix}" ] ; then
		export LIBPATH
	fi
}

otetxcnStatus()
{
	if etxcnIsRunning ; then
		${ECHO} "${thisServer} $1."
	else
		${ECHO} "${thisServer} $2."
	fi
}

removeThisLinkOrFile()
{
	if [ -f "${1}" -o -h "${1}" -o ${optionL} "${1}" ] ; then
		rm -f "${1}"
	fi
}

cleanup()
{
	sleep 1
	
	rm -rf ${Installpath}
}

isItSUSELinux()
{
	if [ -d "/etc/init.d" ] ; then
		isSUSE=1
	fi
}

getThisPlatform()
{
	osAix=aix
	osLinux=linux
	osSolaris=solaris
	osHPUX=hpux
	
	archPpc=ppc
	archi586=i586
	archx86_64=x86_64
	archSparc=sparc
	archParisc=parisc
	
	unknown=unknown
	
	thisOS=${unknown}
	thisArch=${unknown}
	
	thisUname=`uname`
	
	fgrepOptions="-c -i"
	optionL="-L"
	
	hasi86=`uname -a | grep ${fgrepOptions} i386`
	
	if [ ${hasi86} = "0" ] ; then
		hasi86=`uname -a | grep ${fgrepOptions} i686`
	fi
	
	isx86_64=`uname -a | grep ${fgrepOptions} x86_64`
	
	if [ ${hasi86} = "0" ] ; then
		if [ ! ${isx86_64} = "0" ] ; then
			thisArch=${archx86_64}    
		fi
	else
		thisArch=${archi586}
	fi
	
	case ${thisUname} in
		AIX )
			thisOS=${osAix}
			thisArch=${archPpc}
			;;
		Linux )
			thisOS=${osLinux}
			isItSUSELinux
			;;
		SunOS )
			thisOS=${osSolaris}
			
			if [ ${hasi86}=0 ] ; then
				thisArch=${archSparc}
				optionL="-h"
			fi
			;;
		HP-UX )
			thisOS=${osHPUX}      
			thisArch=${archParisc}  
			;;
		* )
			;;
	esac
}

removeTheseRcLinks()
{
	theseLinks=`ls ${1} 2>&1`
	
	for eachLink in ${theseLinks} ; do
		removeThisLinkOrFile ${eachLink}
	done
}

systemdInUse()
{
	if [ -d /run/systemd/system ]; then
		return 0
	fi
	if [ -n "$OTETX_USE_SYSTEMD" ]; then
		# Invert
		[ "$OTETX_USE_SYSTEMD" = 1 ]
		return $?
	fi
	return 1
}

removeService()
{
	if systemdInUse; then
		runBoottime --del
		return
	fi

	thisChkConfig="/sbin/chkconfig"
	
	if [ -x "${thisChkConfig}" ] ; then
	${thisChkConfig} --del ${thisETXCNService} > /dev/null 2>&1
	fi
	
	thisUpdateRcD="/usr/sbin/update-rc.d"
	
	if [ -x "${thisUpdateRcD}" ] ; then
	${thisUpdateRcD} -f ${thisETXCNService} remove > /dev/null 2>&1
	${thisUpdateRcD} ${thisETXCNService} remove > /dev/null 2>&1
	fi
	
	if [ "${thisOS}" = "${osSolaris}" ] ; then
		thisSvcAdm="/usr/sbin/svcadm"
		
		removeTheseRcLinks "/etc/rc?.d/*${thisETXCNService}"
		
		if [ -x "${thisSvcAdm}" ] ; then
			${thisSvcAdm} disable -t ${thisETXCNService} > /dev/null 2>&1
		fi
		
		removeThisLinkOrFile "/etc/init.d/${thisETXCNService}"
	fi
	
	if [ "${thisOS}" = "${osHPUX}" ] ; then
		removeTheseRcLinks "/sbin/rc?.d/*${thisETXCNService}"
		removeThisLinkOrFile "/sbin/init.d/${thisETXCNService}"
	fi
	
	if [ "${thisOS}" = "${osAix}" ] ; then
		removeTheseRcLinks "/etc/rc.d/rc?.d/*${thisETXCNService}"
		removeThisLinkOrFile "/etc/rc.d/init.d/${thisETXCNService}"
	fi
	
	if [ "${thisOS}" = "${osLinux}" ] ; then
		removeThisLinkOrFile "/etc/rc.d/init.d/${thisETXCNService}"
		removeThisLinkOrFile "/etc/init.d/${thisETXCNService}"
	fi
}

otetxcnKillSessions()
{
	${thisETXCNnodecmds} sessions stop 
}

countRunningEtxpm_ImplSunOS()
{
	result=0
	runtimefldr=${1}/bin/sys
	pslist=`/usr/ucb/ps  -auxwww|grep "etxpm"|awk '{ print $2 }'`
	for psitem in ${pslist} ; do
		pid=${psitem}
		pathcheck=`/usr/ucb/ps  -auxwww|grep "${runtimefldr}"|grep ${psitem}`
		if [ ! "${pathcheck}x" = "x" ] ; then
			result=`expr ${result} + 1`
		fi
	done
	return ${result}
}

countRunningEtxpm_Impl()
{
	result=0
	runtimefldr=${1}/bin/sys
	pidlist=`ps -A|grep etxpm|awk '{ print $1 }'`
	for psitem in ${pidlist} ; do
		pid=${psitem}
		pathcheck=`ps -p ${pid} -f|grep ${runtimefldr}/etxpm`
		if [ ! "${pathcheck}x" = "x" ] ; then
			result=`expr ${result} + 1`
		fi
	done
	return ${result}
}

checkIfSunOSOldPS()
{
	if [ -x "/usr/ucb/ps" ] ; then
		return 1
	fi
	return 0
}

countRunningEtxpm()
{
	location=$1
	if [ "${thisOS}" = "${osSolaris}" ] ; then
		checkIfSunOSOldPS
		if [ $? -gt 0 ] ; then
			countRunningEtxpm_ImplSunOS  ${location}
		else
			countRunningEtxpm_Impl ${location}
		fi
	elif [ "${thisOS}" = "${osLinux}" ] ; then
		 countRunningEtxpm_Impl ${location}
	elif [ "${thisOS}" = "${osAix}" ] ; then
		 countRunningEtxpm_Impl ${location}
	fi
	retVal=$?
	return ${retVal}
}

etxcnIsRunning()
{
        # etxpm pid 26926 (:mntr -) is running...
	status=`${thisETXPMControl} status| grep running`
	retVal=$?
	return ${retVal}
}

otetxcnStop()
{
	if [ -n "$systemdUnit" -a -z "$ETX_SYSTEMD_LAUNCH" ]; then
		systemctl stop "$systemdUnit"
		return
	fi
	if etxcnIsRunning ; then
		${thisETXCNnodecmds} proxymgr stop
		# etxpm may take some time to flush db state so wait here
		sleep 3
	fi
}

otetxcnGetNodeId()
{
	${thisETXCNnodecmds} getnodeinfo
}

warningCurDir()
{
	${ECHO} "Please do not try to remove ${thisServer}"
	${ECHO} "from ${curDir}."
	${ECHO} "The system cannot remove current directory."
	${ECHO}
	exit 0
}

checkCurrentDir()
{
	curDir=`pwd`
	
	installPathLength=`expr "${Installpath}" : '.*'`
	
	if [ "${thisOS}" = "${osSolaris}" ] ; then
		matchedChars=`expr ${curDir} : ${Installpath}`
		
		if [ "${matchedChars}" = "${installPathLength}" ] ; then
			badCurDir=1
		fi
	else
		curDirParent=`expr substr "${curDir}" 1 "${installPathLength}"`
		
		if [ "${curDirParent}" = "${Installpath}" ] ; then
			badCurDir=1
		fi
	fi
	
	if [ "${badCurDir}" = "1" ] ; then
		warningCurDir
	fi
}

confirmRemoveETXCN()
{
	if [ "${bSilent}" = "1" ] ; then
		return
	fi
	
	if [ "${Quiet}" = "2" ] ; then
		return
	fi
	
	if [ ! "${thisOS}" = "${osLinux}" ] ; then
		checkCurrentDir
	fi
	
	if [ "${homeless}" = "1" ] ; then
		${ECHO} "${thisServer} home directory does not exist at"
		${ECHO} "${Installpath}"
		${ECHO}
		# in case where we are called from boot we should not prompt ever
		if [ "x${1}" = "x" ] ;  then
			${ECHO} "Would you like to finish removal of ${thisServer}?"
			${ECHO} "[y]es or [n]o (<Enter> for no): \c"
		else
			${ECHO} "Please re-install ${thisServer} to restore its home directory."
			exit 1
		fi
	else
		${ECHO} "Are you sure you want to remove completely ${thisServer} at"
		${ECHO} "${Installpath}?"
		${ECHO} "[y]es or [n]o (<Enter> for no): \c"
	fi
	
	if read_noyes ; then
		if [ "${homeless}" = "1" ] ; then
			${ECHO}
			${ECHO} "Please re-install ${thisServer} to restore its home directory."
		fi
		exit 0
	fi
}

otetxcnRemoveStatus()
{
	if [ "${Quiet}" = "2" ] ; then
		return
	fi
	
	${ECHO} "${thisServer} has been removed."
	
	if [ -d "${Installpath}" ] ; then
		${ECHO} "However, ${Installpath} could not be completely removed."
		${ECHO} "The system could not remove current directory."
		${ECHO} "Manual cleanup is required."
	fi
	
	alreadyRemoved=1
	
	${ECHO}
}

isRootRequiredForThisCmd()
{
	rootCmds="remove bootstart nobootstart bootstatus getnodeid getnodeinfo"
	thisCmd="${1}"
	
	wai=whoami
	
	noWhoAmI=`which ${wai} | grep -c "no ${wai}"`
	
	if [ "${noWhoAmI}" = "1" -a  -x /usr/ucb/${wai} ] ; then
		wai=/usr/ucb/${wai}
		noWhoAmI=0
	fi
	
	for rootCmd in ${rootCmds} ; do
		if [ "${thisCmd}" = "${rootCmd}" -a "${noWhoAmI}" = "0" -a ! "`${wai}`" = "root" ] ; then
			${ECHO} "Please login as 'root' to use the command <${1}>."
			exit 1
		fi
	done
}

otetxcnRemove()
{
	if [ "${alreadyRemoved}" = "1" ] ; then
		exit
	fi
	
	if [ "${Quiet}" = "1" ] ; then
		Quiet=0
	fi
	
	if [ ! "${Quiet}" = "2" ] ; then
		${ECHO}
	fi
	
	confirmRemoveETXCN ${1}
	if [ -d "${Installpath}" ] ; then
		if [ -x ${thisETXCNnodecmds} ] ; then
			otetxcnKillSessions
			sleep 4
			otetxcnStop
		else
			${ECHO} "${thisETXCNnodecmds} cannot be run.\nCannot verify existence of running ETX sessions."
		fi
	else
		${ECHO} "${Installpath} is missing."
	fi
	removeService
	cleanup
	otetxcnRemoveStatus
	exit 0
}

otetxcnRestart()
{
	etxcnIsRestarting=1
	otetxcnStop
	otetxcnStart
	etxcnIsRestarting=""
}

doSleeping()
{
	nPills=${1}
	
	PILLS_USED=`expr ${PILLS_USED} + ${nPills}`
	sleep ${nPills}
}

showETXpmProcessesCurrentlyRunning()
{
	${ECHO} >> "${STARTUPLOG}"
	${ECHO} "etxpm processes currently running:" >> "${STARTUPLOG}"
	${ECHO} "----------------------------------" >> "${STARTUPLOG}"
	
	ps -A | grep etxpm >> "${STARTUPLOG}" 2>&1
	
	${ECHO} >> "${STARTUPLOG}"
}

runETXCNControl()
{
	${ECHO} "Starting \"${thisETXCNnodecmds} proxymgr start ${ETXCNOPTIONS}\""  >> "${STARTUPLOG}"
	${ECHO} >> "${STARTUPLOG}"
	
	${thisETXCNnodecmds} proxymgr start ${ETXCNOPTIONS} >> "${STARTUPLOG}" 2>&1
	
	${ECHO} >> "${STARTUPLOG}"
}

otetxcnStart()
{
	if [ -n "$systemdUnit" -a -z "$ETX_SYSTEMD_LAUNCH" ]; then
		systemctl start "$systemdUnit"
		return
	fi
	if etxcnIsRunning ; then
		return
	fi
	
	if [ ! -d "${ETXCNLOGDIR}" ] ; then
		mkdir -p "${ETXCNLOGDIR}"
	fi 
	
	runETXCNControl
	
	return
}

runBoottime()
{
	if [ -x ${thisBoottime} ] ; then
		# ETX-18516 - propagate silent flag
		export bSilent
		${thisBoottime} $*
	else
		if [ ! "${bSilent}" = "1" ] ; then
			${ECHO} "${thisBoottime} not found."
		fi
	fi
}

otetxcnUsage()
{
	thisScriptName=${thisETXCNService}
	
	if [ ! -z "${otetxcnWrapper}" ] ; then
		thisScriptName=${otetxcnWrapper}
	fi
	
	${ECHO}
	${ECHO} "Usage: ${thisScriptName} <command>"
	${ECHO} "  Commands:"
	${ECHO} "${nspaces}start             : start ${serverName}"
	${ECHO} "${nspaces}restart           : restart ${serverName}"
	${ECHO} "${nspaces}stop              : stop ${serverName} only"
	${ECHO} "${nspaces}fullstop          : stop ${serverName} and sessions"
	${ECHO} "${nspaces}killsessions      : stop sessions only"
	${ECHO}
	${ECHO} "${nspaces}status            : get ${serverName} running status"
	${ECHO} "${nspaces}home              : get ${serverName} installation path"
	${ECHO} "${nspaces}getnodeinfo       : report ${serverName} information"
	${ECHO}
	${ECHO} "${nspaces}remove            : remove ${serverName} from the system"
	${ECHO}
	${ECHO} "${nspaces}bootstart enable  : enable Exceed TurboX Connection Node service to start on boot"
	${ECHO} "${nspaces}bootstart disable : disable Exceed TurboX Connection Node service to start on boot"
	${ECHO} "${nspaces}bootstart status  : get Exceed TurboX Connection Node service boot status"
	${ECHO}
	
	exit 1
}

otetxcnHome()
{
	if [ ! "${alreadyRemoved}" = "1" ] ; then
		${ECHO} "${Installpath}"
	fi
}

findHome()
{
	if [ ! -d "${Installpath}" ] ; then
		if [ "${1}" = "start" -o "${1}" = "stop" ] ; then
			${ECHO} "Please re-install ${thisServer} to restore its home directory."
			exit 0
		else
			homeless=1
			otetxcnRemove warning
		fi
	fi
}

scanThisPort()
{
	if (echo > /dev/${TRANS}/${THISHOST}/${thisPort}) > /dev/null 2>&1 ; then
		status="open"
		OPENPORTS="${thisPort} ${OPENPORTS}"
		nOpenPorts=`expr ${nOpenPorts} + 1`
	else
		status="closed"
	fi
}

getSecNow()
{
	XTIMEMIN=`date -u +"%M"`
	XTIMESEC=`date -u +"%S"`
	XTIMERETVAL=`expr ${XTIMEMIN} \* 60 + ${XTIMESEC}`
	return ${XTIMERETVAL}
}

preScan()
{
	THISHOST="`hostname`"
	
	if [ ! -z "${1}" ] ; then
	THISHOST=${1}
	fi
	
	FIRSTPORT=1
	
	if [ ! -z "${2}" ] ; then
	FIRSTPORT=${2}
	fi
	
	LASTPORT=65535
	
	if [ ! -z "${3}" ] ; then
	LASTPORT=${3}
	fi
	
	ALLPORTS=`seq ${FIRSTPORT} ${LASTPORT}`
	TRANS=tcp   # ${4}
	
	nOpenPorts=0
	
	echo 
	date
	getSecNow
	START=$?
	
	echo "Scanning ${TRANS} ports might take up to a few minutes. Please wait..."
}

getThisPortState()
{
	thisOpenPort="${1}"
	thisState="${2}"
	thisHeading="${3}"
	
	nUsers=`ss ${SSOPTIONS} | grep "${thisState}" | grep -c "${thisOpenPort} "`
	
	if [ ${nUsers} -gt 0 ] ; then
		thisHeadingLength=`expr "${thisHeading}" : '.*'`
		
		underLine=""
		
		for i in  {1..${thisHeadingLength}} ; do
			underLine="${underLine}="
		done
		
		echo "${thisHeading}" 
		echo ${underLine}
		ss ${SSOPTIONS} | grep "${thisState}" | grep "${thisOpenPort} " | awk '{print $6}' | sed -e "s|users:||" | sort -t , -k1,1d -k2,2g -k3,3g
		echo
	fi
}

getOpenPortsStates()
{
	# echo "State Recv-Q Send-Q LocalPort PeerPort Users"
	echo
	
	for oPort in ${OPENPORTS} ; do
		echo "******** Port ${oPort}: ********" 
		getThisPortState "${oPort}" "ESTAB" "Owners"  
		getThisPortState "${oPort}" "LISTEN" "Listners"    
	done
}

postScan()
{
	if [ "${verbosePortsStatus}" = "1" ] ; then
		SSOPTIONS="-nap"
		PORTLISTENERS=""
		PORTOWNERS=""
		getOpenPortsStates
	fi
	
	echo "`date`  ${nOpenPorts} open ${TRANS} ports:${OPENPORTS}"
	getSecNow
	END=$?
	SPAN=`expr ${END} - ${START}`
	
	echo "Scanning time: ${SPAN} seconds"
}

portsStatus()
{
	if [ "${1}" = "-v" ] ; then
		verbosePortsStatus=1
		shift
	fi
	
	preScan $@
	
	for thisPort in ${ALLPORTS} ; do
		scanThisPort
	done
	
	postScan
}

portsMon()
{
	OTETXCNPORTSMONLOG="/var/log/otetxcnPortsMon.log"
	SSOPTIONS="-nap"
	
	while true 
	do
		OPENPORTS=""
		portsStatus $@ >> ${OTETXCNPORTSMONLOG} 2>&1
		
		for oPort in ${OPENPORTS} ; do
			echo "Port ${oPort}" >> ${OTETXCNPORTSMONLOG}
			ss ${SSOPTIONS} | grep "${oPort} " >> ${OTETXCNPORTSMONLOG} 2>&1
			echo >> ${OTETXCNPORTSMONLOG}
		done
	done
}

otetxcn()
{
	setGlobalVars $*
	
	if [ ! "${2}" = "lastHome" ] ; then
		findHome "${2}"
	fi
	
	isRootRequiredForThisCmd "${2}"
	
	case "$2" in
		'start')
			if etxcnIsRunning ; then
				${ECHO} "${thisServer} is already running."
			else
				otetxcnStart
				otetxcnStatus "has been started" "failed to start"
			fi
			;;
		'restart')
			otetxcnRestart
			otetxcnStatus "has been restarted" "failed to restart"
			;;
		'stop')
			if etxcnIsRunning ; then
				otetxcnStop
				otetxcnStatus "failed to stop" "has been stopped"
			else
				${ECHO} "${thisServer} is already stopped."
			fi
			;;
		'fullstop')
			otetxcnKillSessions
			if etxcnIsRunning ; then
				otetxcnStop
				otetxcnStatus "failed to stop" "has been stopped"
			else
				${ECHO} "${thisServer} is already stopped."
			fi
			;;
		'killsessions')
			otetxcnKillSessions
			;;
		'status')
			otetxcnStatus "is running" "is stopped"
			;;
		'remove')
			otetxcnRemove
			;;
		'home')
			otetxcnHome
			;;
		'lastHome')
			${ECHO} "${Installpath}"
			;;
		'bootstart')
			# New Style
			if [ "$3" = "enable" ]; then
				runBoottime --add
			elif [ "$3" = "disable" ]; then
				runBoottime --del
			elif [ "$3" = "status" ]; then
				runBoottime --status
			elif [ "$3" != "" ]; then
				echo "Invalid argument: $3"
			else
			# Old style
				runBoottime --add
			fi
			;;
		'nobootstart')
			runBoottime --del
			;;
		'bootstatus')
			runBoottime --status
			;;
		'portsstatus')
			portsStatus ${3} ${4} ${5} ${6}
			;;
		'portsmon')
			# portsMon ${3} ${4} ${5} ${6}
			;;
		'getnodeid' | 'getnodeinfo')
			otetxcnGetNodeId
			;;
		*)
			otetxcnUsage
			;;
	esac
}

