]> git.99rst.org Git - openwrt-packages.git/commitdiff
mariadb: init - check file versions
authorDaniel Black <redacted>
Thu, 10 Sep 2026 00:59:56 +0000 (10:59 +1000)
committerJosef Schlehofer <redacted>
Thu, 10 Sep 2026 08:20:50 +0000 (10:20 +0200)
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 <redacted>
utils/mariadb/files/mysqld.init

index 587ce95bfc7684908dfb48d0565cbcaaa03b3b44..99c08dab094f1d19f5dbe10b5043e51ecee4d70a 100644 (file)
@@ -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
git clone https://git.99rst.org/PROJECT