Skip to content

Commit

Permalink
Merge branch 'release/v8.4.2-1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sklein94 authored and cesmarvin committed Nov 14, 2024
2 parents 2dba565 + 02b23f6 commit a702ff8
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v8.4.2-1] - 2024-11-14
### Changed
- Upgrade mysql to 8.4.2 (LTS)

## [v8.0.38-3] - 2024-09-18
### Changed
- Relicense to AGPL-3.0-only
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM registry.cloudogu.com/official/base-debian:12.6-1

LABEL MAINTAINER="[email protected]" \
NAME="official/mysql" \
VERSION="8.0.38-3"
VERSION="8.4.2-1"

ENV PATH="${PATH}:/var/lib/mysql/bin" \
MYSQL_VOLUME=/var/lib/mysql \
Expand Down
5 changes: 5 additions & 0 deletions docs/development/upgrade_test_de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Upgrade Tests

Um den Update-Mechanismus des Dogus testen zu können, kann/sollte das "itz-bund/easyredmine"-Dogu zusätzlich installiert werden.

Die von easyredmine erstellte Datenbank enthält mehrere Tabellen und bestimme Datenbank-Anwender und Schemata, die vom Upgradeskript extrahiert werden und in der neuen Version wieder importiert werden.
5 changes: 5 additions & 0 deletions docs/development/upgrade_test_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Upgrade Tests

In order to be able to test the Dogus update mechanism, the "itz-bund/easyredmine" Dogu can/should also be installed.

The database created by easyredmine contains several tables and certain database users and schemas, which are extracted by the upgrade script and reimported in the new version.
2 changes: 1 addition & 1 deletion dogu.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Name": "official/mysql",
"Version": "8.0.38-3",
"Version": "8.4.2-1",
"DisplayName": "MySQL",
"Description": "MySQL - Relational database",
"Url": "https://www.mysql.com/",
Expand Down
10 changes: 6 additions & 4 deletions installation-scripts/install-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
set -o errexit
set -o nounset
set -o pipefail
DEBIAN_SHA_256_SUM="a62bca0a0fd67e11fd5c8efde7e67e6e59255c3f0fa61ecc817fd99254b483ab"
VERSION="0.8.29-1"
DEBIAN_SHA_256_SUM="df9c563abd70bb9b2fb1be7d11868a300bd60023bcd60700f24430008059a704"
# Version of debian file containing the installation files for mysql in different versions
# This is NOT the actual mysql version to install
VERSION="0.8.32-1"
# see for latest version: https://dev.mysql.com/downloads/repo/apt/
wget "https://dev.mysql.com/get/mysql-apt-config_${VERSION}_all.deb"
echo "${DEBIAN_SHA_256_SUM} mysql-apt-config_${VERSION}_all.deb" | sha256sum -c -
# Select the correct mysql package
# 1. '1': Select the option to choose the mysql version
# 2. '1': Select mysql8.0
# 2. '3': Select mysql8.4-lts
# 3. 'ok': Finish configuration
dpkg -i "mysql-apt-config_${VERSION}_all.deb" <<EOF
1
1
3
ok
EOF
# https://repo.mysql.com/apt/ubuntu/conf/distributions
Expand Down
7 changes: 5 additions & 2 deletions resources/post-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function run_postupgrade() {
fi

if [[ -f "${WORKDIR}/var/lib/mysql/alldb.sql" ]]; then
restoreDump
restoreDump "${FROM_VERSION}" "${TO_VERSION}"
fi

echo "Set registry flag so startup script can start afterwards..."
Expand All @@ -24,6 +24,8 @@ function run_postupgrade() {
}

restoreDump() {
local FROM_VERSION="${1}"
local TO_VERSION="${2}"
while [[ ! -f "${DATABASE_CONFIG_DIR}/default-config.cnf" ]]; do
echo "Wait for preparations"
sleep 3
Expand All @@ -38,7 +40,8 @@ restoreDump() {
mysql -u root <"${WORKDIR}/alldb.sql"

echo "Cleanup db..."
rm -f "${WORKDIR}/var/lib/mysql/alldb.sql"
# keep Backup if something happens with during the migration
mv "${WORKDIR}/alldb.sql" "${WORKDIR}/var/lib/mysql/alldb_${FROM_VERSION}_to_${TO_VERSION}_$(date +%s).sql"

echo "Shutdown mysql"
mysqladmin shutdown
Expand Down
42 changes: 32 additions & 10 deletions resources/pre-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function run_preupgrade() {

function dumpData(){
TABLES="$(mysql -e "SELECT group_concat(schema_name) FROM information_schema.schemata WHERE schema_name NOT IN ('mysql', 'information_schema','performance_schema', 'sys');" | tail -n +2 | sed 's/,/ /g')"
if [[ $TABLES == "NULL" ]]; then
if [[ "${TABLES}" == "NULL" ]]; then
echo "TABLES are NULL. No available Data to DUMP."
rm -rf /var/lib/mysql/*
doguctl config --rm first_start_done
Expand All @@ -33,17 +33,39 @@ function dumpData(){
local USERS
USERS="$(mysql -uroot mysql -e "select GROUP_CONCAT(User) FROM user WHERE NOT User LIKE '%mysql.%' AND NOT User='root';" | tail -n +2 | sed 's/,/ /g')"

local user
for user in ${USERS}
do
local CREATE
CREATE="$(mysql --skip-column-names -A mysql -e "SET @@SESSION.print_identified_with_as_hex = 1; SHOW CREATE USER '${user}'")"
echo "${CREATE};" >> /alldb.sql
done
# as users may exists within the dump but need to be recreated with all privileges the user must be dropped first
# otherwise the creation would result in an ERROR 1396 (HY000) - see https://stackoverflow.com/a/6332971
if [[ "${USERS}" != "NULL" ]]; then
local user
for user in ${USERS}
do
echo "DROP user IF EXISTS '${user}';" >> /alldb.sql
done

echo "flush privileges;" >> /alldb.sql
# flush privileges just once instead of once per user
echo "flush privileges;" >> /alldb.sql

# recreate users
for user in ${USERS}
do
local CREATE
CREATE="$(mysql --skip-column-names -A mysql -e "SET @@SESSION.print_identified_with_as_hex = 1; SHOW CREATE USER '${user}'")"
echo "${CREATE};" >> /alldb.sql
done

echo "flush privileges;" >> /alldb.sql

local GRANT
GRANT="$(mysql --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql --skip-column-names -A | sed 's/$/;/g')"

# this is needed for any version from 8.4 and up
# SET_USER_ID Privilege was removed as deprecated
# https://dev.mysql.com/doc/refman/8.4/en/mysql-nutshell.html
GRANT=$(echo "${GRANT}" | sed 's/SET_USER_ID,/SET_ANY_DEFINER,ALLOW_NONEXISTENT_DEFINER,/g')

echo "${GRANT};" >> /alldb.sql
fi

mysql --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql --skip-column-names -A | sed 's/$/;/g' >> /alldb.sql
rm -rf /var/lib/mysql/*
doguctl config --rm first_start_done
mv /alldb.sql /var/lib/mysql/alldb.sql
Expand Down

0 comments on commit a702ff8

Please sign in to comment.