2020-04-07 12:10:03 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2012-01-23 12:20:16 +01:00
|
|
|
|
2023-03-29 12:42:12 +03:00
|
|
|
# shellcheck source=/dev/null
|
2016-10-09 23:39:01 +03:00
|
|
|
. /usr/share/debconf/confmodule
|
2012-01-23 12:20:16 +01:00
|
|
|
|
2023-03-30 13:58:54 +03:00
|
|
|
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
|
|
|
|
then
|
|
|
|
set -v -x
|
|
|
|
DEBIAN_SCRIPT_TRACE=1
|
|
|
|
fi
|
|
|
|
|
2012-01-23 12:20:16 +01:00
|
|
|
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
|
|
|
|
|
|
|
|
#
|
2020-04-07 12:10:03 +03:00
|
|
|
# - Purge logs and data only if they are ours (#307473)
|
2012-01-23 12:20:16 +01:00
|
|
|
# - Remove the mysql user only after all his owned files are purged.
|
2020-04-07 12:10:03 +03:00
|
|
|
# - Cleanup the initscripts only if this was the last provider of them
|
2016-10-09 23:39:01 +03:00
|
|
|
#
|
2023-05-11 09:24:59 +03:00
|
|
|
if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag" ]
|
2023-03-30 13:58:54 +03:00
|
|
|
then
|
2012-01-23 12:20:16 +01:00
|
|
|
# we remove the mysql user only after all his owned files are purged
|
|
|
|
rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz}
|
|
|
|
rm -rf /var/log/mysql
|
|
|
|
|
2022-04-30 23:27:39 -07:00
|
|
|
db_input high "mariadb-server/postrm_remove_databases" || true
|
2012-01-23 12:20:16 +01:00
|
|
|
db_go || true
|
2022-04-30 23:27:39 -07:00
|
|
|
db_get "mariadb-server/postrm_remove_databases" || true
|
2023-03-30 13:58:54 +03:00
|
|
|
if [ "$RET" = "true" ]
|
|
|
|
then
|
2012-01-23 12:20:16 +01:00
|
|
|
# never remove the debian.cnf when the databases are still existing
|
|
|
|
# else we ran into big trouble on the next install!
|
|
|
|
rm -f /etc/mysql/debian.cnf
|
2016-10-09 23:39:01 +03:00
|
|
|
# Remove all contents from /var/lib/mysql except if it's a
|
|
|
|
# directory with file system data. See #829491 for details and
|
|
|
|
# #608938 for potential mysql-server leftovers which erroneously
|
|
|
|
# had been renamed.
|
2020-04-07 12:10:03 +03:00
|
|
|
# Attempt removal only if the directory hasn't already been removed
|
|
|
|
# by dpkg to avoid failing on "No such file or directory" errors.
|
|
|
|
if [ -d /var/lib/mysql ]
|
|
|
|
then
|
|
|
|
find /var/lib/mysql -mindepth 1 \
|
2023-03-29 12:28:51 +03:00
|
|
|
-not -path '*/lost+found/*' -not -name 'lost+found' \
|
|
|
|
-not -path '*/lost@002bfound/*' -not -name 'lost@002bfound' \
|
|
|
|
-delete
|
2020-04-07 12:10:03 +03:00
|
|
|
|
|
|
|
# "|| true" still needed as rmdir still exits with non-zero if
|
|
|
|
# /var/lib/mysql is a mount point
|
|
|
|
rmdir --ignore-fail-on-non-empty /var/lib/mysql || true
|
|
|
|
fi
|
2020-04-26 10:41:21 +03:00
|
|
|
rm -rf /run/mysqld # this directory is created by the init script, don't leave behind
|
2012-01-23 12:20:16 +01:00
|
|
|
userdel mysql || true
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2016-10-09 23:39:01 +03:00
|
|
|
#DEBHELPER#
|
2020-04-22 00:48:14 +03:00
|
|
|
|
|
|
|
# Modified dh_systemd_start snippet that's not added automatically
|
2023-03-30 13:58:54 +03:00
|
|
|
if [ -d /run/systemd/system ]
|
|
|
|
then
|
2023-03-29 12:28:51 +03:00
|
|
|
systemctl --system daemon-reload >/dev/null || true
|
2020-04-22 00:48:14 +03:00
|
|
|
fi
|