Updated to use a $NAME variable to create PID and state files,

correcting also locations where these are stored (in jetty.base rather
than jetty.home).
This commit is contained in:
Simone Bordet 2013-11-07 23:46:55 +01:00
parent d9f818bee9
commit 1f140548fa
1 changed files with 19 additions and 24 deletions

View File

@ -2,6 +2,12 @@
# #
# Startup script for jetty under *nix systems (it works under NT/cygwin too). # Startup script for jetty under *nix systems (it works under NT/cygwin too).
##################################################
# Set the name which is used by other variables.
# Defaults to the file name without extension.
##################################################
NAME=$(echo $(basename $0) | sed -e 's/^[SK][0-9]+//' -e 's/\.sh$//')
# To get the service to restart correctly on reboot, uncomment below (3 lines): # To get the service to restart correctly on reboot, uncomment below (3 lines):
# ======================== # ========================
# chkconfig: 3 99 99 # chkconfig: 3 99 99
@ -11,15 +17,15 @@
# Configuration files # Configuration files
# #
# /etc/default/jetty # /etc/default/$NAME
# If it exists, this is read at the start of script. It may perform any # If it exists, this is read at the start of script. It may perform any
# sequence of shell commands, like setting relevant environment variables. # sequence of shell commands, like setting relevant environment variables.
# #
# $HOME/.jettyrc # $HOME/.$NAMErc (e.g. $HOME/.jettyrc)
# If it exists, this is read at the start of script. It may perform any # If it exists, this is read at the start of script. It may perform any
# sequence of shell commands, like setting relevant environment variables. # sequence of shell commands, like setting relevant environment variables.
# #
# /etc/jetty.conf # /etc/$NAME.conf
# If found, and no configurations were given on the command line, # If found, and no configurations were given on the command line,
# the file will be used as this script's configuration. # the file will be used as this script's configuration.
# Each line in the file may contain: # Each line in the file may contain:
@ -31,10 +37,6 @@
# #
# The files will be checked for existence before being passed to jetty. # The files will be checked for existence before being passed to jetty.
# #
# $JETTY_HOME/etc/jetty.xml
# If found, used as this script's configuration file, but only if
# /etc/jetty.conf was not present. See above.
#
# Configuration variables # Configuration variables
# #
# JAVA # JAVA
@ -67,12 +69,12 @@
# <Set name="Port">8080</Set> # <Set name="Port">8080</Set>
# #
# JETTY_RUN # JETTY_RUN
# Where the jetty.pid file should be stored. It defaults to the # Where the $NAME.pid file should be stored. It defaults to the
# first available of /var/run, /usr/var/run, JETTY_HOME and /tmp # first available of /var/run, /usr/var/run, JETTY_BASE and /tmp
# if not set. # if not set.
# #
# JETTY_PID # JETTY_PID
# The Jetty PID file, defaults to $JETTY_RUN/jetty.pid # The Jetty PID file, defaults to $JETTY_RUN/$NAME.pid
# #
# JETTY_ARGS # JETTY_ARGS
# The default arguments to pass to jetty. # The default arguments to pass to jetty.
@ -81,7 +83,6 @@
# #
# JETTY_USER # JETTY_USER
# if set, then used as a username to run the server as # if set, then used as a username to run the server as
#
usage() usage()
{ {
@ -92,12 +93,6 @@ usage()
[ $# -gt 0 ] || usage [ $# -gt 0 ] || usage
##################################################
# Set the name
##################################################
JETTY=jetty
################################################## ##################################################
# Some utility functions # Some utility functions
################################################## ##################################################
@ -169,7 +164,7 @@ then
ETC=$HOME/etc ETC=$HOME/etc
fi fi
for CONFIG in $ETC/default/${JETTY}{,9} $HOME/.${JETTY}rc; do for CONFIG in $ETC/default/${NAME}{,9} $HOME/.${NAME}rc; do
if [ -f "$CONFIG" ] ; then if [ -f "$CONFIG" ] ; then
readConfig "$CONFIG" readConfig "$CONFIG"
fi fi
@ -249,9 +244,9 @@ fi
################################################## ##################################################
if [ -z "$JETTY_CONF" ] if [ -z "$JETTY_CONF" ]
then then
if [ -f $ETC/${JETTY}.conf ] if [ -f $ETC/${NAME}.conf ]
then then
JETTY_CONF=$ETC/${JETTY}.conf JETTY_CONF=$ETC/${NAME}.conf
elif [ -f "$JETTY_BASE/etc/jetty.conf" ] elif [ -f "$JETTY_BASE/etc/jetty.conf" ]
then then
JETTY_CONF=$JETTY_BASE/etc/jetty.conf JETTY_CONF=$JETTY_BASE/etc/jetty.conf
@ -298,7 +293,7 @@ fi
##################################################### #####################################################
if [ -z "$JETTY_RUN" ] if [ -z "$JETTY_RUN" ]
then then
JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_HOME /tmp) JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE /tmp)
fi fi
##################################################### #####################################################
@ -306,12 +301,12 @@ fi
##################################################### #####################################################
if [ -z "$JETTY_PID" ] if [ -z "$JETTY_PID" ]
then then
JETTY_PID="$JETTY_RUN/${JETTY}.pid" JETTY_PID="$JETTY_RUN/${NAME}.pid"
fi fi
if [ -z "$JETTY_STATE" ] if [ -z "$JETTY_STATE" ]
then then
JETTY_STATE=$JETTY_HOME/${JETTY}.state JETTY_STATE=$JETTY_BASE/${NAME}.state
fi fi
JAVA_OPTIONS+=("-Djetty.state=$JETTY_STATE") JAVA_OPTIONS+=("-Djetty.state=$JETTY_STATE")
rm -f $JETTY_STATE rm -f $JETTY_STATE
@ -409,7 +404,7 @@ case "$ACTION" in
echo -n "Starting Jetty: " echo -n "Starting Jetty: "
if (( NO_START )); then if (( NO_START )); then
echo "Not starting ${JETTY} - NO_START=1"; echo "Not starting ${NAME} - NO_START=1";
exit exit
fi fi