[ openjms-Bugs-610282 ] Start / stop script for Redhat: missing

"SourceForge.net" <[email protected]> Thu, 03 Feb 2005 08:39:13 -0800
Newsgroups gmane.comp.java.openjms.devel
Message-ID <[email protected]>
Bugs item #610282, was opened at 2002-09-17 00:12
Message generated for change (Settings changed) made by josevnz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=474136&aid=610282&group_id=54559

Category: server
Group: v0.7.2b14
>Status: Closed
Resolution: None
Priority: 5
Submitted By: José Vicente Núñez Zuleta (josevnz)
Assigned to: Nobody/Anonymous (nobody)
Summary: Start / stop script for Redhat: missing

Initial Comment:
Hi,

I started to use your product but i found there is not
script to start / stop it automatically for Redhat.

I wrote one myself, maybe will be usefull for someone
on the same situation as me.

Hope this helps,

PD: I tested this script on Redhat 7.2 but should work
on 7.0, 7.1, 7.2 and 7.3.

Jose Vicente Nunez Zuleta.

# &lt;---- CUT HERE ------&gt;

#!/bin/bash

# OpenJMS init file for JMS
#
# chkconfig: 35 50 50
# description: Open Source Implementation of the Sun
JMS API. # Written by exolab.org. http://openjms.sourceforge.net/
#
# Script author: Jose Vicente Nunez Zuleta
(josevnz-/[email protected]) - 09/16/2002
#
# processname: /usr/local/openjms-0.7.2
# config: $OPENJMS_HOME/config
# pidfile: /var/run/openjms

# source function library
. /etc/rc.d/init.d/functions

# &lt;!--- START OF USER CONFIGURABLE SECTION ---&gt;
# User configurable section. Please modify the value of
the following variables:
JAVA_HOME=&quot;/usr/java/j2sdk1.4.0_01&quot;
OPENJMS_HOME=&quot;/usr/local/openjms-0.7.2&quot;
CONFIG_FILE=&quot;rmi_jms_jdbc.xml&quot;
# &lt;!--- END OF USER CONFIGURABLE SECTION ---&gt;

OPTIONS_START=&quot;-config $OPENJMS_HOME/config/$CONFIG_FILE&quot;
OPTIONS_STOP=&quot;-config $OPENJMS_HOME/config/$CONFIG_FILE
-stopServer&quot;
RETVAL=0
prog=&quot;$OPENJMS_HOME/bin/startjms.sh&quot;
admin=&quot;$OPENJMS_HOME/bin/admin.sh&quot;
WAIT_TIME=10

force() {
   rm -f /var/lock/subsys/openjms
   start
}

start() {
	echo -n &quot;Starting $prog: &quot;
        res=0;
        if [ ! -e /var/lock/subsys/openjms ] ; then
          $prog $OPTIONS_START 2&gt;&amp;1 &amp;
          # Wait some time to give OpenJMS a chance to
start
          sleep $WAIT_TIME
          res=`/bin/ps $! | /usr/bin/wc -l`
        else
          echo
          echo &quot;A lock file for '$prog' was detected.&quot;
          echo &quot;Maybe another instance of this program
is running.&quot;
          echo &quot;If this is not true, then run it again
using '$0 force'.&quot;
        fi
        # Now check if is still there
        [ $res -ne 0 ] &amp;&amp; success || failure
	RETVAL=$?
	echo
	touch /var/lock/subsys/openjms
	return $RETVAL
}

stop() {
	echo -n &quot;Stopping $prog: &quot;
	#killproc $prog
        res=`$admin $OPTIONS_STOP 2&gt;&amp;1 | /bin/grep
Exception | /usr/bin/wc -l`
        if [ $res -eq 0 ] ; then 
	  rm -f /var/lock/subsys/openjms
          success
        else 
          failure
        fi
	RETVAL=$?
	echo
	return $RETVAL
}

reload(){
	stop
        # Wait a little because the program takes at
least 5 seconds to die
        sleep $WAIT_TIME
	start
}

restart(){
        reload
}

condrestart(){
    [ -e /var/lock/subsys/openjms ] &amp;&amp; restart
    return 0
}

another_message() {
echo &lt;&lt;EOF
Another instance of OpenJMS is running.&quot;
If you think this is an error, type: '$0 force&quot;
EOF
}

case &quot;$1&quot; in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
        ;;
  reload)
	reload
        ;;
  condrestart)
	condrestart
	;;
  status)
        status $prog
        ;;
  force)
        force
        ;;
  *)
	echo $&quot;Usage: $0
{start|stop|status|restart|condrestart|reload|force}&quot;
	RETVAL=1
esac

exit $RETVAL


# &lt;----- CUT HERE -----&gt;

----------------------------------------------------------------------

Comment By: Tim Anderson (tanderson)
Date: 2003-01-13 03:57

Message:
Logged In: YES 
user_id=557161

I've finally refactored the openjms scripts so they can be 
more easily invoked by other user scripts. 
If you can refactor your script using the 0.7.4 scripts I 
will commit it. 

In particular, take a look at the 
$OPENJMS_HOME/bin/openjms.sh.

This can be used to start and stop OpenJMS - run it 
without any arguments to get usage.

To duplicate the behaviour of your existing script:
. $OPENJMS_HOME/bin/openjms.sh run      - to start
. $OPENJMS_HOME/bin/openjms.sh stop    - to stop 

Alternatively, invoke the wrapper scripts 
$OPENJMS_HOME/bin/startup.sh and 
$OPENJMS_HOME/bin/shutdown.sh

Note that the -config argument is no longer required. If 
not set, $OPENJMS_HOME/config/openjms.xml will be 
used.

BTW: It would be nice if the JAVA_HOME and 
OPENJMS_HOME weren't hardcoded in the scripts. I 
guess this could be got around by providing a simple 
install script for Unix.

Regards,

Tim


----------------------------------------------------------------------

Comment By: José Vicente Núñez Zuleta (josevnz)
Date: 2002-09-17 00:19

Message:
Logged In: YES 
user_id=283328

I tired to delete it, but i don't have permissions. The
fixed script is the last one, here is the code snipet i
added at the beginning:

# &lt;!--- END OF USER CONFIGURABLE SECTION ---&gt;

[ -z $JAVA_HOME ] &amp;&amp; exit 1
[ -z $OPENJMS_HOME ] &amp;&amp; exit 1
[ ! -e $OPENJMS_HOME/config/$CONFIG_FILE ] &amp;&amp; exit 1


----------------------------------------------------------------------

Comment By: José Vicente Núñez Zuleta (josevnz)
Date: 2002-09-17 00:18

Message:
Logged In: YES 
user_id=283328

I added a little path to check for the environment variables
and the configuration file. I'm adding the new version and
deleting the old one.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=474136&aid=610282&group_id=54559


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl