#!/bin/sh #============================================================================== # /etc/init.d/mqseries - Start/Stop MQSeries # $Id: S88mqseries,v 1.9 2006/06/26 23:10:06 shelden Exp $ # # A straightforward script to start and stop Webshere MQ queue # managers under SysV init. # # Although it can start more than one queue manager (add them # as a space-separated list to the QMGRS= line below), they # all must need to have the same programs started to be useful; # this is difficult if you use runmqlsr. # # Mostly, this file is based on the Solaris files for sendmail. As # such, you should copy this file to: # /etc/init.d/mqseries # And then make symlinks like: # cd /etc/rc0.d/ ; ln -s ../init.d/mqseries K57mqseries # cd /etc/rc1.d/ ; ln -s ../init.d/mqseries K57mqseries # cd /etc/rc2.d/ ; ln -s ../init.d/mqseries S88mqseries # And optionally: # chown mqm:mqm /etc/init.d/mqseries # ...which is good idea for sites where mqm and root are different # people. # # --shelden 28 January 1998 #============================================================================== PATH=/usr/xpg4/bin:/usr/bin:/bin:/opt/mqm/bin:/usr/ucb PS=/bin/ps GREP=/bin/grep SED=/bin/sed L=/dev/null # if you want a log file, change this N=/dev/null # ...but don't change this #============================================================================== # This assumes that the Queue Manager's name is the name as the # (short) hostname, only in all caps. This is a convention I # tend to use, but of course it's not universal. # # If this is not true at your site, just hard code The queue # manager name (or names). I.e., QMGRS=FOO BAR or QMGRS=FOO QMGRS=`hostname | awk -F. '{print $1}' | tr a-z A-Z` #============================================================================== SU="sh" if [ "`whoami`" = "root" ]; then SU="su - mqm" fi #============================================================================== killproc() { # kill the named process(es) pid=`$PS -e | $GREP -w $1 | $SED -e 's/^ *//' -e 's/ .*//'` [ "$pid" != "" ] && kill -9 $pid } #============================================================================== start() { for qmgr in $QMGRS ; do export qmgr echo "$0: starting $qmgr" $SU -c "strmqm $qmgr" $SU -c "nohup runmqchi -m $qmgr >> $L 2>&1 < $N &" $SU -c "nohup runmqtrm -m $qmgr >> $L 2>&1 < $N &" $SU -c "nohup runmqlsr -m $qmgr -t tcp -p 1414 >> $L 2>&1 < $N &" $SU -c "nohup runmqlsr -m $qmgr -t tcp -p 14140 >> $L 2>&1 < $N &" done } #============================================================================== stop() { for qmgr in $QMGRS ; do export qmgr echo ending $qmgr killproc runmqlsr $SU -c "endmqm -w $qmgr" done } case $1 in 'start') start ;; 'stop') stop ;; 'restart') stop start ;; *) echo "usage: $0 {start|stop|restart}" ;; esac