My JBoss Deploy Scripts

CVS structure:

/usr/local/cvsroot/applications/<project>/database

/usr/local/cvsroot/applications/<project>/documentation

/usr/local/cvsroot/applications/<project>/inactive

/usr/local/cvsroot/applications/<project>/jboss

/usr/local/cvsroot/applications/<project>/pgs

Prerequisites:

JDK 1.5.0_11 in /apps/java/ & ln -s /apps/java/jdk1.5.0_11 default

JBoss 4.2.0 GA in /apps/jboss & ln -s /apps/jboss/jboss4.2.0... default

Redhat 4 AS

Anthill 3.2.1

/apps/anthill/anthill3/agent

/apps/java/

/apps/jboss/default/server/<instance>

/apps/jboss/default/server/<instance>/deploy

/apps/jboss/default/server/<instance>/jboss-config

/apps/inet/server/<instance>

/apps/inet/server/conf

/apps/inet/deploy/scripts

/log/<instance>

/data/<instance>

chown on all directories to a consistent userid

Install Anthill agent

  1. untar anthill3-3.2.1.tar.gz into a convenient, temporary directory.
  2. Run the following commands
    1. cd anthill3-install

    2. export JAVA_HOME= /apps/java/default

    3. /bin/bash install-agent.sh

Directory where AnthillPro3 agent should be installed:

/apps/anthill/anthill3/agent

The home directory of the JDK:

/apps/java/default

The external IP address where the agent can be reached:

This is the IP address for the server where you are installing the agent.

The port where the agent can be reached:

Use default of 4568

The IP address on which the Anthill3 Server is listening

The anthill server's IP address

The port on which the Anthill3 Server is listening for Agents

Use default of 4567

Enter the name for this Agent.:

Use the hostname of the server where you are installing the agent

Anthill will cache all the deployment files in ~userid/.codestation/cache. This will quickly use up disk space.

To turn the caching off create a properties file using the following command. The anthill client must be stopped and restarted before this will take effect.

echo codestation.noCache=true > ~/.codestation/codestation.properties

To install base JBoss

  1. untar JBoss into /apps/jboss/jboss-4.2.0
  2. Make a symbolic link to into /apps/jboss/default with ln -s jboss-4.2.0 default

Setup properties file for each instance of JBoss

In /apps/inet/server/<instance>/

Add files named <instance>.properties that contain:

# Set ip and ports here

hostIp="x.x.x.x"

jvmDebugPort="8787"

jmxRemotePort="1999"

Then in /apps/inet/server/<instance>/deploy/ add your database and ldap config files:

oracle-ds.xml

oracleJms-ds.xml

login-config.xml # LDAP

These files will vary depending upon your environment

#runDeployInet2JBoss.sh in cvs under pgs/scripts folder

#!/bin/bash

# hack for anthill3 ??? /bin/chmod +x *.sh */*.sh 2>/dev/null >/dev/null

LINUX_SERVER=$(hostname)

# for now this only handles the "inet" server # this will be expanded to be able to deploy multiple iinet servers per linux server. # if [[ $# = 1 ]] then inet_SERVER="$1" else inet_SERVER="inet" fi

inet_SERVER_DIR="/apps/jboss/default/server/${inet_SERVER}"

JBOSS_HOME="/apps/jboss/default" inet_DIR="/apps/inet"

CONFDIR=${inet_DIR}

STOPCMD="${inet_SERVER_DIR}/bin/stopJBoss" STARTCMD="${inet_SERVER_DIR}/bin/startJBoss" /bin/chmod +x ${STOPCMD} /bin/chmod +x ${STARTCMD}

###################### # get path to deploy scripts ###################### WD=$(/bin/pwd) case "${0}" in /*) cmdDir=$(dirname "$0") ;; *) cmdDir=$(dirname "${WD}/$0") ;; esac

cd $cmdDir deployDir=$(/bin/pwd) cd ${WD}

###################### # find zip and ear ###################### conf=$(/bin/ls *.zip) ear=$(/bin/ls *.ear)

dir=$(pwd) instconf="$dir/$conf" instear="$dir/$ear"

if [[ ! -d ${inet_DIR}/uploads ]] then mkdir ${inet_DIR}/uploads fi conf="${inet_DIR}/uploads/$conf" ear="${inet_DIR}/uploads/$ear"

# copy ear to Upload dir in case manual deploymnet is needed in the future # a cheat, mkdir directory but ignore error if it is already there mkdir ${inet_DIR}/uploads 2>/dev/null cp $instconf $conf cp $instear $ear

###################### # deploy conf zip ######################

echo "Replace config" cd ${CONFDIR} DATE=$(date "+%H%M-%d%m%y") mv conf conf.${DATE} 2>/dev/null /usr/bin/unzip -q ${conf} r=$? if (( $r != 0 )) then echo "Problems unzipping ${config} into ${CONFDIR}" exit -1 fi

############################################### # now make all the required directories under /data/<server>/ ############################################### ${deployDir}/killJboss.sh ${inet_SERVER}

# the liost of files is under the conf directory list=${CONFDIR}/conf/batch/list-of-data-directories

# the data dir is server specific datadir=/data/inet/${SERVER}

# run the script ${deployDir}/mkDataDir.sh $datadir $list r=$? if (( $r != 0 )) then echo "Problems creating data directories" exit -1 fi

# run stopJboss ${deployDir}/isUp.sh $LINUX_SERVER 0 state=$? if(( $state == 0 )) then echo "Stopping JBoss" ${STOPCMD} 2>/dev/null >/dev/null fi

# remove old ear echo "Replace old ear with new" /bin/rm ${inet_SERVER_DIR}/deploy/*.ear 2>/dev/null # cp ear into place cp ${ear} ${inet_SERVER_DIR}/deploy

# start Jboss echo "Start JBoss" nohup ${STARTCMD} >/dev/null 2>/dev/null &

${deployDir}/isUp.sh $LINUX_SERVER 30 state=$? if(( $state == 0 )) then echo "inet up and deployed" exit 0

else echo "Server failed tp startup" exit -1 fi

#installInetServer.sh

#!/bin/bash

#

# This looks for inet server definition files eg inet.properities

# it will install on an inet server for each definition it finds

#

# hack for anthill3 ???

/bin/chmod +x scripts/*.sh 2>/dev/null >/dev/null

inetServerDir="/apps/inet/server"

if [[ ! -d ${inetServerDir} ]]

then

echo "No inet directory: ${inetServerDir}"

exit -1

fi

SERVERS=$(cd ${inetServerDir}; ls */*.properties sed -e "s//.*.properties//")

echo $SERVERS

for server in $SERVERS

do

echo "Deploy server: $server"

echo runDeployJBoss.sh $server

/bin/bash scripts/runDeployJBoss.sh $server

ret=$?

if (( $ret != 0 ))

then

exit $ret

fi

echo runDeployInet2JBoss.sh $server

/bin/bash scripts/runDeployInet2JBoss.sh $server

ret=$?

if (( $ret != 0 ))

then

exit $ret

fi

echo ""

done

#runDeployJBoss.sh

#!/bin/bash

JBOSS_HOME="/apps/jboss/default"

# If called directly this will install the inet server

# if told what server to install it will install the server defined.

#

if [[ $# = 1 ]]

then

INET_SERVER="$1"

else

INET_SERVER="inet"

fi

INET_SERVER_DIR="/apps/jboss/default/server/${INET_SERVER}"

####################################################

#

# LIST of JBoss Config files that are copied from the old version to the new

#

##################################################

# hack for anthill3 ???

/bin/chmod +x *.sh */*.sh 2>/dev/null >/dev/null

LINUX_SERVER=$(hostname)

INET_DIR="/apps/inet"

STOPCMD="${INET_SERVER_DIR}/bin/stopJBoss"

STARTCMD="${INET_SERVER_DIR}/bin/startJBoss"

ISUP="${INET_SERVER_DIR}/bin/isUp.sh"

STARTUP="${INET_SERVER_DIR}/bin/inet"

CHKVERSION="${INET_SERVER_DIR}/bin/checkJBossVersion"

/bin/chmod +x ${STOPCMD}

/bin/chmod +x ${STARTCMD}

/bin/chmod +x ${ISUP}

/bin/chmod +x ${STARTUP}

######################

# get path to deploy scripts

######################

WD=$(/bin/pwd)

case "${0}" in

/*)

cmdDir=$(dirname "$0")

;;

*)

cmdDir=$(dirname "${WD}/$0")

;;

esac

cd $cmdDir

deployDir=$(/bin/pwd)

# get JBOSDIR

cd ${JBOSS_HOME}/..

JBOSSDIR=$(/bin/pwd)

cd ${WD}

######################

# find zip and ear

######################

tarfile=$(/bin/ls jboss*.tgz)

if [[ "a_${tarfile}" = "a" ]]

then

echo "Could not find jboss tar file"

exit -1

fi

# Name of new JBoss

jbossVersion=$(echo $tarfile sed -e "s/.tgz//")

dir=$(pwd)

tarfile="$dir/$tarfile"

######################

# stop server

######################

# run stopJboss

${deployDir}/isUp.sh $LINUX_SERVER 0

state=$?

if(( $state == 0 ))

then

echo "Stopping JBoss"

${STOPCMD} 2>/dev/null >/dev/null

# we need to wait a bit to be sure Jboss is down

sleep 30

# the server can get into a state where it won't die nicely

# this will kill it real good.

${deployDir}/killJboss.sh ${INET_SERVER}

fi

######################

# move old jboss

######################

echo "Installing $tarfile into $INET_SERVER_DIR"

# check if already installed

cd ${INET_SERVER_DIR}/..

if [[ -d ${INET_SERVER} ]]

then

suffix=$(date "+%H%M%S-%d%m%y")

mv ${INET_SERVER} "${INET_SERVER}_${suffix}"

fi

/bin/mkdir ${INET_SERVER_DIR}

cd ${INET_SERVER_DIR}

tar -xzf $tarfile

r=$?

if (( $r != 0 ))

then

echo "Problems untarring $tarfile into $INET_SERVER_DIR"

exit -1

fi

##################################################

# Clean out any oracle or informix setup files

##################################################

/bin/rm ${INET_SERVER_DIR}/deploy/oracle*ds.xml 2>/dev/null

/bin/rm ${INET_SERVER_DIR}/deploy/informix*ds.xml 2>/dev/null

###############################################

# we create a startup script named after the server.

###############################################

mv ${STARTUP} ${INET_SERVER_DIR}/bin/${INET_SERVER}.sh

/bin/chmod +x ${INET_SERVER_DIR}/bin/${INET_SERVER}.sh

# just to be sure CVS can mess things up.

###############################################

# now compare the verions of JBoss to be sure they are the same

###############################################

# just to be sure CVS can mess things up.

/bin/chmod +x ${CHKVERSION}

${CHKVERSION}

r=$?

if (( $r != 0 ))

then

echo "Version mismatch. stopping install"

exit -1

fi

exit 0

checkJBossVersion.sh

#!/bin/bash ###

JBOSS_SERVER_VERSION="4.2.0.GA" JAVA_VERSION="1.5.0_11"

export JAVA_HOME="/apps/java/default" export JBOSS_HOME="/apps/jboss/default" export PATH=${JAVA_HOME}/bin:${PATH} JAVA=${JAVA_HOME}/bin/java

# make the JBOSS_HOME the real path not a slimebolic link. WD=$(/bin/pwd) cd ${JBOSS_HOME} jb=$(/bin/pwd) export JBOSS_HOME="$jb" cd $WD

CP="${JBOSS_HOME}/bin/run.jar" CLASSPATH="$CP" export CLASSPATH

PROGNAME=`basename $0`

# trick to find which server we are running WD=$(/bin/pwd)

case "${0}" in /*) cmdDir=$(dirname "$0") ;; *) cmdDir=$(dirname "${WD}/$0") ;; esac

cd $cmdDir

cd ${JBOSS_HOME}/bin jbVersion=$(${JAVA} -classpath $CP org.jboss.Main --version head -1 awk '{print $2}')

if [ "${jbVersion}" != "${JBOSS_SERVER_VERSION}" ] then echo "JBoss server has wrong version: ${jbVersion} should be: ${JBOSS_SERVER_VERSION}" echo "see $0" exit -255 else echo "JBoss version is correct: ${JBOSS_SERVER_VERSION}" fi

jVersion=$(${JAVA} -version 2>&1 head -1 awk '{print $3}' sed -e "s/"//g") if [ "${jVersion}" != "${JAVA_VERSION}" ] then echo "Java is wrong version: ${jVersion} should be: ${JAVA_VERSION}" echo "see $0" exit -255 else echo "Java version is correct: ${JAVA_VERSION}" fi

exit 0

#startJBoss

#!/bin/sh ### ====================================================================== ### ## ## ## JBoss Bootstrap Script ## ## ## ### ====================================================================== ###

export JAVA_HOME="/apps/java/default" export JBOSS_HOME="/apps/jboss/default" export PATH=${JAVA_HOME}/bin:${PATH} JAVA=${JAVA_HOME}/bin/java

# make the JBOSS_HOME the real path not a slimebolic link. WD=$(/bin/pwd) cd ${JBOSS_HOME} jb=$(/bin/pwd) export JBOSS_HOME="$jb" cd $WD

CP="${JAVA_HOME}/lib/tools.jar" CLASSPATH="$CP" export CLASSPATH

PROGNAME=`basename $0` whoiam=$(/usr/bin/id --user --name) if [[ "$whoiam" != "<userid>" ]] then echo "$PROGNAME: This script must be run as <userid>." exit -1 fi

# trick to find which server we are running WD=$(/bin/pwd)

case "${0}" in /*) cmdDir=$(dirname "$0") ;; *) cmdDir=$(dirname "${WD}/$0") ;; esac

cd $cmdDir wrkDir=$(/bin/pwd) SERVER=$(echo $wrkDir sed -e "s^${JBOSS_HOME}/server/^^" sed -e "s^/.*^^") SERVERDIR="${JBOSS_HOME}/server/${SERVER}" pid=${SERVERDIR}/${SERVER}.pid LOGFILE="${SERVERDIR}/log/${SERVER}.log"

cd ${JBOSS_HOME}/bin

#################################################### # # We setup defaults for the server to run # Then we look for a properties files for this server # The properties file should override any or all of these defaults ####################################### # bind to a specific IP or default to all ips on this server hostIp="0.0.0.0" jvmDebugPort="8787" jmxRemotePort="1999"

############## # The directory where server setup files will be serverSetupDir="/apps/inet/server/${SERVER}" # Directory where database deployment files will be # This directory is read just like server/inet/deploy is serverDeployDir=${serverSetupDir}/deploy # The properties file for properties above setup="${serverSetupDir}/${SERVER}.properties"

if [[ -f ${setup} ]] then echo "Reading server setup from ${setup}" . ${setup} else echo "No setup file found at ${setup}. Using defaults" fi

# We will get jboss errors if the serverDeployDir does not exsist if [[ ! -d ${serverDeployDir} ]] then echo "WARN: server deploy dir ${serverDeployDir} does not exsist. creating ..." mkdir -p ${serverDeployDir} fi

# Use the maximum available, or set MAX_FD != -1 to use that MAX_FD="maximum"

# # Helper to complain. # warn() { echo "${PROGNAME}: $*" }

# # Helper to puke. # die() { warn $* exit 1 }

# Increase the maximum file descriptors if we can ulimit -n 1024

# Setup the classpath runjar="$JBOSS_HOME/bin/run.jar" if [ ! -f "$runjar" ]; then die "Missing required file: $runjar" fi JBOSS_BOOT_CLASSPATH="$runjar"

# Include the JDK javac compiler for JSP pages. The default is for a Sun JDK # compatible distribution which JAVA_HOME points to if [ "x$JAVAC_JAR" = "x" ]; then JAVAC_JAR="$JAVA_HOME/lib/tools.jar" fi

if [ "x$JBOSS_CLASSPATH" = "x" ]; then JBOSS_CLASSPATH="$JBOSS_BOOT_CLASSPATH:$JAVAC_JAR" else JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_BOOT_CLASSPATH:$JAVAC_JAR" fi

INET_CLASSPATH="/apps/inet/conf/spring" CLASSPATH="$_CLASSPATH:$JBOSS_CLASSPATH"

DEBUG_OPTS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=${jvmDebugPort},server=y,suspend=n" JMX_OPTS="-Dcom.sun.management.jmxremote" JMX_OPTS="${JMX_OPTS} -Dcom.sun.management.jmxremote.port=${jmxRemotePort}" JMX_OPTS="${JMX_OPTS} -Dcom.sun.management.jmxremote.authenticate=false" JMX_OPTS="${JMX_OPTS} -Dcom.sun.management.jmxremote.ssl=false"

# don't use JMX or DEBUG on this server #DEBUG_OPTS="" #JMX_OPTS=""

#LOG_OPTS="-Dlog4j.configuration=file:/apps/inet/conf/log4j/log4j.xml" LOG_OPTS="-Dlog4j.debug=true"

# set MaxPermSize to avoid "java.lang.OutOfMemoryError: PermGen" space error # gcInterval time is set to avoid excessive CPU usage for garbage collection # recommendations are between ten minutes (600000) & one hour (3600000) # see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6200091 # JAVA_MEM="-Xms712m -Xmx712m -XX:MaxPermSize=196m -Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000" SERVER_OPTS="-server" JAVA_OPTS="${SERVER_OPTS} ${JAVA_MEM} ${DEBUG_OPTS} ${JMX_OPTS} ${JAVA_OPTS}"

# Setup JBoss sepecific properties JAVA_OPTS="-Dprogram.name=inetDev $JAVA_OPTS"

# Setup the java endorsed dirs JBOSS_ENDORSED_DIRS="$JBOSS_HOME/lib/endorsed"

PTI_ARGS="-Djconfig.filewatcher=false -Dhostname=$HOSTNAME -Dconfig.dir=/apps/inet/conf -Ddata.dir=/data/inet -Dinet.server=${SERVER} -Dlog.dir=/log/ -Dbatchconfig.dir=/apps/inet/conf -Dtest=yes -Dlogfile=${LOGFILE}"

# DIE DIE DIE JBOSS_PID=$(cat $pid) kill $JBOSS_PID 2>/dev/null r=$? if (( $r == 0 )) then /bin/echo -n "shutdown running instance" fi while (( $r == 0 )) do /bin/echo -n "." sleep 3 kill $JBOSS_PID 2>/dev/null r=$? done

echo "rotate server logs" touch ${LOGFILE}1 /bin/mv -f ${LOGFILE}1 ${LOGFILE}2 touch ${LOGFILE}0 /bin/mv -f ${LOGFILE}0 ${LOGFILE}1 touch ${LOGFILE} /bin/mv -f ${LOGFILE} ${LOGFILE}0 touch ${LOGFILE}

/bin/echo

# Display our environment echo "=========================================================================" echo "" echo " JBoss Bootstrap Environment" echo "" echo " SERVER: $SERVER" echo " Host IP: $hostIp" echo " JVM Debug Port: $jvmDebugPort" echo " JMX Remote Port: $jmxRemotePort" echo "" echo " JBOSS_HOME: $JBOSS_HOME" echo "" echo " JAVA: $JAVA" echo "" echo " LOGFILE: $LOGFILE" echo "" echo " JAVA_OPTS: $JAVA_OPTS $LOG_OPTS" echo "" echo " PTI_ARGS: $PTI_ARGS" echo "" echo " CLASSPATH: $CLASSPATH" echo "" echo "=========================================================================" echo ""

# note that "-b0.0.0.0" binds to all ports. # Execute the JVM in the background "$JAVA" $JAVA_OPTS $LOG_OPTS -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" -classpath "$CLASSPATH" ${PTI_ARGS} org.jboss.Main "--host=${hostIp}" "--configuration=${SERVER}" > $LOGFILE 2>&1 & JBOSS_PID=$!

echo $JBOSS_PID > $pid echo "You can follow along at home by running:" echo "tail -f $LOGFILE" #stopJBoss

#!/bin/bash ### ====================================================================== ### ## ## ## JBoss Shutdown Script ## ## ## ### ====================================================================== ###

export JAVA_HOME="/apps/java/default" export JBOSS_HOME="/apps/jboss/default" export PATH=${JAVA_HOME}/bin:${PATH} JAVA=${JAVA_HOME}/bin/java

# make the JBOSS_HOME the real path not a slimebolic link. WD=$(/bin/pwd) cd ${JBOSS_HOME} jb=$(/bin/pwd) export JBOSS_HOME="$jb" cd $WD

CP="${JBOSS_HOME}/bin/shutdown.jar:${JBOSS_HOME}/client/jbossall-client.jar" CLASSPATH="$CP" export CLASSPATH

PROGNAME=`basename $0`

# trick to find which server we are running WD=$(/bin/pwd)

case "${0}" in /*) cmdDir=$(dirname "$0") ;; *) cmdDir=$(dirname "${WD}/$0") ;; esac

cd $cmdDir wrkDir=$(/bin/pwd) SERVER=$(echo $wrkDir sed -e "s^${JBOSS_HOME}/server/^^" sed -e "s^/.*^^")

#################################################### # # We setup defaults for the server to run # Then we look for a properties files for this server # The properties file should override any or all of these defaults ####################################### # bind to a specific IP or default to all ips on this server hostIp=$(/bin/hostname)

############## # The directory where server setup files will be serverSetupDir="/apps/inet/server/${SERVER}" # Directory where database deployment files will be # This directory is read just like server/inet/deploy is serverDeployDir=${serverSetupDir}/deploy # The properties file for properties above setup="${serverSetupDir}/${SERVER}.properties"

if [[ -f ${setup} ]] then echo "Reading server setup from ${setup}" . ${setup} else echo "No setup file found at ${setup}. Using defaults" fi

JBOSS_SERVER=${hostIp}":1099" cd ${JBOSS_HOME}/bin echo "Stopping server: $SERVER on $hostIp" ${JAVA} -classpath $CP org.jboss.Shutdown --server=$JBOSS_SERVER $@

#<instance>.sh

#!/bin/bash # # Control script for starting and stopping inet server on JBoss # # Usage: inet <startstoprestartstatus> # # First task is to determine which server we want to start # Since we can not do this from the arguemenst we assume the # script is located in the bin directory of the server we want to control. #

# # Print a usage message # function usage() { echo "Usage: $0 {startstoprestartstatus}" exit 1 }

# # sets SERVER, SERVERDIR and PROG # This depends on the this script being in the bin directory or the server # function setServer() { PROG=$(/bin/basename $0)

# trick to find which server we are running WD=$(/bin/pwd)

case "${0}" in /*) cmdDir=$(dirname "$0") ;; *) cmdDir=$(dirname "${WD}/$0") ;; esac

SERVERBINDIR=${cmdDir} cd $cmdDir/.. # this should be the server dir SERVERDIR=$(/bin/pwd) SERVER=$(/bin/basename ${SERVERDIR}) cd ${WD} }

# # reverses isUp into a wait for servr to be down function isDown(){

serverHostname=$1 retries=$2 TIMEOUT=10 n=0 while (( $n < $retries )) do sleep $TIMEOUT n=$(( $n + 1 )) $SERVERBINDIR/isUp.sh $serverHostname 0 state=$? if (( $state != 0 )) then return 0 fi done return -1

}

if [[ $# != 1 ]] then usage fi

setServer hn=$(/bin/hostname)

case "$1" in start) echo "$PROG: Starting $SERVER: " $SERVERBINDIR/isUp.sh $hn 0 ret=$? if [[ $ret != 0 ]] then $SERVERBINDIR/startJBoss $SERVERBINDIR/isUp.sh $hn 12 ret=$? exit $ret else echo "$PROG: Server is up. First stop the server" exit -1 fi ;; stop) echo "$PROG: Shutting down $SERVER: " $SERVERBINDIR/isUp.sh $hn 0 ret=$? if [[ $ret = 0 ]] then $SERVERBINDIR/stopJBoss fi isDown $hn 12 ret=$? if [[ $ret = 0 ]] then echo "$PROG: server $SERVER is down" exit 0 else echo "$PROG: server $SERVER is up" exit 1 fi ;; restart) $0 stop $0 start ;; status) $SERVERBINDIR/isUp.sh $hn 0 ret=$? if [[ $ret = 0 ]] then echo "$PROG: server $SERVER is up" exit $ret else echo "$PROG: server $SERVER is down" exit $ret fi ;; *) usage ;; esac

exit 0

#isUp.sh

#!/bin/sh ### ====================================================================== ### ## ## ## JBoss IsUp Script ## ## ## ### ====================================================================== ###

jmxPort="1099"

export JAVA_HOME="/apps/java/default" export PATH=${JAVA_HOME}/bin:${PATH} export JBOSS_HOME="/apps/jboss/default" JAVA="${JAVA_HOME}/bin/java"

DIRNAME=`dirname $0` PROGNAME=`basename $0`

#SERVER=$(/bin/hostname)

SERVER_NAME="$1" RETRIES="$2" TIMEOUT="10"

# # Helper to complain. # die() { echo "${PROGNAME}: $*" exit 1 }

# Setup the classpath # we put a jndi.properties into the same dir as the command and add # DIRNAME to the classpath JBOSS_CLASSPATH="${DIRNAME}:$JBOSS_HOME/bin/twiddle.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/jbossall-client.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/getopt.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/log4j.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/lib/jboss-jmx.jar"

# Setup the java endorsed dirs JBOSS_ENDORSED_DIRS="$JBOSS_HOME/lib/endorsed"

getState(){ # Execute the JVM response=$($JAVA $JAVA_OPTS -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" -Dprogram.name="$PROGNAME" -classpath $JBOSS_CLASSPATH org.jboss.console.twiddle.Twiddle --server=${SERVER_NAME}:${jmxPort} serverinfo -d 2>/dev/null ) ret=$? if (( $ret == 0 )) then state=1 else state=0 fi }

getState if (( $state > 0 )) then echo "inet server $SERVER_NAME is Up." exit 0 fi

n=0 while (( $n < $RETRIES )) do sleep $TIMEOUT n=$(( $n + 1 )) getState if (( $state > 0 )) then echo "inet server $SERVER_NAME is Up." exit 0 fi done

exit -1

No comments: