WMB init script

For a client, I recently had to install a WebSphere Message Broker on Suse Linux. This also means getting it to start at boot time. Now, as far as I’ve been able to locate, WMB does not come with a init script. For WebSphere MQ, IBM recently added a service pac, MSL1, that does exactly this, but so far no luck for WMB. SLES uses LSB compliant init scripts, and has a command called insserv which automatically sets up the soft links to make all components start it the right order based on the dependencies you define as metadata in your script. So, with no further ado, here’s my current stab at the script:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          wmb
# Required-Start:    $syslog $network $remote_fs ibm.com-WebSphere_MQ
# Should-Start:      db2
# Required-Stop:     $syslog $network
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: WebSphere Message Broker
# Description:       Starts WebSphere Message Broker
### END INIT INFO

# Source /etc/rc.status:
. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
    	echo -n "Starting WMB "
    	su - mqm -c 'mqsistart BRK1D;mqsistart CFGMGRD'

    	# Remember status and be verbose
    	rc_status -v
	  ;;
    stop)
    	echo -n "Shutting down WMB "
    	su - mqm -c 'mqsistop BRK1D;mqsistop CFGMGRD'

    	# Remember status and be verbose
    	rc_status -v
	  ;;
    try-restart|condrestart)
	    ## Do a restart only if the service was active before.
	    $0 status
    	if test $? = 0; then
    		$0 restart
    	else
    		rc_reset	# Not running is not a failure.
    	fi
    	# Remember status and be quiet
    	rc_status
	  ;;
    restart)
    	## Stop the service and regardless of whether it was
    	## running or not, start it again.
    	$0 stop
    	$0 start

    	# Remember status and be quiet
    	rc_status
	  ;;
    force-reload)
    	$0 try-restart
    	rc_status
	  ;;
    reload)
	    rc_failed 3
	    rc_status -v
	  ;;
    status)
	   echo -n "Checking for service WMB "
	   /sbin/checkproc /opt/ibm/mqsi/6.0/bin/bipservice
	   rc_status -v
	  ;;
    *)
	    echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
	    exit 1
	  ;;
esac
rc_exit

Note that the script will start WMB as the mqm user. If this is not what you want, you will have to make your changes at the su commands.

To use, create a file called /etc/init.d/wmb and paste the above content into. Make sure it’s runnable with:

chmod +x /etc/init.d/wmb

The run:

insserv wmb

And it should set everything nicely for you.

Note that this script is dependent on the WebSphere MQ init script, as provided in the support pac mentioned above. It will also start DB2 beforehand, if available. In my case, we are using DB2, I’m just not happy with the current script I got so I will hold off publishing it until I’m done.

I will be happy to get feedback in the comments on my attempt and will update the code above with any changes.

Technorati Tags: , , , , , , ,

4 Responses

  1. Stephan Says:
    AFAIR there is now need for a start script for the DB2 instance, since V8.2 you can set the instance to start automatically by using the “db2iauto” command.
  2. niklas Says:
    Yes, I already use db2iauto for starting my DB2 instance. As you know, DB2 starts its fault monitor in the /etc/inittab which means it doesn’t play that well with LSB init scripts. For example, setting up dependencies like I’ve done for the WMB script above.

    I’m trying to figure out how to move it into a LSB init script with all the required commands, like start, stop and status. I’m currently stuck on finding the best way of deciding on the status.

  3. Stephan Says:
    I see, humm the DB2 instance status is a hard one. Don’t have an V8.2 on Linux easily available right now but I think the instance is not just 1 process it’s a few procs started for it. Another thing about your script, I can’t see where you source the mqsiprofile for the user you maybe have it in mqm’s .profile? I believe it’s always a good idea to source the db2profile for the user that issues the mqsistart/-stop commands as well, maybe link it inside the mqsiprofile but it should be sourced.
  4. niklas Says:
    Yes, the instance is indeed multiple processes. However, I’m pretty sure that it’s not the instance you want to check the status for. You should probably check the fault manager status, which in worst case should be possible using ps -ef.

    I currently source both the DB2 profile and mqsiprofile in the mqm .profile. I find this works pretty good.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.