From 8171f9da87c9e062b056834942634f04f39d5aea Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Wed, 7 Jun 2023 15:31:05 +0300 Subject: [PATCH] MDEV-31423: Make sure that datadir is available with SySV-init script Commit fixes Debian SySV-init script fail: /etc/init.d/mariadb: line 90: [: : integer expression expected which happens if datadir is not changed in configuration which makes it invisible when printing MariaDB config defaults. Commit makes sure that there is some value if nothing else if in hand use default /usr/lib/mysql or fail with correct error message if directory is not present --- debian/mariadb-server-10.6.mariadb.init | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/debian/mariadb-server-10.6.mariadb.init b/debian/mariadb-server-10.6.mariadb.init index f68fbc99bc2..4a41ed9758c 100644 --- a/debian/mariadb-server-10.6.mariadb.init +++ b/debian/mariadb-server-10.6.mariadb.init @@ -84,6 +84,24 @@ sanity_checks() { # check for diskspace shortage datadir=`mariadbd_get_param datadir` + + # If datadir location is not changed int configuration + # then it's not printed with /usr/sbin/mariadbd --print-defaults + # then we use 'sane' default. + 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" ] + then + log_failure_msg "$0: ERROR: Can't locate MariaDB installation location $datadir" + echo "ERROR: Can't locate MariaDB installation location $datadir" | $ERR_LOGGER + exit 1 + fi + # As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024 # 4096 blocks is then lower than 4 MB df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$datadir" | tail -n 1)"