forked from jakolehm/docker-galera-mariadb-10.0
-
Notifications
You must be signed in to change notification settings - Fork 103
/
run-upgrades.sh
executable file
·40 lines (34 loc) · 1.29 KB
/
run-upgrades.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
#!/bin/bash
while true; do
if [[ ! -f /var/lib/mysql/sst_in_progress ]] && curl -sf -o /dev/null localhost:8080; then
break
fi
echo "$0: waiting for server to become available..."
sleep 10
done
version=$(mysql -sNe "SELECT VERSION();")
if [[ -z $version ]]; then
echo "$0: _-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^_"
echo "$0: = Could not login as root to determine MySQL version and run upgrades! ="
echo "$0: ------------------------------------------------------------------------"
exit 1
fi
FLAG=/var/lib/mysql/run-upgrades.flag
old_version=
if [[ -f $FLAG ]]; then
old_version=$(grep -v '#' $FLAG)
fi
if [[ -z $old_version ]]; then
echo -e "# Created by $0 on $(date)\n# DO NOT DELETE THIS FILE\n$version" > $FLAG
# Special case for 10.1 users upgrading to 10.2
if ! mysql -sNe "SHOW GRANTS FOR 'xtrabackup'@'localhost';" | grep -qF PROCESS; then
echo "$0: Granting PROCESS to xtrabackup user for old version."
mysql -e "GRANT PROCESS ON *.* TO 'xtrabackup'@'localhost'; FLUSH PRIVILEGES;"
fi
fi
if [[ -n $old_version ]] && [[ $version != $old_version ]]; then
echo -e "# Created by $0 on $(date)\n# DO NOT DELETE THIS FILE\n$version" > $FLAG
echo "$0: Detected old version ($old_version -> $version)"
echo "$0: Running mysql_upgrade..."
mysql_upgrade
fi