@ -9,6 +9,14 @@
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
# Just kill the invalid insserv.conf.d directory without fallback
if [ -d "/etc/insserv.conf.d/mariadb/" ]; then
rm -rf "/etc/insserv.conf.d/mariadb/"
fi
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
@ -41,7 +49,7 @@ stop_server() {
################################ main() ##########################
this_version=10.5
this_version=$MAJOR_VER
max_upgradeable_version=5.7
# Check if a flag file is found that indicates a previous MariaDB or MySQL
@ -53,12 +61,12 @@ 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" = "$mysql_datadir/debian-*.flag" ]
then
break
fi
flag_version=`echo $flag | sed 's/.*debian-\([0-9\.]\+\).flag/\1/'`
flag_version=$(echo "$flag" | sed 's/.*debian-\([0-9\.]\+\).flag/\1/')
# Initialize value if empty
if [ -z "$found_version" ]
@ -85,6 +93,15 @@ done
if [ ! -z "$found_version" ]
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" ]
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"
if dpkg --compare-versions "$found_version" '>>' "$this_version"
@ -105,17 +122,17 @@ fi
# Instead simply move the old datadir and create a new for this_version.
if [ ! -z "$downgrade_detected" ]
then
db_input critical mariadb-server-10.5/old_data_directory_saved || true
db_input critical "mariadb-server-$MAJOR_VER/old_data_directory_saved" || true
db_go
echo "The file $mysql_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 "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2
mv -f $mysql_datadir $mysql_datadir-$found_version
mv -f " $mysql_datadir" " $mysql_datadir-$found_version"
# Also move away the old debian.cnf file that included credentials that are
# no longer valid
mv -f /etc/mysql/debian.cnf /etc/mysql/debian.cnf-$found_version
mv -f /etc/mysql/debian.cnf " /etc/mysql/debian.cnf-$found_version"
fi
# to be sure
@ -124,7 +141,7 @@ stop_server
# If we use NIS then errors should be tolerated. It's up to the
# user to ensure that the mysql user is correctly setup.
# Beware that there are two ypwhich one of them needs the 2>/dev/null!
if test -n "`which ypwhich 2>/dev/null` " && ypwhich >/dev/null 2>&1; then
if test -n "$(which ypwhich 2>/dev/null) " && ypwhich >/dev/null 2>&1; then
set +e
fi
@ -164,16 +181,18 @@ set -e
# if there's a symlink, let's store where it's pointing, because otherwise
# it's going to be lost in some situations
for dir in DATADIR LOGDIR; do
checkdir=`eval echo "$"$dir`
if [ -L "$checkdir" ]; then
mkdir -p "$mysql_upgradedir"
cp -dT "$checkdir" "$mysql_upgradedir/$dir.link"
fi
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"
fi
done
# creating mysql home directory
if [ ! -d $mysql_datadir -a ! -L $mysql_datadir ]; then
mkdir $mysql_datadir
if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then
# Use mkdir option 'Z' to create with correct SELinux context.
mkdir -Z $mysql_datadir
fi
# checking disc space
@ -191,7 +210,7 @@ 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 ! -uid " $(id -u mysql)" -print0 | xargs -0 -r chown mysql
find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \
| xargs -0 --no-run-if-empty chgrp mysql
set -e
@ -200,5 +219,3 @@ set -e
db_stop
#DEBHELPER#
exit 0