4 # Required-Start: $local_fs $remote_fs $network $syslog
5 # Required-Stop: $local_fs $remote_fs $network $syslog
6 # Default-Start: 2 3 4 5
8 # Short-Description: Start/stop JBoss application server
11 #define where jboss is - this is the directory containing directories log, bin, conf etc
12 JBOSS_HOME=${JBOSS_HOME:-"/opt/jboss"}
14 #define the user under which jboss will run, or use 'RUNASIS' to run as the current user
15 JBOSS_USER=${JBOSS_USER:-"www-data"}
17 #make sure java is in your path
18 JAVAPTH=${JAVAPTH:-"/usr/local/jdk/bin"}
20 #configuration to use, usually one of 'minimal', 'default', 'all'
21 JBOSS_CONF=${JBOSS_CONF:-"default"}
25 #if JBOSS_HOST specified, use -b to bind jboss services to that address
26 JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}
28 #define the classpath for the shutdown class
29 JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"}
31 #define the script to use to start jboss
32 JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"}
34 JBOSS_CONSOLE="$JBOSS_HOME/server/$JBOSS_CONF/log/jboss.log"
36 if [ "$JBOSS_USER" = "RUNASIS" ]; then
39 SUBIT="su - $JBOSS_USER -c "
42 if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
43 # ensure the file exists
45 if [ ! -z "$SUBIT" ]; then
46 chown $JBOSS_USER $JBOSS_CONSOLE
50 if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
51 echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
52 echo "WARNING: ignoring it and using /dev/null"
53 JBOSS_CONSOLE="/dev/null"
56 #define what will be done with the console log
57 JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
59 JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
60 JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown"}
62 if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
63 export PATH=$PATH:$JAVAPTH
66 if [ ! -d "$JBOSS_HOME" ]; then
67 echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
71 #echo JBOSS_CMD_START = $JBOSS_CMD_START
76 if [ -z "$SUBIT" ]; then
77 eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
79 $SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &"
83 if [ -z "$SUBIT" ]; then
86 $SUBIT "$JBOSS_CMD_STOP"
95 echo "usage: $0 (start|stop|restart|help)"