From 3f44efaa1706bb5795e5ee6ad6acb1778b16419b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sat, 7 Oct 2023 20:31:39 -0700 Subject: [PATCH] MDEV-33750: Make sure that datadir always has some value and exists Adapted from upstream commit 8171f9da87c but separated only the datadir section from the commit and wrote it in a way that does not trigger Shellcheck or English grammar nags. This check is intentionally not added to the preinst script as was done upstream in 30fb72ca6e2 as the preinst script will always create the data directory if missing, and thus checking for it right after the creation is moot. --- debian/mariadb-server.mariadb.init | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/debian/mariadb-server.mariadb.init b/debian/mariadb-server.mariadb.init index c1bb3d94e4b..d4d290b2e9a 100644 --- a/debian/mariadb-server.mariadb.init +++ b/debian/mariadb-server.mariadb.init @@ -91,20 +91,19 @@ sanity_checks() { # check for diskspace shortage datadir="$(mariadbd_get_param datadir)" - # If datadir location is not changed int configuration + # If datadir location is not customized in configuration # then it's not printed with /usr/sbin/mariadbd --print-defaults - # then we use 'sane' default. + # and this should fall back to a sane default value if [ -z "$datadir" ] then datadir="/var/lib/mysql" fi - # Check if there datadir location is available and - # fail if it's not - if [ ! -d "$datadir" ] + # Verify the datadir location exists + if [ ! -d "$datadir" ] && [ ! -L "$datadir" ] then - log_failure_msg "$0: ERROR: Can't locate MariaDB installation location $datadir" - echo "ERROR: Can't locate MariaDB installation location $datadir" | $ERR_LOGGER + log_failure_msg "$0: ERROR: Can't locate MariaDB data location at $datadir" + echo "ERROR: Can't locate MariaDB data location at $datadir" | $ERR_LOGGER exit 1 fi