Cool! Maybe you'd like to open a JIRA and contribute your script once you're done? :-)

For the status, maybe you could try something like -

isGeronimoRunning()
{
  ps_log=`mktemp /var/tmp/geronimo-ps.log`
  ps auxww >"$ps_log"
  geronimo_is_running="false"
if grep " -Dorg.apache.geronimo.base.dir=.*server.jar" "$ps_log" >/dev/null 2>/dev/null ; then
    geronimo_is_running="true"
  fi
  rm -f "$ps_log"
  test "$geronimo_is_running" = "true"
}



-Donald


Doug Reeder wrote:
I've written a bash shell script to start and stop geronimo, for use with System V startup (scripts in /etc/rc.d/init.d/).

Start and stop are straightforward, as the scripts in $GERONIMO_HOME/bin/ just need to be called, but status is less obvious. The best I've come up with so far is

su -l -c "$GERONIMO_HOME/bin/deploy.sh -u $GERONIMO_ADMIN -p $GERONIMO_PASSWORD list-modules" $USER

but it's not satisfactory:
1) if geronimo is not running, it produces a stack dump, when all I want is a simple message indicating geronimo is not running

2) I have to include the geronimo administrator password in the script (of course, it also needs to be in the script so geronimo can be shut down).

Can anyone suggest something better? If geronimo is running, what would be best is a short list of all the ports it's listening on. (Then one could use netstat or whatever to see if one can actually access them).



#! /bin/sh

# Return values
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running

isGeronimoRunning()
{
  ps_log=`mktemp /var/tmp/geronimo-ps.log`
  ps auxww >"$ps_log"
  geronimo_is_running="false"
  if grep " -Dorg.apache.geronimo.base.dir=.*server.jar" "$ps_log" >/dev/null 
2>/dev/null ; then
    geronimo_is_running="true"
  fi
  rm -f "$ps_log"
  test "$geronimo_is_running" = "true"
}

if isGeronimoRunning ; then
  echo Found a Geronimo server instance running.
  exit 0
else
  echo Did not find a Geronimo server instance running.
  exit 7
fi

Reply via email to