summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuukka Pasanen <tuukka.pasanen@ilmi.fi>2023-03-13 11:56:53 +0200
committerDaniel Black <daniel@mariadb.org>2023-03-27 16:28:48 +1100
commitfe32a4a5bb84afa0db4cf6fee5ce5f37dfa065ea (patch)
tree6b5c2cc475577e3ab1468dbc3d52a5694db6a9b9
parenta79abb6517f2fa68b48e61aa3354a0631e3a63f7 (diff)
downloadmariadb-git-fe32a4a5bb84afa0db4cf6fee5ce5f37dfa065ea.tar.gz
MDEV-30837: Remove usage of AWK from Debian init and postinst scripts
AWK in used in Debian SysV-init and postinst scripts to determine is there enough space starting MariaDB database or create new database to target destination. These AWK scripts can be rewrited to use pure SH or help using Coreutils which is mandatory for usage of MariaDB currently. Reasoning behind this is to get rid of one very less used dependency
-rw-r--r--debian/mariadb-server.mariadb.init5
-rw-r--r--debian/mariadb-server.preinst6
2 files changed, 8 insertions, 3 deletions
diff --git a/debian/mariadb-server.mariadb.init b/debian/mariadb-server.mariadb.init
index cc004179894..f4051d4b007 100644
--- a/debian/mariadb-server.mariadb.init
+++ b/debian/mariadb-server.mariadb.init
@@ -84,7 +84,10 @@ sanity_checks() {
# check for diskspace shortage
datadir=`mariadbd_get_param datadir`
- if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
+ # 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`
+ if [ "$df_available_blocks" -lt "4096" ]; then
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
exit 1
diff --git a/debian/mariadb-server.preinst b/debian/mariadb-server.preinst
index 755815eaeed..e2d8e670bbf 100644
--- a/debian/mariadb-server.preinst
+++ b/debian/mariadb-server.preinst
@@ -196,8 +196,10 @@ if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then
mkdir -Z $mysql_datadir
fi
-# checking disc space
-if LC_ALL=C BLOCKSIZE= df --portability $mysql_datadir/. | tail -n 1 | awk '{ exit ($4>1000) }'; then
+# 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`
+if [ "$df_available_blocks" -lt "4096" ]; then
echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2
db_stop
exit 1