From: Daniel Black Date: Thu, 10 Sep 2026 00:59:56 +0000 (+1000) Subject: mariadb: init - check file versions X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=bc8c5e84c140449ea54fb29871f731aae25220f2;p=openwrt-packages.git mariadb: init - check file versions mariadb-upgrade has had its own upgrade version file in the datadir, called mysql_upgrade_info in <= 10.11 and mariadb_upgrade_info there after. The mariadb-install-db creates this file, and also the mariadb-upgrade executable creates this file also. This removes the need to maintain the .version info though this is used as a last check of the upgrade. Signed-off-by: Daniel Black --- diff --git a/utils/mariadb/files/mysqld.init b/utils/mariadb/files/mysqld.init index 587ce95bf..99c08dab0 100644 --- a/utils/mariadb/files/mysqld.init +++ b/utils/mariadb/files/mysqld.init @@ -146,8 +146,17 @@ start_service() { done # Migration from old versions + file_version='' + for f in mariadb_upgrade_info mysql_upgrade_info .version; do + if [ -f "$datadir"/$f ]; then + file_version=$(cat "$datadir/$f") + # removing trailing suffix + file_version=${file_version%%-*} + break + fi + done # shellcheck disable=SC2154 - if [ "$(cat "$datadir"/.version 2> /dev/null)" \!= "$version" ] && [ "$autoupgrade" -gt 0 ]; then + if [ "${file_version}" != "$version" ] && [ "$autoupgrade" -gt 0 ]; then # Check for correct owner local owner="$(stat --format %U:%G "$datadir" 2> /dev/null)" if [ -n "$owner" ] && [ "$owner" != "$my_user:$my_group" ]; then @@ -168,8 +177,7 @@ start_service() { exit 1 } # Upgrade the database - mysql_upgrade --upgrade-system-tables --socket=/tmp/mysql_upgrade.sock - echo "$version" > "$datadir"/.version + mariadb-upgrade --upgrade-system-tables --socket=/tmp/mysql_upgrade.sock # Stop the upgrade instance kill "$PID" i=0