#!/bin/sh
#
# $Id: jboss_init_redhat.sh 46554 2006-07-28 10:29:13Z dimitris $
#
# JBoss Control Script
#
# To use this script run it as root - it will switch to the specified user
#
# Here is a little (and extremely primitive) startup/shutdown script
# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
# All this can be changed in the script itself.
#
# Either modify this script for your requirements or just ensure that
# the following variables are set correctly before calling the script.
#换成你本机jboss的安装目录
JBOSS_HOME=${JBOSS_HOME:-"/home/jboss/jboss-4.0.5.GA"}
#换成你新建的jboss用户
JBOSS_USER=${JBOSS_USER:-"jboss"}
#换成本地java路径
JAVAPTH=${JAVAPTH:-"/home/jboss/jdk1.5.0_14/bin"}
#启动的配置参数,有3个值: 'minimal', 'default', 'all',all是集群模式的配置
JBOSS_CONF=${JBOSS_CONF:-"default"}
#这里是绑定所有的网卡,如果绑一个,就写你的IP地址。只在jboss4.2.0+的版本对外使用时才使用。
#JBOSS_HOST=${JBOSS_HOST:-"0.0.0.0"}
#默认的关闭脚本,好像不太好用,我就没用
#JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"}
#jboss4.2.0+版本对外服务绑定Ip的时候的关闭脚本
#JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.sh -S -s $JBOSS_HOST"}
#jboss关闭脚本
JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.sh -S"}
#这是jboss4.2.0+版本对外服务时的启动
#JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF -b $JBOSS_HOST"}
#jboss启动
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF"}
if [ "$JBOSS_USER" = "RUNASIS" ]; then
SUBIT=""
else
SUBIT="su - $JBOSS_USER -c "
fi
if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
# ensure the file exists
touch $JBOSS_CONSOLE
if [ ! -z "$SUBIT" ]; then
chown $JBOSS_USER $JBOSS_CONSOLE
fi
fi
if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
#自启动日志
# echo "WARNING: ignoring it and using /dev/null"
echo "WARNING: ignoring it and using $JBOSS_HOME/jbossAutoStart.log"
#自启动日志
#JBOSS_CONSOLE="/dev/null"
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"$JBOSS_HOME/jbossAutoStart.log"}
fi
#自启动日志
#JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"$JBOSS_HOME/jbossAutoStart.log"}
JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
#这个是默认的,跟上面的一样,不太好用
#JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown -S"}
#我自己用的关闭方式
JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"cd $JBOSS_HOME/bin; $JBOSSCP"}
if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
export PATH=$PATH:$JAVAPTH
fi
if [ ! -d "$JBOSS_HOME" ]; then
echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
exit 1
fi
#这是默认的控制台打印启动脚本命令,很不爽,就关了
#echo JBOSS_CMD_START = $JBOSS_CMD_START
case "$1" in
start)
echo "JBoss start.........."
cd $JBOSS_HOME/bin
if [ -z "$SUBIT" ]; then
eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
else
$SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &"
fi
stop)
echo "JBoss stop........."
if [ -z "$SUBIT" ]; then
$JBOSS_CMD_STOP
else
$SUBIT "$JBOSS_CMD_STOP"
fi
restart)
echo "JBoss restart........"
$0 stop
sleep 60
$0 start
*)
echo "usage: $0 (start|stop|restart|help)"
esac