-
Notifications
You must be signed in to change notification settings - Fork 21
/
client_check.sh
executable file
·125 lines (113 loc) · 4.4 KB
/
client_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
#!/bin/bash
set -e
if [ "$#" -ne 1 ]; then
echo "This script requires product parameter: ps56, ps57, ps80, pxc56, pxc57 or pxc80 !"
echo "Usage: ./client_check.sh <prod>"
exit 1
fi
SCRIPT_PWD=$(cd "$(dirname "$0")" && pwd)
source "${SCRIPT_PWD}"/VERSIONS
if [ "$1" = "ps56" ]; then
deb_version="-5.6"
rpm_version="-56"
elif [ "$1" = "ps57" ]; then
deb_version="-5.7"
rpm_version="-57"
elif [ "$1" = "ps80" ]; then
deb_version=""
rpm_version=""
version=${PS80_VER}
elif [ "$1" = "ps84" ]; then
deb_version=""
rpm_version=""
version=${PS84_VER}
elif [ "$1" = "pxc56" ]; then
deb_version="-5.6"
rpm_version="-56"
elif [ "$1" = "pxc57" ]; then
deb_version="-5.7"
rpm_version="-57"
elif [ "$1" = "pxc80" ]; then
deb_version=""
rpm_version=""
elif [ "$1" = "pxc84" ]; then
deb_version=""
rpm_version=""
version=${PXC84_VER}
else
echo "Invalid product selected"
exit 1
fi
product=$1
log="/tmp/${product}_client_check.log"
echo -n > "${log}"
if [ -f /etc/redhat-release ] || [ -f /etc/system-release ]; then
if [ "${product}" = "ps56" ] || [ "${product}" = "ps57" ]; then
yum install -y Percona-Server-client${rpm_version}
elif ([ -z ${install_mysql_shell} ] && [ "${product}" = "ps80" ]) || [ "${product}" = "ps80" -a "${install_mysql_shell}" = "yes" ]; then
yum install -y percona-server-client percona-mysql-router percona-mysql-shell
elif [ "${product}" = "ps80" ] && [ "${install_mysql_shell}" = "no" ]; then
yum install -y percona-server-client percona-mysql-router
elif ([ -z ${install_mysql_shell} ] && [ "${product}" = "ps84" ]) || [ "${product}" = "ps84" -a "${install_mysql_shell}" = "yes" ]; then
yum install -y percona-server-client percona-mysql-router percona-mysql-shell
elif [ "${product}" = "ps84" ] && [ "${install_mysql_shell}" = "no" ]; then
yum install -y percona-server-client percona-mysql-router
elif [ "${product}" = "pxc56" ] || [ "${product}" = "pxc57" ]; then
yum install -y Percona-XtraDB-Cluster-client${rpm_version}
elif [ "${product}" = "pxc80" ] || [ "${product}" = "pxc84" ]; then
yum install -y percona-xtradb-cluster-client
else
echo "client version is incorrect"
exit 1
fi
else
if [ "${product}" = "ps56" ] || [ "${product}" = "ps57" ]; then
apt-get update; apt-get install -y percona-server-client${deb_version}
elif ([ -z ${install_mysql_shell} ] && [ "${product}" = "ps80" ]) || [ "${product}" = "ps80" -a "${install_mysql_shell}" = "yes" ]; then
apt-get update; apt-get install -y percona-server-client percona-mysql-router percona-mysql-shell
elif [ "${product}" = "ps80" ] && [ "${install_mysql_shell}" = "no" ]; then
apt-get update; apt-get install -y percona-server-client percona-mysql-router
elif ([ -z ${install_mysql_shell} ] && [ "${product}" = "ps84" ]) || [ "${product}" = "ps84" -a "${install_mysql_shell}" = "yes" ]; then
apt-get update; apt-get install -y percona-server-client percona-mysql-router percona-mysql-shell
elif [ "${product}" = "ps84" ] && [ "${install_mysql_shell}" = "no" ]; then
apt-get update; apt-get install -y percona-server-client percona-mysql-router
elif [ "${product}" = "pxc56" ] || [ "${product}" = "pxc57" ]; then
apt-get install -y percona-xtradb-cluster-client${deb_version}
elif [ "${product}" = "pxc80" ] || [ "${product}" = "pxc84" ]; then
apt-get update; apt-get install -y percona-xtradb-cluster-client
else
echo "client version is incorrect"
exit 1
fi
fi
if [ "${product}" = "ps80" || "${product}" = "ps84" ]; then
echo "checking client version"
if [ "$(mysql --version | grep -c "$version")" == 1 ]; then
echo "mysql client version is correct"
else
echo "ERROR: mysql-client version is incorrect "
exit 1
fi
if [ -z ${install_mysql_shell} ] || [ ${install_mysql_shell} = "yes" ] ; then
echo "checking shell version"
if [ "$(mysqlsh --version | grep -c "$version")" == 1 ]; then
echo "mysql shell version is correct"
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
echo "checking router version"
if [ "$(mysqlrouter --version | grep -c "$version")" == 1 ]; then
echo "mysql router version is correct"
else
echo "ERROR: mysqlrouter version is incorrect "
exit 1
fi
fi
mysql --help
echo $?