geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Reeder <reeder...@gmail.com>
Subject Re: status from shell script (System V starup)
Date Wed, 19 Nov 2008 05:20:11 GMT
Thanks for the suggestion -- I didn't want to have to modify the start  
script to save the PID.  Here's what I've come up with -- it's not  
polished, but does what you need a System V startup script to do:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          geronimo
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Apache Geronimo application server
# Description:       Apache Geronimo startup script
### END INIT INFO
set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
#DESC="Apache Geronimo"
NAME=geronimo
USER=gdaemon
JAVA_HOME=/usr/java/jdk
GERONIMO_HOME=/usr/local/geronimo
DAEMON=$GERONIMO_HOME/bin/geronimo.sh
SCRIPTNAME=/etc/init.d/$NAME
GERONIMO_ADMIN=gadmin
GERONIMO_PASSWORD=xxxxxx

# JAVA_HOME must be set
export JAVA_HOME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

#
#       Function that starts the daemon/service.
#
d_start() {
	su -c "$DAEMON start" $USER
}

#
#       Function that stops the daemon/service.
#
d_stop() {
         su -c "$DAEMON stop --user $GERONIMO_ADMIN --password  
$GERONIMO_PASSWORD" $USER
}

#
#        Function that gets status
#
d_status() {
     ps_log=`mktemp /var/tmp/geronimo-ps$$.log`
     ps auxww >"$ps_log"
     if grep " -Dorg.apache.geronimo.base.dir=.*server.jar" "$ps_log"  
 >/dev/null 2>/dev/null; then
         echo "$NAME is running"
     else
         echo "$NAME is not running"
     fi
     rm -f "$ps_log"
}

case "$1" in
   start)
         echo -n "Starting $NAME"
         d_start
         echo "."
         ;;
   stop)
         echo  "Stopping $NAME"
         d_stop
         echo "."
         ;;
   restart)
         #
         #       If the "reload" option is implemented, move the  
"force-reload"
         #       option to the "reload" entry above. If not, "force- 
reload" is
         #       just the same as "restart".
         #
         echo  "Restarting $NAME"
         d_stop
         # One second might not be time enough for a daemon to stop,
         # if this happens, d_start will fail (and dpkg will break if
         # the package is being upgraded). Change the timeout if needed
         # be, or change d_stop to have start-stop-daemon use --retry.
         # Notice that using --retry slows down the shutdown process  
somewhat.
         sleep 10
         d_start
         echo "."
         ;;
   status)
         d_status
	echo "."
	;;
   *)
         echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
         exit 3
         ;;
esac

exit 0


Mime
View raw message