Skip to content

Commit f99a891

Browse files
illuusiogrooverdan
authored andcommitted
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
1 parent 5740638 commit f99a891

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

debian/mariadb-server-10.6.mariadb.init

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ sanity_checks() {
8484

8585
# check for diskspace shortage
8686
datadir=`mariadbd_get_param datadir`
87-
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
87+
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
88+
# 4096 blocks is then lower than 4 MB
89+
df_available_blocks=`LC_ALL=C BLOCKSIZE= df --output=avail "$datadir" | tail -n 1`
90+
if [ "$df_available_blocks" -lt "4096" ]; then
8891
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
8992
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
9093
exit 1

debian/mariadb-server-10.6.preinst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then
209209
mkdir -Z $mysql_datadir
210210
fi
211211

212-
# checking disc space
213-
if LC_ALL=C BLOCKSIZE= df --portability $mysql_datadir/. | tail -n 1 | awk '{ exit ($4>1000) }'; then
212+
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
213+
# 4096 blocks is then lower than 4 MB
214+
df_available_blocks=`LC_ALL=C BLOCKSIZE= df --output=avail "$datadir" | tail -n 1`
215+
if [ "$df_available_blocks" -lt "4096" ]; then
214216
echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2
215217
db_stop
216218
exit 1

0 commit comments

Comments
 (0)