|
@@ -1,57 +1,69 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
-# This script validates and upgrades the MariaDB version to 10.5
|
|
|
|
|
|
|
+# This script validates and upgrades the MariaDB version
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
-# Variable&Function #
|
|
|
|
|
|
|
+# Variable & Function #
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
# Set MariaDB Target Version
|
|
# Set MariaDB Target Version
|
|
|
mariadb_v='10.11'
|
|
mariadb_v='10.11'
|
|
|
|
|
|
|
|
-# Load OS informations
|
|
|
|
|
-source /etc/os-release
|
|
|
|
|
-
|
|
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
-# Verifications #
|
|
|
|
|
|
|
+# Verifications #
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
-# Detect installed mariadb version
|
|
|
|
|
-IFS=' ' read -r -a mysql_v <<< $(mysqld -V)
|
|
|
|
|
-mysql_v=$(echo "${mysql_v[2]}" | cut -c1-4)
|
|
|
|
|
|
|
+# Detect installed MariaDB version
|
|
|
|
|
+mysql_v="$(mysqld -V | awk '{print $3}' | cut -d: -f1)"
|
|
|
|
|
|
|
|
-if [ "$mysql_v" = "$mariadb_v" ]; then
|
|
|
|
|
- echo "Version is already up to date, cancelling."
|
|
|
|
|
|
|
+if [ "${mysql_v%.*}" = "$mariadb_v" ]; then
|
|
|
|
|
+ echo "[ ! ] MariaDB version ($mariadb_v) is already up to date."
|
|
|
exit 0
|
|
exit 0
|
|
|
|
|
+else
|
|
|
|
|
+ echo "[ * ] Upgrading MariaDB version to ($mariadb_v)..."
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-#Get OS details
|
|
|
|
|
-os=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=')
|
|
|
|
|
|
|
+# Get OS details
|
|
|
|
|
+os="$(grep "^ID=" /etc/os-release | cut -d= -f2)"
|
|
|
codename="$(lsb_release -s -c)"
|
|
codename="$(lsb_release -s -c)"
|
|
|
-release="$(lsb_release -s -r)"
|
|
|
|
|
-RHOST='apt.hestiacp.com'
|
|
|
|
|
|
|
+
|
|
|
|
|
+case $(arch) in
|
|
|
|
|
+ x86_64)
|
|
|
|
|
+ arch="amd64"
|
|
|
|
|
+ ;;
|
|
|
|
|
+ aarch64)
|
|
|
|
|
+ arch="arm64"
|
|
|
|
|
+ ;;
|
|
|
|
|
+ *)
|
|
|
|
|
+ echo "[ ! ] Error: $(arch) is currently not supported!"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ ;;
|
|
|
|
|
+esac
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
-# Action #
|
|
|
|
|
|
|
+# Action #
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
-# Installing MariaDB repo
|
|
|
|
|
-apt="/etc/apt/sources.list.d/"
|
|
|
|
|
-echo "[ * ] MariaDB"
|
|
|
|
|
-echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/mariadb-keyring.gpg] https://dlm.mariadb.com/repo/mariadb-server/$mariadb_v/repo/$VERSION $codename main" > $apt/mariadb.list
|
|
|
|
|
|
|
+# Installing MariaDB repository
|
|
|
|
|
+apt="/etc/apt/sources.list.d"
|
|
|
|
|
+echo "[ * ] Installing MariaDB repository..."
|
|
|
|
|
+echo "deb [arch=$arch signed-by=/usr/share/keyrings/mariadb-keyring.gpg] https://dlm.mariadb.com/repo/mariadb-server/$mariadb_v/repo/$os $codename main" > $apt/mariadb.list
|
|
|
curl -s https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor | tee /usr/share/keyrings/mariadb-keyring.gpg > /dev/null 2>&1
|
|
curl -s https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor | tee /usr/share/keyrings/mariadb-keyring.gpg > /dev/null 2>&1
|
|
|
|
|
|
|
|
# Update repository
|
|
# Update repository
|
|
|
-echo "Update apt repository..."
|
|
|
|
|
|
|
+echo "[ * ] Update apt repository..."
|
|
|
apt update -qq > /dev/null 2>&1
|
|
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
|
|
|
|
|
|
|
+# Stop and uninstall old version
|
|
|
|
|
+echo "[ * ] Stop and remove old MariaDB Server (${mysql_v%.*})..."
|
|
|
|
|
+systemctl -q stop mariadb mysql 2> /dev/null
|
|
|
apt remove -qq mariadb-server -y > /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..."
|
|
|
|
|
|
|
+# Install new version and run upgrade
|
|
|
|
|
+echo "[ * ] Installing new MariaDB Server, start and run upgrade..."
|
|
|
apt install -qq mariadb-server -y
|
|
apt install -qq mariadb-server -y
|
|
|
-systemctl start mysql > /dev/null 2>&1
|
|
|
|
|
-mysql_upgrade
|
|
|
|
|
|
|
+update-rc.d mariadb defaults > /dev/null 2>&1
|
|
|
|
|
+systemctl -q daemon-reload
|
|
|
|
|
+systemctl -q enable mariadb
|
|
|
|
|
+systemctl -q start mariadb
|
|
|
|
|
+mariadb-upgrade
|