#! /bin/sh
test -x /usr/mqm/bin/dspmq || exit 5
test -x /usr/mqm/bin/strmqm || exit 5
test -x /usr/mqm/bin/endmqm || exit 5
if test "x$QUEUE_MANAGERS" = x ; then
# Default to deal with all defined QMs
QUEUE_MANAGERS='*'
fi
if test "x$QUEUE_MANAGERS" = 'x*' ; then
# Expand * to list of all queue managers
QUEUE_MANAGERS=`su - mqm -c "/usr/mqm/bin/dspmq" | sed -e 's/^QMNAME(\([^)]*\)).*/\1/'`
fi
if test "x$STOP_METHOD" = x ; then
# Default to quiesce and wait
STOP_METHOD='-w'
fi
stop_qm()
{
QM=$1
echo "Stopping queue manager $QM"
su - mqm -c "/usr/mqm/bin/endmqm $STOP_METHOD $QM" > /dev/null 2>&1
STAT=$?
if test $STAT -eq 0 ; then
echo "Queue manager $QM stopped"
elif test $STAT -eq 40 ; then
echo "Queue manager $QM not available"
elif test $STAT -eq 16 ; then
echo "Queue manager $QM does not exist"
else
echo "Stopping queue manager $QM failed (rc=$STAT)"
fi
}
start_qm()
{
QM=$1
echo "Starting queue manager $QM"
su - mqm -c "/usr/mqm/bin/strmqm $QM" > /dev/null 2>&1
STAT=$?
if test $STAT -eq 0 ; then
echo "Queue manager $QM started"
elif test $STAT -eq 5 ; then
echo "Queue manager $QM is already running"
elif test $STAT -eq 16 ; then
echo "Queue manager $QM does not exist"
else
echo "Starting queue manager $QM failed (rc=$STAT)"
fi
}
qm_status()
{
QM=$1
su - mqm -c "/usr/mqm/bin/dspmq" | grep "^QMNAME($QM).*STATUS(Running)\$" > /dev/null 2>&1
}
qm_status_verbose()
{
QM=$1
echo "Getting status of queue manager $QM"
su - mqm -c "/usr/mqm/bin/dspmq" | grep "^QMNAME($QM).*STATUS(.*)\$" > /dev/null 2>&1
STAT=$?
if test $STAT -eq 0 ; then
QMSTATUS=`su - mqm -c "/usr/mqm/bin/dspmq" | grep "QMNAME($QM)" | sed -n 's/^.*STATUS(\(.*\))$/\1/p'`
echo "Queue manager $QM status is: $QMSTATUS"
else
echo "Queue manager $QM does not exist"
fi
}
case "$1" in
start)
echo "Starting Queue Managers:"
for QM in $QUEUE_MANAGERS ; do
start_qm $QM
done
;;
stop)
echo "Stopping Queue Managers:"
for QM in $QUEUE_MANAGERS ; do
stop_qm $QM
done
;;
try-restart)
echo "Restarting Active Queue Managers:"
for QM in $QUEUE_MANAGERS ; do
qm_status $QM && (stop_qm $QM; start_qm $QM)
done
;;
restart)
echo "Restarting All Queue Managers:"
for QM in $QUEUE_MANAGERS ; do
qm_status $QM && stop_qm $QM
start_qm $QM
done
;;
force-reload)
$0 try-restart
;;
reload)
echo "reload does nothing"
exit 3
;;
status)
echo "Checking Queue Manager Status:"
for QM in $QUEUE_MANAGERS ; do
qm_status_verbose $QM
done
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
# WebSphere MQ for AIX Init Script
This script assumes WebSphere MQ is installed at /usr/mqm/.
This init script is based on the init script provided in WebSphere MQ SupportPac for Linux. That can be viewed [here](http://www-01.ibm.com/support/docview.wss?uid=swg24016554)
### Setup
* Copy mq.sh to /etc/rc.d/init.d
* Create symbolic links to mq.sh in the appropriate run level directory
- /etc/rc.d/rc2.d/S1_mq.sh
- /etc/rc.d/rc2.d/K1_mq.sh
S<number>, K<number> specify the order that the script should run in relation to the other scripts at that run level when starting or stopping the server.