-
Notifications
You must be signed in to change notification settings - Fork 21
/
version_check.sh
executable file
·348 lines (324 loc) · 11.8 KB
/
version_check.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#!/bin/bash
if [ "$#" = 2 ]; then
if [ $2 = "pro" ]; then
pro="yes"
else
echo "Wrong second argument! It is not pro!"
exit 1
fi
elif [ "$#" -ne 1 ]; then
echo "This script requires product parameter: ps56, ps57, ps80, ps81 !"
echo "Usage: ./version_check.sh <prod> [pro]"
exit 1
fi
SCRIPT_PWD=$(cd $(dirname "$0") && pwd)
source "${SCRIPT_PWD}"/VERSIONS
if [ "$1" = "ps56" ]; then
version=${PS56_VER}
release=${PS56_VER#*-}
revision=${PS56_REV}
elif [ "$1" = "ps57" ]; then
version=${PS57_VER}
release=${PS57_VER#*-}
revision=${PS57_REV}
elif [ "$1" = "ps80" ]; then
if [ "$2" = "pro" ]; then
version=${PS80_PRO_VER}
release=${PS80_PRO_VER#*-}
revision=${PS80_PRO_REV}
else
version=${PS80_VER}
release=${PS80_VER#*-}
revision=${PS80_REV}
fi
elif [ "$1" = "ps84" ]; then
if [ "$2" = "pro" ]; then
version=${PS84_PRO_VER}
release=${PS84_PRO_VER#*-}
revision=${PS84_PRO_REV}
else
version=${PS84_VER}
release=${PS84_VER#*-}
revision=${PS84_REV}
fi
elif [[ $1 =~ ^ps8[1-9]{1}$ ]]; then
version=${PS_INN_LTS_VER}
release=${PS_INN_LTS_VER#*-}
revision=${PS_INN_LTS_REV}
elif [ "$1" = "pxc56" ]; then
version=${PXC56_VER%-*}
release=${PXC56_VER#*-}
revision=${PXC56_REV}
innodb_ver=${PXC56_INNODB}
wsrep=${PXC56_WSREP}
elif [ "$1" = "pxc57" ]; then
version=${PXC57_VER%-*}
release=${PXC57_VER#*-}
revision=${PXC57_REV}
innodb_ver=${PXC57_INNODB}
wsrep=${PXC57_WSREP}
elif [ "$1" = "pxc80" ]; then
version=${PXC80_VER%-*}
release=${PXC80_VER#*-}
revision=${PXC80_REV}
innodb_ver=${PXC80_INNODB}
wsrep=${PXC80_WSREP}
elif [ "$1" = "pxc84" ]; then
version=${PXC84_VER%-*}
release=${PXC84_VER#*-}
revision=${PXC84_REV}
innodb_ver=${PXC84_INNODB}
wsrep=${PXC84_WSREP}
elif [[ "$1" =~ ^pxc8[5-9]{1}$ ]]; then
version=${PXC_INN_LTS_VER%-*}
release=${PXC_INN_LTS_VER#*-}
revision=${PXC_INN_LTS_REV}
innodb_ver=${PXC_INN_LTS_INNODB}
wsrep=${PXC_INN_LTS_WSREP}
elif [ "$1" = "pt" ]; then
version=${PT_VER}
elif [ "$1" = "pxb23" ]; then
version=${PXB23_VER}
elif [ "$1" = "pxb24" ]; then
version=${PXB24_VER}
elif [ "$1" = "pxb80" ]; then
version=${PXB80_VER}
elif [ "$1" = "pxb81" ]; then
version=${PXB81_VER}
elif [[ $1 = "pxb84" ]]; then
version=${PXB84_VER}
elif [[ $1 = "pxb84" ]]; then
version=${PXB84_PRO_VER}
pkg_version=${PXB84_PRO_PKG_VER}
elif [[ $1 =~ ^pxb9([2-35-9])$ ]]; then
version=${PXB_INN_LTS_VER}
elif [ "$1" = "pmm" ]; then
version=${PMM_VER}
elif [ "$1" = "pmm2" ]; then
version=${PMM2_VER}
elif [ "$1" = "pmm2-rc" ]; then
version=${PMM2_RC_VER}
elif [ "$1" = "proxysql" ]; then
version=${PROXYSQL_VER}
elif [ "$1" = "proxysql2" ]; then
version=${PROXYSQL2_VER}
elif [ "$1" = "sysbench" ]; then
version=${SYSBENCH_VER}
elif [ "$1" = "pbm" ]; then
version=${PBM_VER}
revision=${PBM_REV}
elif [ "$1" = "psmdb34" ]; then
version=${PSMDB34_VER}
elif [ "$1" = "psmdb36" ]; then
version=${PSMDB36_VER}
elif [ "$1" = "psmdb40" ]; then
version=${PSMDB40_VER}
elif [ "$1" = "psmdb42" ]; then
version=${PSMDB42_VER}
elif [ "$1" = "psmdb44" ]; then
version=${PSMDB44_VER}
elif [ "$1" = "psmdb50" ]; then
version=${PSMDB50_VER}
else
echo "Illegal product selected!"
exit 1
fi
product=$1
log="/tmp/${product}_version_check.log"
echo -n > "${log}"
if [[ ${product} = "ps56" || ${product} = "ps57" ]] || [[ ${product} =~ ^ps8[0-9]{1}$ ]]; then
for i in @@INNODB_VERSION @@VERSION; do
if [ "$(mysql -e "SELECT ${i}; "| grep -c "${version}")" = 1 ]; then
echo "${i} is correct" >> "${log}"
else
echo "${i} is incorrect it shows $(mysql -e "SELECT ${i};")"
exit 1
fi
done
if [ "${product}" = "ps56" -o "${product}" = "ps57" ]; then
if [ "$(mysql -e "SELECT @@TOKUDB_VERSION; "| grep -c "${version}")" = 1 ]; then
echo "@@TOKUDB_VERSION is correct" >> "${log}"
else
echo "@@TOKUDB_VERSION is incorrect it shows $(mysql -e "SELECT @@TOKUDB_VERSION;")"
fi
fi
if [ "$(mysql -e "SELECT @@VERSION_COMMENT;" | grep ${revision} | grep -c ${release})" = 1 ]; then
echo "@@VERSION COMMENT is correct" >> "${log}"
else
echo "@@VERSION_COMMENT is incorrect. Server comment is: $(mysql -e "SELECT @@VERSION_COMMENT;") . VERSION's revision is ${revision}. VERSION's release is ${release}"
exit 1
fi
if [ "${pro}" = 'yes' ]; then
if [ "$(mysql -e "SELECT @@VERSION_COMMENT;" | grep -c 'Percona Server Pro (GPL)')" = 1 ]; then
echo "@@VERSION COMMENT is correct with Pro" >> "${log}"
else
echo "@@VERSION_COMMENT is incorrect. Pro is missing. Server comment is: $(mysql -e "SELECT @@VERSION_COMMENT;") ."
exit 1
fi
if [ "$(mysql --version | grep -c 'Percona Server Pro (GPL)')" = 1 ]; then
echo "mysql --version is correct with Pro" >> "${log}"
else
echo "mysql --version is incorrect. Pro is missing. mysql --version: $(mysql --version) ."
exit 1
fi
fi
if [[ ${product} =~ ^ps8[0-9]{1}$ ]]; then
if [ -z ${install_mysql_shell} ] || [ ${install_mysql_shell} = "yes" ] ; then
if [ "$(mysqlsh --version | grep -c ${version})" = 1 ]; then
echo "mysql-shell version is correct" >> "${log}"
else
echo "ERROR: mysql-shell version is incorrect"
exit 1
fi
elif [ ${install_mysql_shell} = "no" ]; then
echo "MYSQL Shell check is disabled.." >> "${log}"
else
echo "Invalid input in ${install_mysql_shell} variable"
fi
fi
elif [[ ${product} = "pxc56" || ${product} = "pxc57" ]] || [[ ${product} =~ ^pxc8[0-9]{1}$ ]]; then
for i in @@INNODB_VERSION @@VERSION; do
if [ "$(mysql -e "SELECT ${i}; "| grep -c ${version}-${innodb_ver})" = 1 ]; then
echo "${i} is correct" >> "${log}"
else
echo "${i} is incorrect"
exit 1
fi
done
if [ "$(mysql -e "SELECT @@VERSION_COMMENT;" | grep ${revision} | grep rel${innodb_ver} | grep -c ${release})" = 1 ]; then
echo "@@VERSION COMMENT is correct" >> "${log}"
else
echo "@@VERSION_COMMENT is incorrect"
mysql -e "SELECT @@VERSION_COMMENT;"
exit 1
fi
if [ "$(mysql -e "SHOW STATUS LIKE 'wsrep_provider_version';" | grep -c ${wsrep})" = 1 ]; then
echo "wsrep_provider_version is correct" >> "${log}"
else
echo "wsrep_provider_version is incorrect"
exit 1
fi
elif [ ${product} = "pt" ]; then
for i in `cat /package-testing/pt`; do
version_check=$(${i} --version|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${i} version is not good!"
echo $(${i} --version)
exit 1
else
echo "${i} version is correct and ${version}" >> "${log}"
fi
done
elif [ ${product} = "pmm" ]; then
version_check=$(pmm-admin --version 2>&1|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
elif [ ${product} = "pmm2" -o ${product} = "pmm2-rc" ]; then
pmm-admin --version
version_check=$(pmm-admin --version 2>&1|grep -c "${version}")
actual_version=$(pmm-admin --version 2>&1|grep ^Version | awk -F ' ' '{print $2}')
if [ ${version_check} -eq 0 ]; then
echo "${product} version ${actual_version} is not good! Expected: ${version}" >&2;
exit 1
else
echo "${product} version is correct and ${version}"
fi
bash -xe ./check_pmm2_client_upgrade.sh ${version}
elif [[ "${product}" = "pxb24" ]] || [[ ${product} =~ ^pxb8[0-9]{1}$ ]]; then
for binary in xtrabackup xbstream xbcloud xbcrypt; do
version_check=$($binary --version 2>&1| grep -c "${version}")
installed_version=$($binary --version 2>&1|tail -1|awk '{print $3}')
if [ "${version_check}" -eq 0 ]; then
echo "${binary} version is incorrect! Expected version: ${version} Installed version: ${installed_version}"
exit 1
else
echo "${binary} version is correctly displayed as: ${version}" >> "${log}"
fi
done
if [ "${pro}" = 'yes' ]; then
if [ "$(xtrabackup --version 2>&1 | grep -c 'pro')" = 1 ]; then
echo "@@VERSION COMMENT is correct with Pro" >> "${log}"
else
echo "@@VERSION_COMMENT is incorrect. Pro is missing. Server comment is: $(xtrabackup --version 2>&1) ."
exit 1
fi
if [ "$(xtrabackup --version 2>&1 | grep -c 'pro')" = 1 ]; then
echo "xtrabackup --version 2>&1 is correct with Pro" >> "${log}"
else
echo "xtrabackup --version is incorrect. Pro is missing. xtrabackup --version 2>&1: $(xtrabackup --version 2>&1) ."
exit 1
fi
fi
elif [ ${product} = "proxysql" -o ${product} = "proxysql2" ]; then
# Define binaries lists depending on product.
# proxysql 1.X.X packages contain 'proxysql' and 'proxysql-admin' binaries.
# proxysql 2.X.X packages contain 'proxysql', 'proxysql-admin', 'percona-scheduler-admin' and 'pxc_scheduler_handler' binaries.
if [ ${product} = "proxysql" ]; then
binaries_list='proxysql proxysql-admin'
else
binaries_list='proxysql proxysql-admin percona-scheduler-admin pxc_scheduler_handler'
fi
# Check version of each binary.
for binary in ${binaries_list}; do
# proxysql and proxysql-admin/pxc_scheduler_handler have different formats of version output.
# proxysql 2.X.X-percona-X.X, proxysql-admin/pxc_scheduler_handler 2.X.X
if [ "${binary}" != "proxysql" ]; then
version=$(echo "${version}" | awk -F '-' '{print $1}')
fi
version_check=$(${binary} --version 2>&1|grep -c ${version})
installed_version=$(${binary} --version)
if [ ${version_check} -eq 0 ]; then
echo "${binary} version ${version} is not good!. Installed version: ${installed_version}"
exit 1
else
echo "${binary} version is correct and ${version}" >> "${log}"
fi
done
elif [ ${product} = "sysbench" ]; then
version_check=$(sysbench --version 2>&1|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
elif [ ${product} = "pbm" ]; then
agent_version_check=$(pbm-coordinator --version 2>&1|grep -oE "Version .*$"|grep -c ${version})
agent_revision_check=$(pbm-coordinator --version 2>&1|grep -oE "Commit .*$"|grep -c ${revision})
coordinator_version_check=$(pbm-coordinator --version 2>&1|grep -oE "Version .*$"|grep -c ${version})
coordinator_revision_check=$(pbm-coordinator --version 2>&1|grep -oE "Commit .*$"|grep -c ${revision})
control_version_check=$(pbmctl version 2>&1|grep -oE "Version .*$"|grep -c ${version})
control_revision_check=$(pbmctl version 2>&1|grep -oE "Commit .*$"|grep -c ${revision})
if [ ${agent_version_check} -eq 0 -o ${coordinator_version_check} -eq 0 -o ${control_version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
if [ ${agent_revision_check} -eq 0 -o ${coordinator_revision_check} -eq 0 -o ${control_revision_check} -eq 0 ]; then
echo "${product} revision is not good!"
exit 1
else
echo "${product} revision is correct and ${revision}" >> "${log}"
fi
elif [ ${product} = "psmdb34" -o ${product} = "psmdb36" -o ${product} = "psmdb40" -o ${product} = "psmdb42" -o ${product} = "psmdb44" ]; then
##PSMDB-544
declare -A new_bin_version=(["3.6"]="21" ["4.0"]="22" ["4.2"]="11" ["4.4"]="2")
ver="${version%-*}"; major_ver="${ver%.*}"; minor_ver="${ver##*.}"
binary=(mongo mongod mongos bsondump mongoexport mongofiles mongoimport mongorestore mongotop mongostat)
if (( $minor_ver >= "${new_bin_version[$major_ver]}" )); then
binary+=(mongobridge perconadecrypt)
fi
for binary in ${binary[@]}; do
binary_version_check=$(${binary} --version|head -n1|grep -c "${version}")
if [ ${binary_version_check} -eq 0 ]; then
echo "${product} version is not good for binary ${binary}!"
exit 1
fi
done
fi
echo "${product} versions are OK"