Great information!
If I'd have knew that I wouldn't have spent the time to dig it for myself. However, if somebody is interested in my experience, I have installed JBoss 4.2.3.GA on my Ubuntu (8.04) machine and when trying to run it as a service I had some problems with the already-available scripts (e.g. for RedHat, SuSE, HPUX). Therefore I have derived the RedHat script and here are the steps that made my installation work:
1. Create in /etc/init.d folder a file for the JBoss service (e.g. jboss.sh). Note that you need the right to create files there...
2. Using your preferred editor (e.g. gedit), fill in the file with the following content (note that changes for your local installation are needed):
Code:
#!/bin/sh
#
# This script has been derived from the following one:
# $Id: jboss_init_redhat.sh 71252 2008-03-25 17:52:00Z dbhole $
#
# 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 Ubuntu systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk.
# 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.
#
# Major changes from the original one:
# * usage of the shutdown.sh script instead of killing the jboss' JVM process. This simplifies the structure of the script.
# * added support for bind address change (see the JBOSS_HOST variable).
#define the JAVA_HOME
JAVA_HOME=${JAVA_HOME:-"/usr/local/jdk"}
#define where jboss is - this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/usr/local/jboss"}
#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"jboss"}
#configuration to use, usually one of 'minimal', 'default', 'all'
JBOSS_CONF=${JBOSS_CONF:-"default"}
#bind address
JBOSS_HOST=${JBOSS_HOST:-"127.0.0.1"}
#define the script used to start jboss
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF -b $JBOSS_HOST"}
#define the script used to stop jboss
JBOSSST=${JBOSSST:-"$JBOSS_HOME/bin/shutdown.sh -S -s jnp://$JBOSS_HOST:1099"}
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"
JBOSS_CONSOLE="/dev/null"
fi
#define what will be done with the console log
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
JBOSS_CMD_STOP="cd $JBOSS_HOME/bin; $JBOSSST"
if [ ! -d "$JBOSS_HOME" ]; then
echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
exit 1
fi
case "$1" in
start)
cd $JBOSS_HOME/bin
echo JBOSS_CMD_START = $JBOSS_CMD_START
if [ -z "$SUBIT" ]; then
eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
else
$SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &"
fi
;;
stop)
cd $JBOSS_HOME/bin
echo JBOSS_CMD_STOP = $JBOSS_CMD_STOP
if [ -z "$SUBIT" ]; then
eval $JBOSS_CMD_STOP >${JBOSS_CONSOLE} 2>&1 &
else
$SUBIT "$JBOSS_CMD_STOP >${JBOSS_CONSOLE} 2>&1 &"
fi
;;
restart)
$0 stop
# there must be a time between the "stop" and the "start" because the mentioned two are asynchronous operations.
# this depends on how fast your machine is.
sleep 3
$0 start
;;
*)
echo "usage: $0 (start|stop|restart)"
esac
3. Configure the script to start for your preferred runlevels (e.g. 3 and 5). To do this you can use the sysvconfig utility.
The same information is available at http://cristivulpe.blogspot.com/2008...v-service.html.
Regards,
cristi
Bookmarks