forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupgrade_mariadb.sh
More file actions
58 lines (48 loc) · 1.97 KB
/
Copy pathupgrade_mariadb.sh
File metadata and controls
58 lines (48 loc) · 1.97 KB
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
#!/bin/bash
# This script validates and upgrades the MariaDB version to 10.4
# Set MariaDB Target Version
mariadb_v='10.4'
# Load OS informations
source /etc/os-release
# Detect installed mariadb version
IFS=' ' read -r -a mysql_v <<< $(mysqld -V)
mysql_v=$(echo "${mysql_v[2]}" | cut -c1-4)
if [ "$mysql_v" = "$mariadb_v" ]; then
echo "Version is already up to date, cancelling."
exit 0
fi
# Detect operating system and load codename
if [ "$ID" = "ubuntu" ]; then
codename="$(lsb_release -s -c)"
elif [ "$ID" = "debian" ]; then
codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
else
echo "Can't detect the os version, cancelling."
exit 1
fi
# Installing MariaDB repo
echo "Add new MariaDB repository..."
apt="/etc/apt/sources.list.d/"
if [ "$id" = "ubuntu" ]; then
echo "deb [arch=amd64] http://ams2.mirrors.digitalocean.com/mariadb/repo/$mariadb_v/$ID $codename main" > $apt/mariadb.list
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8 > /dev/null 2>&1
else
echo "deb [arch=amd64] http://ams2.mirrors.digitalocean.com/mariadb/repo/$mariadb_v/$ID $codename main" > $apt/mariadb.list
if [ "$id" -eq "jessie" ]; then
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key adv --recv-keys --keyserver keyserver.ubuntu.com CBCB082A1BB943DB > /dev/null 2>&1
else
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key adv --recv-keys --keyserver keyserver.ubuntu.com F1656F24C74CD1D8 > /dev/null 2>&1
fi
fi
# Update repository
echo "Update apt repository..."
apt update -qq > /dev/null 2>&1
# Stop and uninstall mysql server
echo "Stop and remove old MariaDB server..."
systemctl stop mysql > /dev/null 2>&1
apt remove -qq mariadb-server -y > /dev/null 2>&1
# Install new version and run upgrader
echo "Installing new MariaDB Server, start and run upgrade..."
apt install -qq mariadb-server -y > /dev/null 2>&1
systemctl start mysql > /dev/null 2>&1
mysql_upgrade