Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Commit 7db2302

Browse files
committed
Split mq.sh into multiple scripts
1 parent 6604d44 commit 7db2302

10 files changed

+228
-123
lines changed

mq-configure-qmgr.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Turn off script failing here because of listeners failing the script
18+
19+
for MQSC_FILE in $(ls -v /etc/mqm/*.mqsc); do
20+
runmqsc ${MQ_QMGR_NAME} < ${MQSC_FILE}
21+
done

mq-create-qmgr.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
QMGR_EXISTS=`dspmq | grep ${MQ_QMGR_NAME} > /dev/null ; echo $?`
20+
if [ ${QMGR_EXISTS} -ne 0 ]; then
21+
MQ_DEV=${MQ_DEV:-"true"}
22+
if [ "${MQ_DEV}" == "true" ]; then
23+
# Turns on early adopt if we're using Developer defaults
24+
export AMQ_EXTRA_QM_STANZAS=Channels:ChlauthEarlyAdopt=Y
25+
fi
26+
crtmqm -q ${MQ_QMGR_NAME} || true
27+
fi

mq-dev-config.sh

+15-15
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ configure_tls()
8989
# Now copy the key files
9090
chown mqm:mqm /tmp/tlsTemp/key.*
9191
chmod 640 /tmp/tlsTemp/key.*
92-
su -c "cp -PTv /tmp/tlsTemp/key.kdb ${DATA_PATH}/qmgrs/$1/ssl/key.kdb" -l mqm
93-
su -c "cp -PTv /tmp/tlsTemp/key.sth ${DATA_PATH}/qmgrs/$1/ssl/key.sth" -l mqm
92+
su -c "cp -PTv /tmp/tlsTemp/key.kdb ${DATA_PATH}/qmgrs/${MQ_QMGR_NAME}/ssl/key.kdb" -l mqm
93+
su -c "cp -PTv /tmp/tlsTemp/key.sth ${DATA_PATH}/qmgrs/${MQ_QMGR_NAME}/ssl/key.sth" -l mqm
9494

9595
# Set up Dev default MQ objects
9696
# Make channel TLS CHANNEL
9797
# Create SSLPEERMAP Channel Authentication record
9898
if [ "${MQ_DEV}" == "true" ]; then
99-
su -l mqm -c "echo \"ALTER CHANNEL('DEV.APP.SVRCONN') CHLTYPE(SVRCONN) SSLCIPH(TLS_RSA_WITH_AES_256_GCM_SHA384) SSLCAUTH(OPTIONAL)\" | runmqsc $1"
100-
su -l mqm -c "echo \"ALTER CHANNEL('DEV.ADMIN.SVRCONN') CHLTYPE(SVRCONN) SSLCIPH(TLS_RSA_WITH_AES_256_GCM_SHA384) SSLCAUTH(OPTIONAL)\" | runmqsc $1"
99+
su -l mqm -c "echo \"ALTER CHANNEL('DEV.APP.SVRCONN') CHLTYPE(SVRCONN) SSLCIPH(TLS_RSA_WITH_AES_256_GCM_SHA384) SSLCAUTH(OPTIONAL)\" | runmqsc ${MQ_QMGR_NAME}"
100+
su -l mqm -c "echo \"ALTER CHANNEL('DEV.ADMIN.SVRCONN') CHLTYPE(SVRCONN) SSLCIPH(TLS_RSA_WITH_AES_256_GCM_SHA384) SSLCAUTH(OPTIONAL)\" | runmqsc ${MQ_QMGR_NAME}"
101101
fi
102102
}
103103

@@ -127,33 +127,33 @@ if ! getent group mqclient; then
127127
fi
128128
configure_os_user 1002 1002 MQ_APP_NAME MQ_APP_PASSWORD /home/app
129129
# Set authorities to give access to qmgr, queues and topic
130-
su -l mqm -c "setmqaut -m $1 -t qmgr -g mqclient +connect +inq"
131-
su -l mqm -c "setmqaut -m $1 -n \"DEV.**\" -t queue -g mqclient +put +get +browse"
132-
su -l mqm -c "setmqaut -m $1 -n \"DEV.**\" -t topic -g mqclient +sub +pub"
130+
su -l mqm -c "setmqaut -m ${MQ_QMGR_NAME} -t qmgr -g mqclient +connect +inq"
131+
su -l mqm -c "setmqaut -m ${MQ_QMGR_NAME} -n \"DEV.**\" -t queue -g mqclient +put +get +browse"
132+
su -l mqm -c "setmqaut -m ${MQ_QMGR_NAME} -n \"DEV.**\" -t topic -g mqclient +sub +pub"
133133

134134
echo "Configuring admin user"
135135
configure_os_user 1001 1000 MQ_ADMIN_NAME MQ_ADMIN_PASSWORD /home/admin
136136

137137
if [ "${MQ_DEV}" == "true" ]; then
138-
echo "Configuring default objects for queue manager: $1"
138+
echo "Configuring default objects for queue manager: ${MQ_QMGR_NAME}"
139139
set +e
140-
runmqsc $1 < /etc/mqm/mq-dev-config
141-
echo "ALTER CHANNEL('DEV.APP.SVRCONN') CHLTYPE(SVRCONN) MCAUSER('${MQ_APP_NAME}')" | runmqsc $1
140+
runmqsc ${MQ_QMGR_NAME} < /etc/mqm/mq-dev-config
141+
echo "ALTER CHANNEL('DEV.APP.SVRCONN') CHLTYPE(SVRCONN) MCAUSER('${MQ_APP_NAME}')" | runmqsc ${MQ_QMGR_NAME}
142142

143143
# If client password set to "" allow users to connect to application channel without a userid
144144
if [ "${MQ_APP_PASSWORD}" == "" ]; then
145-
echo "SET CHLAUTH('DEV.APP.SVRCONN') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(CHANNEL) CHCKCLNT(ASQMGR) ACTION(REPLACE)" | runmqsc $1
145+
echo "SET CHLAUTH('DEV.APP.SVRCONN') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(CHANNEL) CHCKCLNT(ASQMGR) ACTION(REPLACE)" | runmqsc ${MQ_QMGR_NAME}
146146
fi
147147
set -e
148148
fi
149149

150150
if [ ! -z ${MQ_TLS_KEYSTORE+x} ]; then
151-
if [ ! -e "${DATA_PATH}/qmgrs/$1/ssl/key.kdb" ]; then
152-
echo "Configuring TLS for queue manager $1"
151+
if [ ! -e "${DATA_PATH}/qmgrs/${MQ_QMGR_NAME}/ssl/key.kdb" ]; then
152+
echo "Configuring TLS for queue manager ${MQ_QMGR_NAME}"
153153
mkdir -p /tmp/tlsTemp
154154
chown mqm:mqm /tmp/tlsTemp
155-
configure_tls $1
155+
configure_tls
156156
else
157-
echo "A key store already exists at '${DATA_PATH}/qmgrs/$1/ssl/key.kdb'"
157+
echo "A key store already exists at '${DATA_PATH}/qmgrs/${MQ_QMGR_NAME}/ssl/key.kdb'"
158158
fi
159159
fi

mq-monitor-qmgr.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
state()
20+
{
21+
dspmq -n -m ${MQ_QMGR_NAME} | awk -F '[()]' '{ print $4 }'
22+
}
23+
24+
trap mq-stop-container.sh SIGTERM SIGINT
25+
26+
# Loop until "dspmq" says the queue manager is running
27+
until [ "`state`" == "RUNNING" ]; do
28+
sleep 1
29+
done
30+
dspmq
31+
32+
echo "IBM MQ Queue Manager ${MQ_QMGR_NAME} is now fully running"
33+
34+
# Loop until "dspmq" says the queue manager is not running any more
35+
until [ "`state`" != "RUNNING" ]; do
36+
sleep 5
37+
done
38+
39+
# Wait until queue manager has ended before exiting
40+
while true; do
41+
STATE=`state`
42+
case "$STATE" in
43+
ENDED*) break;;
44+
*) ;;
45+
esac
46+
sleep 1
47+
done
48+
dspmq

mq-parameter-check.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
: ${MQ_QMGR_NAME?"ERROR: You need to set the MQ_QMGR_NAME environment variable"}
20+
21+
# We want to do parameter checking early as then we can stop and error early before it looks
22+
# like everything is going to be ok (when it won't)
23+
if [ ! -z ${MQ_TLS_KEYSTORE+x} ]; then
24+
: ${MQ_TLS_PASSPHRASE?"Error: If you supply MQ_TLS_KEYSTORE, you must supply MQ_TLS_PASSPHRASE"}
25+
fi

mq-pre-create-setup.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
source /opt/mqm/bin/setmqenv -s
20+
dspmqver
21+
echo "Checking filesystem..."
22+
amqmfsck /var/mqm

mq-start-qmgr.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
if [ ${MQ_QMGR_CMDLEVEL+x} ]; then
20+
# Enables the specified command level, then stops the queue manager
21+
strmqm -e CMDLEVEL=${MQ_QMGR_CMDLEVEL} || true
22+
fi
23+
24+
strmqm ${MQ_QMGR_NAME}

mq-stop-container.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# -*- mode: sh -*-
3+
# © Copyright IBM Corporation 2015, 2017
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
endmqm $MQ_QMGR_NAME
20+
which endmqweb && endmqweb

mq.sh

+18-106
Original file line numberDiff line numberDiff line change
@@ -15,110 +15,22 @@
1515
# limitations under the License.
1616

1717
set -e
18-
19-
stop()
20-
{
21-
endmqm $MQ_QMGR_NAME
22-
}
23-
24-
parameterCheck()
25-
{
26-
: ${MQ_QMGR_NAME?"ERROR: You need to set the MQ_QMGR_NAME environment variable"}
27-
28-
# We want to do parameter checking early as then we can stop and error early before it looks
29-
# like everything is going to be ok (when it won't)
30-
if [ ! -z ${MQ_TLS_KEYSTORE+x} ]; then
31-
if [ -z ${MQ_TLS_PASSPHRASE+x} ]; then
32-
echo "Error: If you supply MQ_TLS_KEYSTORE, you must supply MQ_TLS_PASSPHRASE"
33-
exit 1;
34-
fi
35-
fi
36-
}
37-
38-
config()
39-
{
40-
# Populate and update the contents of /var/mqm - this is needed for
41-
# bind-mounted volumes, and also to migrate data from previous versions of MQ
42-
43-
setup-var-mqm.sh
44-
45-
if [ -z "${MQ_DISABLE_WEB_CONSOLE}" ]; then
46-
echo $MQ_ADMIN_PASSWORD
47-
# Start the web console, if it's been installed
48-
which strmqweb && setup-mqm-web.sh
49-
fi
50-
51-
ls -l /var/mqm
52-
source /opt/mqm/bin/setmqenv -s
53-
echo "----------------------------------------"
54-
dspmqver
55-
echo "----------------------------------------"
56-
57-
QMGR_EXISTS=`dspmq | grep ${MQ_QMGR_NAME} > /dev/null ; echo $?`
58-
if [ ${QMGR_EXISTS} -ne 0 ]; then
59-
echo "Checking filesystem..."
60-
amqmfsck /var/mqm
61-
echo "----------------------------------------"
62-
MQ_DEV=${MQ_DEV:-"true"}
63-
if [ "${MQ_DEV}" == "true" ]; then
64-
# Turns on early adopt if we're using Developer defaults
65-
export AMQ_EXTRA_QM_STANZAS=Channels:ChlauthEarlyAdopt=Y
66-
fi
67-
crtmqm -q ${MQ_QMGR_NAME} || true
68-
if [ ${MQ_QMGR_CMDLEVEL+x} ]; then
69-
# Enables the specified command level, then stops the queue manager
70-
strmqm -e CMDLEVEL=${MQ_QMGR_CMDLEVEL} || true
71-
fi
72-
echo "----------------------------------------"
73-
fi
74-
strmqm ${MQ_QMGR_NAME}
75-
76-
# Turn off script failing here because of listeners failing the script
77-
set +e
78-
for MQSC_FILE in $(ls -v /etc/mqm/*.mqsc); do
79-
runmqsc ${MQ_QMGR_NAME} < ${MQSC_FILE}
80-
done
81-
set -e
82-
83-
echo "----------------------------------------"
84-
mq-dev-config.sh ${MQ_QMGR_NAME}
85-
echo "----------------------------------------"
86-
}
87-
88-
state()
89-
{
90-
dspmq -n -m ${MQ_QMGR_NAME} | awk -F '[()]' '{ print $4 }'
91-
}
92-
93-
monitor()
94-
{
95-
# Loop until "dspmq" says the queue manager is running
96-
until [ "`state`" == "RUNNING" ]; do
97-
sleep 1
98-
done
99-
dspmq
100-
101-
echo "IBM MQ Queue Manager ${MQ_QMGR_NAME} is now fully running"
102-
103-
# Loop until "dspmq" says the queue manager is not running any more
104-
until [ "`state`" != "RUNNING" ]; do
105-
sleep 5
106-
done
107-
108-
# Wait until queue manager has ended before exiting
109-
while true; do
110-
STATE=`state`
111-
case "$STATE" in
112-
ENDED*) break;;
113-
*) ;;
114-
esac
115-
sleep 1
116-
done
117-
dspmq
118-
}
119-
12018
mq-license-check.sh
121-
parameterCheck
122-
config
123-
trap stop SIGTERM SIGINT
124-
monitor
19+
echo "----------------------------------------"
20+
mq-parameter-check.sh
21+
echo "----------------------------------------"
22+
setup-var-mqm.sh
23+
echo "----------------------------------------"
24+
which strmqweb && setup-mqm-web.sh
25+
echo "----------------------------------------"
26+
mq-pre-create-setup.sh
27+
echo "----------------------------------------"
28+
mq-create-qmgr.sh
29+
echo "----------------------------------------"
30+
mq-start-qmgr.sh
31+
echo "----------------------------------------"
32+
mq-configure-qmgr.sh
33+
echo "----------------------------------------"
34+
mq-dev-config.sh
35+
echo "----------------------------------------"
36+
exec mq-monitor-qmgr.sh

0 commit comments

Comments
 (0)