Browse Source

mariadb: Check and fix datadir owner issues during upgrade

If you are migrating to MariaDB package, you might have old datadir
stored somewhere using different setup with different users. If you
trust us enough to enable autoupgrade, you probably trust us enough to
chown your datadir as well. This can prevent some potential issues.

Signed-off-by: Michal Hrusecky <michal.hrusecky@turris.com>
lilik-openwrt-22.03
Michal Hrusecky 3 years ago
parent
commit
b41525cef4
No known key found for this signature in database GPG Key ID: 7B7562FE6F4D91EF
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      utils/mariadb/files/mysqld.init

+ 6
- 0
utils/mariadb/files/mysqld.init View File

@ -152,6 +152,12 @@ start_service() {
# Migration from old versions
# shellcheck disable=SC2154
if [ "$(cat "$datadir"/.version 2> /dev/null)" \!= "$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
chown -Rh "$my_user:$my_group" "$datadir"
fi
# Start upgrade instance without credentials
sudo -u "$my_user" mysqld --skip-networking --skip-grant-tables --socket=/tmp/mysql_upgrade.sock &
PID="$!"


Loading…
Cancel
Save