自定义RHEL6.0的jboss 启动脚本

#!/bin/bash

#Version:1.0.0 For RHEL6.0

#Write:2013-11-08


#clean up the temporary files!

rm -rf /usr/local/jboss-4.2.2.GA/server/default/tmp/*

rm -rf /usr/local/jboss-4.2.2.GA/server/default/work/*


export JAVA_HOME=/usr/local/jdk1.6.0_32

export JBOSS_HOME=/usr/local/jboss-4.2.2.GA

export LANG=zh.CN.GB18030

backupdate=`date +%Y-%m-%d_%H-%M`


JAVACMD=$JAVA_HOME/bin/java


CLASSPATH=.:$JBOSS_HOME/bin/run.jar

CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar"


JAVA_OPTS="-server -Xms512m -Xmx2048m -Djava.awt.headless=true"


START_OPTS="-b 0.0.0.0"


if [ "$1" = "start" ] ; then

shift


$JAVACMD $JAVA_OPTS -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \

-classpath "$CLASSPATH" \

org.jboss.Main $START_OPTS 1> /dev/null 2>&1 &

echo $! > "/var/run/jboss.pid"


JBOSS_PID=$!


#Trap common signals and relay them to the jboss process

trap "kill -HUP $JBOSS_PID" HUP

trap "kill -TERM $JBOSS_PID" INT

trap "kill -QUIT $JBOSS_PID" QUIT

trap "kill -PIPE $JBOSS_PID" PIPE

trap "kill -TERM $JBOSS_PID" TERM


echo "JBOSS START............[OK]"

elif [ "$1" = "stop" ] ; then

shift

cp $JBOSS_HOME/server/default/log/server.log $JBOSS_HOME/server/default/log/server.log.$backupdate


kill -15 `cat /var/run/jboss.pid`

rm -rf "/var/run/jboss.pid"

sleep 3s

# killall -9 java


echo "JBOSS STOP.............[OK]"


elif [ "$1" = "restart" ] ; then


shift


$0 stop

sleep 1s

$0 start


else

echo "Usage:"

echo "$0 (start|stop|restart)"

echo " start :start jboss in the backgroud"

echo " stop :stop jboss"

echo " restart:restart jboss"

echo "welcome to visit www.kingsoft.com!!!"

exit 0

fi


你可能感兴趣的:(jboss,自定义,启动脚本,RHEL6.0)