MDEV-33750: Make sure that datadir always has some value and exists

Adapted from upstream commit 8171f9da87 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 30fb72ca6e as the preinst script will always create the
data directory if missing, and thus checking for it right after the
creation is moot.
This commit is contained in:
Otto Kekäläinen 2023-10-07 20:31:39 -07:00 committed by Daniel Black
parent 2adaf5c261
commit 3f44efaa17

View file

@ -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