root@web3:~# apt-get -y install mariadb-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: galera-4 libaio1 libdbd-mariadb-perl libdbi-perl libhtml-template-perl libmariadb3 libmysqlclient21 libreadline5 libterm-readkey-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat Suggested packages: libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test The following NEW packages will be installed: galera-4 libaio1 libdbd-mariadb-perl libdbi-perl libhtml-template-perl libmariadb3 libmysqlclient21 libreadline5 libterm-readkey-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat 0 upgraded, 17 newly installed, 0 to remove and 86 not upgraded. Need to get 29.1 MB of archives. After this operation, 229 MB of additional disk space will be used. Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libdbi-perl amd64 1.643-1 [730 kB] Get:1 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mysql-common all 1:10.5.5+maria~focal [3260 B] Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libreadline5 amd64 5.2+dfsg-3build3 [100 kB] Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libaio1 amd64 0.3.112-5 [7184 B] Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 socat amd64 1.7.3.3-2 [323 kB] Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient21 amd64 8.0.21-0ubuntu0.20.04.4 [1222 kB] Get:13 http://archive.ubuntu.com/ubuntu focal/universe amd64 libdbd-mariadb-perl amd64 1.11-3ubuntu2 [105 kB] Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB] Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 libterm-readkey-perl amd64 2.38-1build1 [24.6 kB] Get:3 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mariadb-common all 1:10.5.5+maria~focal [4196 B] Get:4 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 galera-4 amd64 26.4.5-focal [12.7 MB] Get:5 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 libmariadb3 amd64 1:10.5.5+maria~focal [147 kB] Get:6 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mariadb-client-core-10.5 amd64 1:10.5.5+maria~focal [774 kB] Get:10 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mariadb-client-10.5 amd64 1:10.5.5+maria~focal [1545 kB] Get:12 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mariadb-server-core-10.5 amd64 1:10.5.5+maria~focal [6950 kB] Get:16 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mariadb-server-10.5 amd64 1:10.5.5+maria~focal [4403 kB] Get:17 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal/main amd64 mariadb-server all 1:10.5.5+maria~focal [3212 B] Fetched 29.1 MB in 22s (1345 kB/s) perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory Preconfiguring packages ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /tmp/mariadb-server-10.5.config.p76BN4 configure ' '1>&2' #42#DEBUG# RUNNING /tmp/mariadb-server-10.5.config.p76BN4 configure 1>&2 # 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 db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' Selecting previously unselected package mysql-common. (Reading database ... 21166 files and directories currently installed.) Preparing to unpack .../00-mysql-common_1%3a10.5.5+maria~focal_all.deb ... Unpacking mysql-common (1:10.5.5+maria~focal) ... Selecting previously unselected package mariadb-common. Preparing to unpack .../01-mariadb-common_1%3a10.5.5+maria~focal_all.deb ... Unpacking mariadb-common (1:10.5.5+maria~focal) ... Selecting previously unselected package galera-4. Preparing to unpack .../02-galera-4_26.4.5-focal_amd64.deb ... Unpacking galera-4 (26.4.5-focal) ... Selecting previously unselected package libdbi-perl:amd64. Preparing to unpack .../03-libdbi-perl_1.643-1_amd64.deb ... Unpacking libdbi-perl:amd64 (1.643-1) ... Selecting previously unselected package libmariadb3:amd64. Preparing to unpack .../04-libmariadb3_1%3a10.5.5+maria~focal_amd64.deb ... Unpacking libmariadb3:amd64 (1:10.5.5+maria~focal) ... Selecting previously unselected package libreadline5:amd64. Preparing to unpack .../05-libreadline5_5.2+dfsg-3build3_amd64.deb ... Unpacking libreadline5:amd64 (5.2+dfsg-3build3) ... Selecting previously unselected package mariadb-client-core-10.5. Preparing to unpack .../06-mariadb-client-core-10.5_1%3a10.5.5+maria~focal_amd64.deb ... Unpacking mariadb-client-core-10.5 (1:10.5.5+maria~focal) ... Selecting previously unselected package mariadb-client-10.5. Preparing to unpack .../07-mariadb-client-10.5_1%3a10.5.5+maria~focal_amd64.deb ... Unpacking mariadb-client-10.5 (1:10.5.5+maria~focal) ... Selecting previously unselected package libaio1:amd64. Preparing to unpack .../08-libaio1_0.3.112-5_amd64.deb ... Unpacking libaio1:amd64 (0.3.112-5) ... Selecting previously unselected package mariadb-server-core-10.5. Preparing to unpack .../09-mariadb-server-core-10.5_1%3a10.5.5+maria~focal_amd64.deb ... Unpacking mariadb-server-core-10.5 (1:10.5.5+maria~focal) ... Selecting previously unselected package socat. Preparing to unpack .../10-socat_1.7.3.3-2_amd64.deb ... Unpacking socat (1.7.3.3-2) ... Setting up mysql-common (1:10.5.5+maria~focal) ... Setting up mariadb-common (1:10.5.5+maria~focal) ... Selecting previously unselected package mariadb-server-10.5. (Reading database ... 21595 files and directories currently installed.) Preparing to unpack .../0-mariadb-server-10.5_1%3a10.5.5+maria~focal_amd64.deb ... locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure ' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure 1>&2 # 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 db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst install' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst install 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin mysql_datadir=/var/lib/mysql + mysql_datadir=/var/lib/mysql mysql_upgradedir=/var/lib/mysql-upgrade + mysql_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 # is running! Another mariadbd in e.g. a different chroot is fine for us. stop_server() { # Return immediately if there are no mysql processes running # as there is no point in trying to shutdown in that case. if ! pgrep -x --ns $$ mariadbd > /dev/null; then return; fi # Compatibility with versions that ran 'mysqld' if ! pgrep -x --ns $$ mysqld > /dev/null; then return; fi set +e invoke-rc.d mariadb stop invoke-rc.d mysql stop # Backwards compatibility errno=$? set -e # systemctl could emit exit code 100=no init script (fresh install) if [ "$errno" != 0 -a "$errno" != 100 ]; then echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 echo "Stop it yourself and try again!" 1>&2 db_stop exit 1 fi } ################################ main() ########################## this_version=$MAJOR_VER + this_version=10.5 max_upgradeable_version=5.7 + 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 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" ] then break fi flag_version=$(echo "$flag" | sed 's/.*debian-\([0-9\.]\+\).flag/\1/') # Initialize value if empty if [ -z "$found_version" ] then found_version=$flag_version fi # Update value if now bigger then before if dpkg --compare-versions "$flag_version" '>>' "$found_version" then found_version=$flag_version fi done + for flag in $mysql_datadir/debian-*.flag + '[' '/var/lib/mysql/debian-*.flag' = '/var/lib/mysql/debian-*.flag' ']' + break # If an upgrade is detected, proceed with it automatically without # requiring any user interaction. # # However, if the user attempts to downgrade, warn about the incompatibility. # Downgrade is detected if the flag version is bigger than $this_version # (e.g. 10.1 > 10.0) or the flag version is smaller than 10.0 but bigger # than $max_upgradeable_version. 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" then downgrade_detected=true fi if dpkg --compare-versions "$found_version" '>>' "$max_upgradeable_version" \ && dpkg --compare-versions "$found_version" '<<' "10.0" then downgrade_detected=true fi fi + '[' '!' -z '' ']' # Don't abort dpkg if downgrade is detected (as was done previously). # Instead simply move the old datadir and create a new for this_version. if [ ! -z "$downgrade_detected" ] then 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" # 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" fi + '[' '!' -z '' ']' # to be sure stop_server + stop_server + pgrep -x --ns 3840 mariadbd + return # 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 set +e fi ++ which ypwhich + test -n '' # # Now we have to ensure the following state: # /etc/passwd: mysql:x:100:101:MySQL Server:/nonexistent:/bin/false # /etc/group: mysql:x:101: # # Sadly there could any state be present on the system so we have to # modify everything carefully i.e. not doing a chown before creating # the user etc... # # creating mysql group if he isn't already there if ! getent group mysql >/dev/null; then # Adding system group: mysql. addgroup --system mysql >/dev/null fi + getent group mysql + addgroup --system mysql # creating mysql user if he isn't already there if ! getent passwd mysql >/dev/null; then # Adding system user: mysql. adduser \ --system \ --disabled-login \ --ingroup mysql \ --no-create-home \ --home /nonexistent \ --gecos "MySQL Server" \ --shell /bin/false \ mysql >/dev/null fi + getent passwd mysql + adduser --system --disabled-login --ingroup mysql --no-create-home --home /nonexistent --gecos 'MySQL Server' --shell /bin/false mysql # end of NIS tolerance zone set -e + 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 # Use mkdir option 'Z' to create with correct SELinux context. mkdir -pZ "$mysql_upgradedir" cp -dT "$checkdir" "$mysql_upgradedir/$dir.link" fi done + for dir in DATADIR LOGDIR ++ eval echo '$DATADIR' +++ echo + checkdir= + '[' -L '' ']' + for dir in DATADIR LOGDIR ++ eval echo '$LOGDIR' +++ echo + checkdir= + '[' -L '' ']' # creating mysql home directory if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then # Use mkdir option 'Z' to create with correct SELinux context. mkdir -Z $mysql_datadir fi + '[' '!' -d /var/lib/mysql ']' + '[' '!' -L /var/lib/mysql ']' + mkdir -Z /var/lib/mysql # checking disc space if LC_ALL=C BLOCKSIZE= df --portability $mysql_datadir/. | tail -n 1 | awk '{ exit ($4>1000) }'; then echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2 db_stop exit 1 fi + LC_ALL=C + BLOCKSIZE= + df --portability /var/lib/mysql/. + tail -n 1 + awk '{ exit ($4>1000) }' # Since the home directory was created before putting the user into # the mysql group and moreover we cannot guarantee that the # permissions were correctly *before* calling this script, we fix them now. # In case we use NIS and no mysql user is present then this script should # better fail now than later.. # The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is # not chgrp'able (#318435). set +e + set +e find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql + xargs -0 -r chown mysql ++ id -u mysql + find /var/lib/mysql '!' -uid 110 -print0 find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \ | xargs -0 --no-run-if-empty chgrp mysql + xargs -0 --no-run-if-empty chgrp mysql + find /var/lib/mysql -follow -not -group mysql -print0 set -e + set -e db_stop + db_stop + echo STOP Unpacking mariadb-server-10.5 (1:10.5.5+maria~focal) ... Selecting previously unselected package libmysqlclient21:amd64. Preparing to unpack .../1-libmysqlclient21_8.0.21-0ubuntu0.20.04.4_amd64.deb ... Unpacking libmysqlclient21:amd64 (8.0.21-0ubuntu0.20.04.4) ... Selecting previously unselected package libdbd-mariadb-perl. Preparing to unpack .../2-libdbd-mariadb-perl_1.11-3ubuntu2_amd64.deb ... Unpacking libdbd-mariadb-perl (1.11-3ubuntu2) ... Selecting previously unselected package libhtml-template-perl. Preparing to unpack .../3-libhtml-template-perl_2.97-1_all.deb ... Unpacking libhtml-template-perl (2.97-1) ... Selecting previously unselected package libterm-readkey-perl. Preparing to unpack .../4-libterm-readkey-perl_2.38-1build1_amd64.deb ... Unpacking libterm-readkey-perl (2.38-1build1) ... Selecting previously unselected package mariadb-server. Preparing to unpack .../5-mariadb-server_1%3a10.5.5+maria~focal_all.deb ... Unpacking mariadb-server (1:10.5.5+maria~focal) ... Setting up galera-4 (26.4.5-focal) ... Setting up libmysqlclient21:amd64 (8.0.21-0ubuntu0.20.04.4) ... Setting up libreadline5:amd64 (5.2+dfsg-3build3) ... Setting up libhtml-template-perl (2.97-1) ... Setting up socat (1.7.3.3-2) ... Setting up libmariadb3:amd64 (1:10.5.5+maria~focal) ... Setting up libterm-readkey-perl (2.38-1build1) ... Setting up libaio1:amd64 (0.3.112-5) ... Setting up libdbi-perl:amd64 (1.643-1) ... Setting up mariadb-server-core-10.5 (1:10.5.5+maria~focal) ... Setting up libdbd-mariadb-perl (1.11-3ubuntu2) ... Setting up mariadb-client-core-10.5 (1:10.5.5+maria~focal) ... Setting up mariadb-client-10.5 (1:10.5.5+maria~focal) ... Setting up mariadb-server-10.5 (1:10.5.5+maria~focal) ... locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure ' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure 1>&2 # 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 db_input high mariadb-server-10.0/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst configure ' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst configure 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin # This command can be used as pipe to syslog. With "-s" it also logs to stderr. ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i" + ERR_LOGGER='logger -p daemon.err -t mariadb-server-10.5.postinst -i' # Specify syslog tag name so it is clear the entry came from this postinst script. # This will make an error in a logged command immediately apparent by aborting # the install, rather than failing silently and leaving a broken install. set -o pipefail + set -o pipefail case "$1" in configure) # This is needed because mysql_install_db removes the pid file in /run # and because changed configuration options should take effect immediately. # In case the server wasn't running at all it should be ok if the stop # script fails. I can't tell at this point because of the cleaned /run. set +e; invoke-rc.d mariadb stop; set -e # An existing /etc/init.d/mysql might be on the system if there was a # previous MySQL or MariaDB installation, since /etc/init.d files are # considered config files and stay around even after the package is removed. # # The install step of this package adds a new /etc/init.d/mariadb file. As # we also want to ensure that there are no old (and potentially outdated) # versions of /etc/init.d/mysql we simply replace it using a copy of the # latest 'mariadb' file. This has also the added benefit that anything that # invokes traditional sysv init with either 'mysql' or 'mariadb' will end up # controlling this newly installed MariaDB, and thus we maintain better # backwards compatiblity. # # Note that the 'Provides' line is also updated to avoid 'insserv' exiting # on failure (when it is run by update-rc.d) because of duplicate service # names. if [ -f "/etc/init.d/mysql" ] && [ -f "/etc/init.d/mariadb" ] then # Copy init file and rename the service name and filename on the fly sed 's/Provides: mariadb/Provides: mysql/g' /etc/init.d/mariadb > /etc/init.d/mysql # NOTE: Number of spaces/tabs is important here! # Confirm if the sed worked if ! grep --quiet "Provides: mysql" /etc/init.d/mysql then # If not, then delete the file to avoid failures later on rm -f /etc/init.d/mysql echo "Warning! Failed creating a mysql named copy of mariadb init.d file" fi fi mysql_statedir=/usr/share/mysql mysql_datadir=/var/lib/mysql mysql_logdir=/var/log/mysql mysql_cfgdir=/etc/mysql mysql_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 # been replaced by an empty mysql dir. This should restore it. for dir in DATADIR LOGDIR; do if [ "$dir" = "DATADIR" ]; then targetdir=$mysql_datadir else targetdir=$mysql_logdir fi savelink="$mysql_upgradedir/$dir.link" if [ -L "$savelink" ]; then # If the targetdir was a symlink before we upgraded it is supposed # to be either still be present or not existing anymore now. if [ -L "$targetdir" ]; then rm "$savelink" elif [ ! -d "$targetdir" ]; then 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" 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 removed your symlink (see #182747 and others). The mysql packages noticed that this happened, and as a workaround have restored it. However, because /var/lib/mysql seems to have been re-created in the meantime, and because we don't want to rm -rf something we don't know as much about, we are going to leave this unexpected directory here. If your database looks normal, and this is not a symlink to your database, you should be able to blow this all away. EOF fi fi rmdir $mysql_upgradedir 2>/dev/null || true done # 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" ]; then mkdir -Z "$mysql_statedir"; fi if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]; then mkdir -Z "$mysql_datadir" ; fi if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]; then mkdir -Z "$mysql_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 modifyable by chown. # The mysql_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 set -e ## Set the correct filesystem ownership for the PAM v2 plugin # eg. /usr/lib/x86_64-linux-gnu/mysql/plugin/auth_pam_tool_dir/ # NOTE! This is security sensitive, don't allow for a race condition. # # 1. Drop privileges of directory # -> At this point only root can see and execute auth_pam_tool chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir # # 2. Make binary setuid # -> At this point only root can run the setuid binary so no escalation here yet chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool # # 3. Allow user 'mysql' to see and execute auth_pam_tool # -> Now user mysql owns the directory and can see and execute the binary inside # -> Since the binary is setuid, user mysql gets limited root powers here to # run the PAM authetications, which need root (e.g. to validate passwords # against /etc/shadow) 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 # data directory and then somewhen 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 # Flag data dir to avoid downgrades touch "$mysql_datadir/debian-$MAJOR_VER.flag" # initiate databases. Output is not allowed by debconf :-( # This will fail if we are upgrading an existing database; in this case # mysql_upgrade, called from the /etc/init.d/mariadb start script, will # handle things. # Debian: beware of the bashisms... # Debian: can safely run on upgrades with existing databases set +e bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql \ --disable-log-bin --skip-test-db 2>&1 | \ $ERR_LOGGER set -e # To avoid downgrades. touch "$mysql_statedir/debian-$MAJOR_VER.flag" # On new installations root user can connect via unix_socket. # But on upgrades, scripts rely on debian-sys-maint user and # credentials in /etc/mysql/debian.cnf # All tools use --defaults-file=/etc/mysql/debian.cnf # And while it's not needed for new installations, we keep using # --defaults-file option for tools (for the sake of upgrades) # and thus need /etc/mysql/debian.cnf to exist, even if it's empty. dc=$mysql_cfgdir/debian.cnf; if [ ! -d "$mysql_cfgdir" ]; then install -o 0 -g 0 -m 0755 -d $mysql_cfgdir fi if [ ! -e "$dc" ]; then cat /dev/null > $dc echo "# Automatically generated for Debian scripts. DO NOT TOUCH!" >>$dc fi # Keep it only root-readable, as it always was chown 0:0 $dc chmod 0600 $dc # If there is a real AppArmor profile, we reload it. # If the default empty profile is installed, then we remove any old # profile that may be loaded. # This allows upgrade from old versions (that have an apparmor profile # on by default) to work both to disable a default profile, and to keep # any profile installed and maintained by users themselves. profile="/etc/apparmor.d/usr.sbin.mariadbd" if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then apparmor_parser -r "$profile" || true else echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true fi fi # @TODO: Remove once buildbot.askmonty.org has been updated not to expect this file mkdir -p /etc/systemd/system/mariadb.service.d/ # Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic # will think the service is masked echo "# empty placeholder" > /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf ;; abort-upgrade|abort-remove|abort-configure) ;; triggered) if [ -x "$(command -v systemctl)" ]; then systemctl daemon-reload else invoke-rc.d mariadb restart fi ;; *) echo "postinst called with unknown argument '$1'" 1>&2 exit 1 ;; esac + case "$1" in + set +e + invoke-rc.d mariadb stop + set -e + '[' -f /etc/init.d/mysql ']' + mysql_statedir=/usr/share/mysql + mysql_datadir=/var/lib/mysql + mysql_logdir=/var/log/mysql + mysql_cfgdir=/etc/mysql + mysql_upgradedir=/var/lib/mysql-upgrade + for dir in DATADIR LOGDIR + '[' DATADIR = DATADIR ']' + targetdir=/var/lib/mysql + savelink=/var/lib/mysql-upgrade/DATADIR.link + '[' -L /var/lib/mysql-upgrade/DATADIR.link ']' + rmdir /var/lib/mysql-upgrade + for dir in DATADIR LOGDIR + '[' LOGDIR = DATADIR ']' + targetdir=/var/log/mysql + savelink=/var/lib/mysql-upgrade/LOGDIR.link + '[' -L /var/lib/mysql-upgrade/LOGDIR.link ']' + rmdir /var/lib/mysql-upgrade + true + '[' '!' -d /usr/share/mysql ']' + '[' '!' -d /var/lib/mysql ']' + '[' '!' -d /var/log/mysql ']' + '[' '!' -L /var/log/mysql ']' + mkdir -Z /var/log/mysql + set +e + chown -R 0:0 /usr/share/mysql + xargs -0 -r chown mysql ++ id -u mysql + find /var/lib/mysql '!' -uid 110 -print0 + chown -R mysql:adm /var/log/mysql + chmod 2750 /var/log/mysql + set -e + chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir + chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool + chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir + db_set mariadb-server/postrm_remove_database false + _db_cmd 'SET mariadb-server/postrm_remove_database' false + _db_internal_IFS=' ' + IFS=' ' + printf '%s\n' 'SET mariadb-server/postrm_remove_database false' + IFS=' ' + read -r _db_internal_line + IFS=' ' + RET='10 mariadb-server/postrm_remove_database doesn'\''t exist' + case ${_db_internal_line%%[ ]*} in + return 10 + true + rm -f '/var/lib/mysql/debian-*.flag' + touch /var/lib/mysql/debian-10.5.flag + set +e + logger -p daemon.err -t mariadb-server-10.5.postinst -i + bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql --disable-log-bin --skip-test-db + set -e + touch /usr/share/mysql/debian-10.5.flag + dc=/etc/mysql/debian.cnf + '[' '!' -d /etc/mysql ']' + '[' '!' -e /etc/mysql/debian.cnf ']' + cat /dev/null + echo '# Automatically generated for Debian scripts. DO NOT TOUCH!' + chown 0:0 /etc/mysql/debian.cnf + chmod 0600 /etc/mysql/debian.cnf + profile=/etc/apparmor.d/usr.sbin.mariadbd + '[' -f /etc/apparmor.d/usr.sbin.mariadbd ']' + aa-status --enabled + mkdir -p /etc/systemd/system/mariadb.service.d/ + echo '# empty placeholder' db_stop # in case invoke failes + db_stop + echo STOP # dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mariadb. # Thus MariaDB server is started via init.d script, which in turn redirects to # systemctl. If we upgrade from MySQL mysql.service may be masked, which also # means init.d script is disabled. Unmask mysql service explicitly. # Check first that the command exists, to avoid emitting any warning messages. if [ -x "$(command -v deb-systemd-helper)" ]; then deb-systemd-helper unmask mysql.service > /dev/null fi ++ command -v deb-systemd-helper + '[' -x /usr/bin/deb-systemd-helper ']' + deb-systemd-helper unmask mysql.service # Automatically added by dh_systemd_enable/12.10ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'mariadb.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi fi + '[' configure = configure ']' + deb-systemd-helper unmask mariadb.service + deb-systemd-helper --quiet was-enabled mariadb.service + deb-systemd-helper enable mariadb.service Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service. # End automatically added section # Automatically added by dh_systemd_enable/12.10ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'mariadb.service'; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'mariadb.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi + '[' configure = configure ']' + deb-systemd-helper debian-installed mariadb.service + deb-systemd-helper unmask mariadb.service + deb-systemd-helper --quiet was-enabled mariadb.service + deb-systemd-helper enable mariadb.service + deb-systemd-helper update-state mariadb.service # End automatically added section # Automatically added by dh_installinit/12.10ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/mariadb" ]; then update-rc.d mariadb defaults 19 21 >/dev/null || exit 1 fi fi + '[' configure = configure ']' + '[' -x /etc/init.d/mariadb ']' + update-rc.d mariadb defaults 19 21 # End automatically added section # Modified dh_systemd_start snippet that's not added automatically if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke start mariadb.service >/dev/null || true # Modified dh_installinit snippet to only run with sysvinit elif [ -x "/etc/init.d/mariadb" ]; then if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then invoke-rc.d mariadb start || exit $? fi fi + '[' -d /run/systemd/system ']' + systemctl --system daemon-reload + deb-systemd-invoke start mariadb.service Setting up mariadb-server (1:10.5.5+maria~focal) ... Processing triggers for systemd (245.4-4ubuntu3) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9) ...