summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuukka Pasanen <tuukka.pasanen@ilmi.fi>2023-03-29 12:42:12 +0300
committerDaniel Black <daniel@mariadb.org>2023-05-08 16:52:27 +1000
commit8febdfa3428c59e93be6a2d3a437706cd0233e3f (patch)
treea615e9becec795403c69588a4b9ca4ef8e975235
parent7cbb45d1d4b1a5e2d07b1c17c49a5ca797df8991 (diff)
downloadmariadb-git-8febdfa3428c59e93be6a2d3a437706cd0233e3f.tar.gz
MDEV-30952: Fix shellcheck problems on Debian scripts
Commit fixes several ShellCheck found problems in Debian Pre- and Postscripts. Debian script mariadb-server-10.6.postrm contains shellcheck Fixed problems are: https://www.shellcheck.net/wiki/SC2166 -- Prefer [ p ] && [ q ] as [ p -a q... https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le... https://www.shellcheck.net/wiki/SC1091 -- Not following: /usr/share/debconf... Debian script mariadb-server-10.6.postinst contains shellcheck Fixed problems are: https://www.shellcheck.net/wiki/SC2129 -- Consider using { cmd1; cmd2; } >>... https://www.shellcheck.net/wiki/SC1091 -- Not following: /usr/share/debconf... https://www.shellcheck.net/wiki/SC1072 -- Expected test to end here (don't ... https://www.shellcheck.net/wiki/SC1073 -- Couldn't parse this test expressi... https://www.shellcheck.net/wiki/SC1009 -- The mentioned syntax error was in... Debian script mariadb-server-10.6.preinst contains shellcheck Fixed problems are: https://www.shellcheck.net/wiki/SC2231 -- Quote expansions in this for loop... https://www.shellcheck.net/wiki/SC2166 -- Prefer [ p ] && [ q ] as [ p -a q... https://www.shellcheck.net/wiki/SC2001 -- See if you can use ${variable//se... https://www.shellcheck.net/wiki/SC1091 -- Not following: /usr/share/debconf... https://www.shellcheck.net/wiki/SC1007 -- Remove space after = if trying to...
-rw-r--r--debian/mariadb-server-10.6.postinst37
-rw-r--r--debian/mariadb-server-10.6.postrm5
-rw-r--r--debian/mariadb-server-10.6.preinst9
3 files changed, 29 insertions, 22 deletions
diff --git a/debian/mariadb-server-10.6.postinst b/debian/mariadb-server-10.6.postinst
index 1a83f38dd25..a994209ce11 100644
--- a/debian/mariadb-server-10.6.postinst
+++ b/debian/mariadb-server-10.6.postinst
@@ -1,6 +1,7 @@
#!/bin/bash
set -e
+# shellcheck source=/dev/null
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file
@@ -112,8 +113,10 @@ EOF
# This direct update is needed to enable an authentication mechanism to
# perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we
# skip innodb and set key-buffer-size to 0 as it isn't reused.
- if [ -f "$mysql_datadir"/auto.cnf ] && [ -f "$mysql_datadir"/mysql/user.MYD ] &&
- [ ! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null ] && [ ! -f "$mysql_datadir"/undo_001 ]; then
+ lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null
+ lsof_rtn_code=$?
+ if [ -f "$mysql_datadir/auto.cnf" ] && [ -f "$mysql_datadir/mysql/user.MYD" ] &&
+ [ ! ${lsof_rtn_code} ] && [ ! -f "$mysql_datadir/undo_001" ]; then
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" |
mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
fi
@@ -189,20 +192,22 @@ EOF
fi
if [ ! -e "$dc" ]; then
cat /dev/null > $dc
- echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE." >>$dc
- echo "# This file exists only for backwards compatibility for" >>$dc
- echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'" >>$dc
- echo "# and have root level access to the local filesystem." >>$dc
- echo "# With those permissions one can run 'mariadb' directly" >>$dc
- echo "# anyway thanks to unix socket authentication and hence" >>$dc
- echo "# this file is useless. See package README for more info." >>$dc
- echo "[client]" >>$dc
- echo "host = localhost" >>$dc
- echo "user = root" >>$dc
- echo "[mysql_upgrade]" >>$dc
- echo "host = localhost" >>$dc
- echo "user = root" >>$dc
- echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE." >>$dc
+ {
+ echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE.";
+ echo "# This file exists only for backwards compatibility for";
+ echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'";
+ echo "# and have root level access to the local filesystem.";
+ echo "# With those permissions one can run 'mariadb' directly";
+ echo "# anyway thanks to unix socket authentication and hence";
+ echo "# this file is useless. See package README for more info.";
+ echo "[client]";
+ echo "host = localhost";
+ echo "user = root";
+ echo "[mysql_upgrade]";
+ echo "host = localhost";
+ echo "user = root";
+ echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.";
+ } >> $dc
fi
# Keep it only root-readable, as it always was
chown 0:0 $dc
diff --git a/debian/mariadb-server-10.6.postrm b/debian/mariadb-server-10.6.postrm
index 82fffef4eae..0c847f19684 100644
--- a/debian/mariadb-server-10.6.postrm
+++ b/debian/mariadb-server-10.6.postrm
@@ -1,6 +1,7 @@
#!/bin/bash
set -e
+# shellcheck source=/dev/null
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file
@@ -26,7 +27,7 @@ stop_server() {
set -e
# systemctl could emit exit code 100=no init script (fresh install)
- if [ "$errno" != 0 -a "$errno" != 100 ]; then
+ if [ "$errno" != 0 ] && [ "$errno" != 100 ]; then
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
echo "Stop it yourself and try again!" 1>&2
@@ -38,7 +39,7 @@ stop_server() {
case "$1" in
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
- if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then
+ if [ -n "$($MYADMIN ping 2>/dev/null)" ]; then
stop_server
sleep 2
fi
diff --git a/debian/mariadb-server-10.6.preinst b/debian/mariadb-server-10.6.preinst
index c203e6f0ade..e8f9953da7c 100644
--- a/debian/mariadb-server-10.6.preinst
+++ b/debian/mariadb-server-10.6.preinst
@@ -7,6 +7,7 @@
# * <old-preinst> abort-upgrade <new-version>
#
+# shellcheck source=/dev/null
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file
@@ -40,7 +41,7 @@ stop_server() {
set -e
# systemctl could emit exit code 100=no init script (fresh install)
- if [ "$errno" != 0 -a "$errno" != 100 ]; then
+ if [ "$errno" != 0 ] && [ "$errno" != 100 ]; then
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
echo "Stop it yourself and try again!" 1>&2
@@ -57,7 +58,7 @@ max_upgradeable_version=5.7
# Check if a flag file is found that indicates a previous MariaDB or MySQL
# version was installed. If multiple flags are found, check which one was
# the biggest version number.
-for flag in $mysql_datadir/debian-*.flag
+for flag in "$mysql_datadir"/debian-*.flag
do
# The for loop leaves $flag as the query string if there are no results,
@@ -92,7 +93,7 @@ done
# Downgrade is detected if the flag version is bigger than $this_version
# (e.g. 10.1 > 10.0) or the flag version is smaller than 10.0 but bigger
# than $max_upgradeable_version.
-if [ ! -z "$found_version" ]
+if [ -n "$found_version" ]
then
# MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly
@@ -134,7 +135,7 @@ fi
# Don't abort dpkg if downgrade is detected (as was done previously).
# Instead simply move the old datadir and create a new for this_version.
-if [ ! -z "$downgrade_detected" ]
+if [ -n "$downgrade_detected" ]
then
db_input critical "mariadb-server-$MAJOR_VER/old_data_directory_saved" || true
db_go