#!/bin/sh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/lpp/bosinst/samples/AE/AS/ConfigITMAgent.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2008,2009 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

# @(#)33        1.1  src/bos/usr/lpp/bosinst/samples/AE/AS/ConfigITMAgent.sh, bosinst, bos720 3/29/09 15:20:10

#
# A utility for configuring and starting the ITM Agent.
#
# usage: sh ConfigITMAgent -tems_hostname "rcn-hny-tpm-01.cloud9.ibm.com"

ITMDIR=/opt/IBM/ITM
AEDIR=/opt/IBM/AE

TEMS_HostName=""

while [ $# -ne 0 ]
do
	case $1 in
		-tems_hostname*)
		TEMS_HostName=$2
		;;
		*)
		;;
	esac
	shift 2
done

if [ "$TEMS_HostName" = "" ]
then

    exit
    
    # HostName=`hostname -s`
    # DomainName=`lsnamsv -S domain`
    # TEMS_HostName="${HostName}.${DomainName}"
fi

cat > $AEDIR/AP/ITMAgentConfig.txt << CONFIG_FILE_END
# Syntax rules:
# - Comment lines begin with "#"
# - Blank lines are ignored
# - Parameter lines are PARAMETER=value (do not put space before the PARAMETER)
# - Space before or after an equal sign is OK
# - Parameter values should NOT contain the following characters \$, =, or |

################## PRIMARY TEMS CONFIGURATION ##################

# Will this agent connect to a Tivoli Enterprise Monitoring Server (TEMS)?
# This parameter is required.
# Valid values are: YES and NO
CMSCONNECT=YES

# What is the hostname of the TEMS to connect to?
# This parameter is NOT required.  (default is the local system hostname)
HOSTNAME=$TEMS_HostName

# Will this agent connect to the TEMS through a firewall?
# This parameter is NOT required.  (default is NO)
# Valid values are: YES and NO
#   - If set to YES the NETWORKPROTOCOL must be ip.pipe
#FIREWALL=NO

# What network protocol is used when connecting to the TEMS?
# This parameter is required.
# Valid values are: ip, sna, ip.pipe, or ip.spipe
NETWORKPROTOCOL=ip.pipe

# What is the first backup network protocol used for connecting to the TEMS?
# This parameter is NOT required. (default is none)
# Valid values are: ip, sna, ip.pipe, ip.spipe, or none
#BK1NETWORKPROTOCOL=none

# What is the second backup network protocol used for connecting to the TEMS?
# This parameter is NOT required. (default is none)
# Valid values are: ip, sna, ip.pipe, ip.spipe or none
#BK2NETWORKPROTOCOL=none

# If ip.pipe is one of the three protocols what is the IP pipe port number?
# This parameter is NOT required. (default is 1918)
#IPPIPEPORTNUMBER=1918

# If ip.pipe is one of the three protocol what is the IP pipe partition name?
# This parameter is NOT required. (default is null)
#KDC_PARTITIONNAME=null

# If ip.pipe is one of the three protocols what is the KDC partition file?
# This parameter is NOT required. (default is null)
#KDC_PARTITIONFILE=null

# If ip.spipe is one of the three protocols what is the IP pipe port number?
# This parameter is NOT required. (default is 3660)
#IPSPIPEPORTNUMBER=3660

# If ip is one of the three protocols what is the IP port number?
# This parameter is NOT required. (default is 1918)
# A port number and or one or more pools of port numbers can be given.
# The format for a pool is #-# with no embedded blanks.
#PORTNUMBER=1918

# If sna is one of the three protocols what is the SNA net name?
# This parameter is NOT required. (default is CANDLE)
#NETNAME=CANDLE

# If sna is one of the three protocols what is the SNA LU name?
# This parameter is NOT required. (default is LUNAME)
#LUNAME=LUNAME

# If sna is one of the three protocols what is the SNA log mode?
# This parameter is NOT required. (default is LOGMODE)
#LOGMODE=LOGMODE

################## SECONDARY TEMS CONFIGURATION ##################

# Would you like to configure a connection for a secondary TEMS?
# This parameter is NOT required. (default is NO)
# Valid values are: YES and NO
FTO=YES

# If configuring a connection for a secondary TEMS, what is the hostname of the secondary TEMS?
# This parameter is required if FTO=YES
#MIRROR=rcc-wat-itm-06.watson.ibm.com

# Will the agent connect to the secondary TEMS through a firewall?
# This parameter is NOT required. (default is NO)
# Valid values are: YES and NO
#FIREWALL2=NO

# What network protocol is used when connecting to the secondary TEMS?
# This parameter is required when FTO=YES and FIREWALL2 is NO
# Valid values are: ip, sna, or ip.pipe
HSNETWORKPROTOCOL=ip.pipe

# What is the first backup network protocol used for connecting to the secondary TEMS?
# This parameter is NOT required. (default is none)
# Valid values are: ip, sna, ip.pipe, or none
#BK1HSNETWORKPROTOCOL=none

# What is the second backup network protocol used for connecting to the secondary TEMS?
# This parameter is NOT required. (default is none)
# Valid values are: ip, sna, ip.pipe, or none
#BK2HSNETWORKPROTOCOL=none

# If ip.pipe is one of the three secondary TEMS protocols what is the IP pipe port number?
# This parameter is NOT required. (default is 1918)
#HSIPPIPEPORTNUMBER=1918

# If ip is one of the three secondary TEMS protocols what is the IP port number?
# This parameter is NOT required. (default is 1918)
# A port number and or one or more pools of port numbers can be given.
# The format for a pool is #-# with no embedded blanks.
#HSPORTNUMBER=1918

# If sna is one of the three secondary TEMS protocols what is the SNA net name?
# This parameter is NOT required. (default is CANDLE)
#HSNETNAME=CANDLE

# If sna is one of the three secondary TEMS protocols what is the SNA LU name?
# This parameter is NOT required. (default is LUNAME)
#HSLUNAME=LUNAME

# If sna is one of the three secondary TEMS protocols what is the SNA log mode?
# This parameter is NOT required. (default is LOGMODE)
#HSLOGMODE=LOGMODE

################## OPTIONAL PRIMARY NETWORK NAME CONFIGURATION ##################

# If the system is equipped with dual network host adapter cards you can designate
# another network name.  What is the network name?
# This parameter is NOT required. (default is none)
#PRIMARYIP=none

CONFIG_FILE_END

echo "Stopping ITM Agent..."
`/opt/IBM/ITM/bin/itmcmd agent -c stop ux`

echo "Configuring ITM Agent with ITM server..."
${ITMDIR}/bin/itmcmd config -A -p $AEDIR/AP/ITMAgentConfig.txt ux
echo "ITM has been configured using $AEDIR/AP/ITMAgentConfig.txt file"

echo "Starting ITM Agent..."
`/opt/IBM/ITM/bin/itmcmd agent -c start ux`

