diff --git a/debian/mariadb-server.postinst b/debian/mariadb-server.postinst index 298f551fdcf..b8090ee3d26 100644 --- a/debian/mariadb-server.postinst +++ b/debian/mariadb-server.postinst @@ -60,11 +60,11 @@ case "$1" in fi fi - mysql_statedir=/usr/share/mariadb - mysql_datadir=/var/lib/mysql - mysql_logdir=/var/log/mysql - mysql_cfgdir=/etc/mysql - mysql_upgradedir=/var/lib/mysql-upgrade + mariadb_statedir=/usr/share/mariadb + mariadb_datadir=/var/lib/mysql + mariadb_logdir=/var/log/mysql + mariadb_cfgdir=/etc/mysql + mariadb_upgradedir=/var/lib/mysql-upgrade # If the following symlink exists, it is a preserved copy the old data dir # created by the preinst script during a upgrade that would have otherwise @@ -74,12 +74,12 @@ case "$1" in if [ "$dir" = "DATADIR" ] then - targetdir=$mysql_datadir + targetdir=$mariadb_datadir else - targetdir=$mysql_logdir + targetdir=$mariadb_logdir fi - savelink="$mysql_upgradedir/$dir.link" + savelink="$mariadb_upgradedir/$dir.link" if [ -L "$savelink" ] then # If the targetdir was a symlink before we upgraded it is supposed @@ -92,10 +92,10 @@ case "$1" in mv "$savelink" "$targetdir" else # this should never even happen, but just in case... - mysql_tmp=$(mktemp -d -t mysql-symlink-restore-XXXXXX) - echo "this is very strange! see $mysql_tmp/README..." >&2 - mv "$targetdir" "$mysql_tmp" - cat << EOF > "$mysql_tmp/README" + mariadb_tmp=$(mktemp -d -t mariadb-symlink-restore-XXXXXX) + echo "this is very strange! see $mariadb_tmp/README..." >&2 + mv "$targetdir" "$mariadb_tmp" + cat << EOF > "$mariadb_tmp/README" If you're reading this, it's most likely because you had replaced /var/lib/mysql with a symlink, then upgraded to a new version of mysql, and then dpkg @@ -110,7 +110,7 @@ this all away. EOF fi fi - rmdir $mysql_upgradedir 2>/dev/null || true + rmdir $mariadb_upgradedir 2>/dev/null || true done @@ -122,10 +122,10 @@ EOF # This direct update is needed to enable an authentication mechanism to # perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we # skip innodb and set key-buffer-size to 0 as it isn't reused. - if [ -f "$mysql_datadir/auto.cnf" ] && - [ -f "$mysql_datadir/mysql/user.MYD" ] && - ! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null && - [ ! -f "$mysql_datadir/undo_001" ] + if [ -f "$mariadb_datadir/auto.cnf" ] && + [ -f "$mariadb_datadir/mysql/user.MYD" ] && + ! lsof -nt "$mariadb_datadir"/mysql/user.MYD > /dev/null && + [ ! -f "$mariadb_datadir/undo_001" ] then echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" | mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null @@ -133,27 +133,27 @@ EOF # Ensure the existence and right permissions for the database and # log files. Use mkdir option 'Z' to create with correct SELinux context. - if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ] + if [ ! -d "$mariadb_statedir" ] && [ ! -L "$mariadb_statedir" ] then - mkdir -Z "$mysql_statedir" + mkdir -Z "$mariadb_statedir" fi - if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ] + if [ ! -d "$mariadb_datadir" ] && [ ! -L "$mariadb_datadir" ] then - mkdir -Z "$mysql_datadir" + mkdir -Z "$mariadb_datadir" fi - if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ] + if [ ! -d "$mariadb_logdir" ] && [ ! -L "$mariadb_logdir" ] then - mkdir -Z "$mysql_logdir" + mkdir -Z "$mariadb_logdir" fi # When creating an ext3 jounal on an already mounted filesystem like e.g. # /var/lib/mysql, you get a .journal file that is not modifiable by chown. - # The mysql_statedir must not be writable by the mysql user under any + # The mariadb_statedir must not be writable by the mysql user under any # circumstances as it contains scripts that are executed by root. set +e - chown -R 0:0 $mysql_statedir - find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql - chown -R mysql:adm $mysql_logdir - chmod 2750 $mysql_logdir + chown -R 0:0 $mariadb_statedir + find $mariadb_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql + chown -R mysql:adm $mariadb_logdir + chmod 2750 $mariadb_logdir set -e ## Set the correct filesystem ownership for the PAM v2 plugin @@ -176,14 +176,14 @@ EOF chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir # This is important to avoid dataloss when there is a removed - # mysql-server version from Woody lying around which used the same + # mariadb-server version from Woody lying around which used the same # data directory and then somehow gets purged by the admin. db_set mariadb-server/postrm_remove_database false || true # Clean up old flags before setting new one - rm -f $mysql_datadir/debian-*.flag + rm -f $mariadb_datadir/debian-*.flag # Flag data dir to avoid downgrades - touch "$mysql_datadir/debian-__MARIADB_MAJOR_VER__.flag" + touch "$mariadb_datadir/debian-__MARIADB_MAJOR_VER__.flag" # initiate databases. Output is not allowed by debconf :-( # This will fail if we are upgrading an existing database; in this case @@ -205,10 +205,10 @@ EOF # --defaults-file option for tools (for the sake of upgrades) # and thus need /etc/mysql/debian.cnf to exist, even if it's empty. # In the long run the goal is to obsolete this file. - dc="$mysql_cfgdir/debian.cnf" - if [ ! -d "$mysql_cfgdir" ] + dc="$mariadb_cfgdir/debian.cnf" + if [ ! -d "$mariadb_cfgdir" ] then - install -o 0 -g 0 -m 0755 -d $mysql_cfgdir + install -o 0 -g 0 -m 0755 -d $mariadb_cfgdir fi if [ ! -e "$dc" ] then @@ -224,7 +224,7 @@ EOF echo "[client]"; echo "host = localhost"; echo "user = root"; - echo "[mysql_upgrade]"; + echo "[mariadb_upgrade]"; echo "host = localhost"; echo "user = root"; echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE."; diff --git a/debian/mariadb-server.preinst b/debian/mariadb-server.preinst index 418273bbb27..4796f6bd76b 100644 --- a/debian/mariadb-server.preinst +++ b/debian/mariadb-server.preinst @@ -26,8 +26,8 @@ fi ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin -mysql_datadir=/var/lib/mysql -mysql_upgradedir=/var/lib/mysql-upgrade +mariadb_datadir=/var/lib/mysql +mariadb_upgradedir=/var/lib/mysql-upgrade # Try to stop the server in a sane way. If it does not success let the admin # do it himself. No database directories should be removed while the server @@ -68,13 +68,13 @@ max_upgradeable_version=5.7 # Check if a flag file is found that indicates a previous MariaDB or MySQL # version was installed. If multiple flags are found, check which one was # the biggest version number. -for flag in "$mysql_datadir"/debian-*.flag +for flag in "$mariadb_datadir"/debian-*.flag do # The for loop leaves $flag as the query string if there are no results, # so the check below is needed to stop further processing when there are # no real results. - if [ "$flag" = "$mysql_datadir/debian-*.flag" ] + if [ "$flag" = "$mariadb_datadir/debian-*.flag" ] then break fi @@ -109,13 +109,13 @@ then # MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly # 'debian-5.7.flag', so in case '5.7' was encountered an extra check needs to # be done to see is there is a file called undo_001, which is a sign of 8.0. - if [ "$found_version" == "5.7" ] && [ -f "$mysql_datadir/undo_001" ] + if [ "$found_version" == "5.7" ] && [ -f "$mariadb_datadir/undo_001" ] then # Seems to be a 8.0, flag has wrongly 5.7 (know bug) found_version=8.0 fi - echo "$mysql_datadir: found previous version $found_version" + echo "$mariadb_datadir: found previous version $found_version" if dpkg --compare-versions "$found_version" '>>' "$this_version" then @@ -135,10 +135,10 @@ fi # installs), then that file is enough of additional indication to trigger the # move of the data directory. if [ -z "$found_version" ] && - [ -z "$(find $mysql_datadir/debian-*.flag 2> /dev/null)" ] && - [ -f "$mysql_datadir/undo_001" ] + [ -z "$(find $mariadb_datadir/debian-*.flag 2> /dev/null)" ] && + [ -f "$mariadb_datadir/undo_001" ] then - echo "$mysql_datadir: no server version flag found, assuming MySQL 8.0 data encountered" + echo "$mariadb_datadir: no server version flag found, assuming MySQL 8.0 data encountered" downgrade_detected=true found_version="previous" # Just use dummy name as we don't know real version fi @@ -149,12 +149,12 @@ if [ -n "$downgrade_detected" ] then db_input critical "mariadb-server/old_data_directory_saved" || true db_go - echo "The file $mysql_datadir/debian-$found_version.flag indicates a" 1>&2 + echo "The file $mariadb_datadir/debian-$found_version.flag indicates a" 1>&2 echo "version that cannot automatically be upgraded. Therefore the" 1>&2 - echo "previous data directory will be renamed to $mysql_datadir-$found_version and" 1>&2 - echo "a new data directory will be initialized at $mysql_datadir." 1>&2 + echo "previous data directory will be renamed to $mariadb_datadir-$found_version and" 1>&2 + echo "a new data directory will be initialized at $mariadb_datadir." 1>&2 echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2 - mv -f "$mysql_datadir" "$mysql_datadir-$found_version" + mv -f "$mariadb_datadir" "$mariadb_datadir-$found_version" # Also move away the old debian.cnf file that included credentials that are # no longer valid. If none existed, ignore error and let dpkg continue. mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" || true @@ -213,33 +213,33 @@ do checkdir=$(eval echo "$"$dir) if [ -L "$checkdir" ]; then # Use mkdir option 'Z' to create with correct SELinux context. - mkdir -pZ "$mysql_upgradedir" - cp -dT "$checkdir" "$mysql_upgradedir/$dir.link" + mkdir -pZ "$mariadb_upgradedir" + cp -dT "$checkdir" "$mariadb_upgradedir/$dir.link" fi done # creating mysql home directory -if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ] +if [ ! -d $mariadb_datadir ] && [ ! -L $mariadb_datadir ] then # Use mkdir option 'Z' to create with correct SELinux context. - mkdir -Z $mysql_datadir + mkdir -Z $mariadb_datadir fi # Check if MariaDB datadir is available if not fails. # There should be symlink or directory available or something will fail. -if [ -d "$mysql_datadir" ] || [ -L "$mysql_datadir" ] +if [ -d "$mariadb_datadir" ] || [ -L "$mariadb_datadir" ] then # As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024 # 4096 blocks is then lower than 4 MB - df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)" + df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mariadb_datadir" | tail -n 1)" if [ "$df_available_blocks" -lt "4096" ] then - echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2 + echo "ERROR: There's not enough space in $mariadb_datadir/" 1>&2 db_stop exit 1 fi else - echo "ERROR: There's no directory or symlink available: $mysql_datadir/" 1>&2 + echo "ERROR: There's no directory or symlink available: $mariadb_datadir/" 1>&2 db_stop exit 1 fi @@ -252,8 +252,8 @@ fi # The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is # not chgrp'able (#318435). set +e -find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql -find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \ +find $mariadb_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql +find $mariadb_datadir -follow -not -group mysql -print0 2>/dev/null \ | xargs -0 --no-run-if-empty chgrp mysql set -e