-
Notifications
You must be signed in to change notification settings - Fork 4
/
mq.sh
119 lines (107 loc) · 3.24 KB
/
mq.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# -*- mode: sh -*-
# © Copyright IBM Corporation 2015, 2017
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
stop()
{
endmqm $MQ_QMGR_NAME
}
parameterCheck()
{
: ${MQ_QMGR_NAME?"ERROR: You need to set the MQ_QMGR_NAME environment variable"}
# We want to do parameter checking early as then we can stop and error early before it looks
# like everything is going to be ok (when it won't)
if [ ! -z ${MQ_TLS_KEYSTORE+x} ]; then
if [ -z ${MQ_TLS_PASSPHRASE+x} ]; then
echo "Error: If you supply MQ_TLS_KEYSTORE, you must supply MQ_TLS_PASSPHRASE"
exit 1;
fi
fi
}
config()
{
# Populate and update the contents of /var/mqm - this is needed for
# bind-mounted volumes, and also to migrate data from previous versions of MQ
setup-var-mqm.sh
if [ -z "${MQ_DISABLE_WEB_CONSOLE}" ]; then
echo $MQ_ADMIN_PASSWORD
# Start the web console, if it's been installed
which strmqweb && setup-mqm-web.sh
fi
ls -l /var/mqm
source /opt/mqm/bin/setmqenv -s
echo "----------------------------------------"
dspmqver
echo "----------------------------------------"
QMGR_EXISTS=`dspmq | grep ${MQ_QMGR_NAME} > /dev/null ; echo $?`
if [ ${QMGR_EXISTS} -ne 0 ]; then
echo "Checking filesystem..."
amqmfsck /var/mqm
echo "----------------------------------------"
MQ_DEV=${MQ_DEV:-"true"}
if [ "${MQ_DEV}" == "true" ]; then
# Turns on early adopt if we're using Developer defaults
export AMQ_EXTRA_QM_STANZAS=Channels:ChlauthEarlyAdopt=Y
fi
crtmqm -q ${MQ_QMGR_NAME} || true
if [ ${MQ_QMGR_CMDLEVEL+x} ]; then
# Enables the specified command level, then stops the queue manager
strmqm -e CMDLEVEL=${MQ_QMGR_CMDLEVEL} || true
fi
echo "----------------------------------------"
fi
strmqm ${MQ_QMGR_NAME}
# Turn off script failing here because of listeners failing the script
set +e
for MQSC_FILE in $(ls -v /etc/mqm/*.mqsc); do
runmqsc ${MQ_QMGR_NAME} < ${MQSC_FILE}
done
set -e
echo "----------------------------------------"
mq-dev-config.sh ${MQ_QMGR_NAME}
echo "----------------------------------------"
}
state()
{
dspmq -n -m ${MQ_QMGR_NAME} | awk -F '[()]' '{ print $4 }'
}
monitor()
{
# Loop until "dspmq" says the queue manager is running
until [ "`state`" == "RUNNING" ]; do
sleep 1
done
dspmq
echo "IBM MQ Queue Manager ${MQ_QMGR_NAME} is now fully running"
# Loop until "dspmq" says the queue manager is not running any more
until [ "`state`" != "RUNNING" ]; do
sleep 5
done
# Wait until queue manager has ended before exiting
while true; do
STATE=`state`
case "$STATE" in
ENDED*) break;;
*) ;;
esac
sleep 1
done
dspmq
}
mq-license-check.sh
parameterCheck
config
trap stop SIGTERM SIGINT
monitor