From 80f5e83ed554d8f454419de71f72a4b8f92c35fa Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 26 Mar 2021 10:29:22 +0100 Subject: [PATCH] fix(multipath): shellcheck for modules.d/90multipath --- modules.d/90multipath/.shchkdir | 0 modules.d/90multipath/module-setup.sh | 25 ++++++++----------- modules.d/90multipath/multipath-shutdown.sh | 4 +-- .../90multipath/multipathd-needshutdown.sh | 2 +- modules.d/90multipath/multipathd-stop.sh | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) create mode 100644 modules.d/90multipath/.shchkdir diff --git a/modules.d/90multipath/.shchkdir b/modules.d/90multipath/.shchkdir new file mode 100644 index 000000000..e69de29bb diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh index 554583e2a..452be6556 100755 --- a/modules.d/90multipath/module-setup.sh +++ b/modules.d/90multipath/module-setup.sh @@ -2,8 +2,8 @@ is_mpath() { local _dev=$1 - [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1 - [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0 + [ -e /sys/dev/block/"$_dev"/dm/uuid ] || return 1 + [[ $(cat /sys/dev/block/"$_dev"/dm/uuid) =~ mpath- ]] && return 0 return 1 } @@ -11,9 +11,9 @@ majmin_to_mpath_dev() { local _dev for i in /dev/mapper/*; do [[ $i == /dev/mapper/control ]] && continue - _dev=$(get_maj_min $i) + _dev=$(get_maj_min "$i") if [ "$_dev" = "$1" ]; then - echo $i + echo "$i" return fi done @@ -21,8 +21,6 @@ majmin_to_mpath_dev() { # called by dracut check() { - local _rootdev - [[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_and_slaves is_mpath || return 255 } @@ -52,10 +50,8 @@ cmdline() { # called by dracut installkernel() { - local _ret local _arch=${DRACUT_ARCH:-$(uname -m)} local _funcs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target' - local _s390 if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then _s390drivers="=drivers/s390/scsi" @@ -66,13 +62,13 @@ installkernel() { # called by dracut install() { - local _f _allow + local _allow add_hostonly_mpath_conf() { - is_mpath $1 && { + is_mpath "$1" && { local _dev - _dev=$(majmin_to_mpath_dev $1) + _dev=$(majmin_to_mpath_dev "$1") [ -z "$_dev" ] && return strstr "$_allow" "$_dev" && return _allow="$_allow --allow $_dev" @@ -96,16 +92,17 @@ install() { [[ $hostonly ]] && [[ $hostonly_mode == "strict" ]] && { for_each_host_dev_and_slaves_all add_hostonly_mpath_conf - [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf + [ -n "$_allow" ] && mpathconf "$_allow" --outfile "${initdir}"/etc/multipath.conf } - inst $(command -v partx) /sbin/partx + inst "$(command -v partx)" /sbin/partx inst_libdir_file "libmultipath*" "multipath/*" inst_libdir_file 'libgcc_s.so*' if [[ $hostonly_cmdline ]]; then - local _conf=$(cmdline) + local _conf + _conf=$(cmdline) [[ $_conf ]] && echo "$_conf" >> "${initdir}/etc/cmdline.d/90multipath.conf" fi diff --git a/modules.d/90multipath/multipath-shutdown.sh b/modules.d/90multipath/multipath-shutdown.sh index 3c9e96fc8..220da8f5c 100755 --- a/modules.d/90multipath/multipath-shutdown.sh +++ b/modules.d/90multipath/multipath-shutdown.sh @@ -1,7 +1,7 @@ #!/bin/sh for i in $(multipath -l -v1); do - if ! dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1'; then - dmsetup message $i 0 fail_if_no_path + if ! dmsetup table "$i" | sed -n '/.*queue_if_no_path.*/q1'; then + dmsetup message "$i" 0 fail_if_no_path fi done diff --git a/modules.d/90multipath/multipathd-needshutdown.sh b/modules.d/90multipath/multipathd-needshutdown.sh index 4f5c76c50..cb2602e2e 100755 --- a/modules.d/90multipath/multipathd-needshutdown.sh +++ b/modules.d/90multipath/multipathd-needshutdown.sh @@ -1,7 +1,7 @@ #!/bin/sh for i in $(multipath -l -v1); do - if $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1'); then + if dmsetup table "$i" | sed -n '/.*queue_if_no_path.*/q1'; then need_shutdown break fi diff --git a/modules.d/90multipath/multipathd-stop.sh b/modules.d/90multipath/multipathd-stop.sh index 31d573bf7..cf9b782e9 100755 --- a/modules.d/90multipath/multipathd-stop.sh +++ b/modules.d/90multipath/multipathd-stop.sh @@ -4,7 +4,7 @@ if [ -e /etc/multipath.conf ]; then HARD="" while pidof multipathd > /dev/null 2>&1; do for pid in $(pidof multipathd); do - kill $HARD $pid > /dev/null 2>&1 + kill "$HARD" "$pid" > /dev/null 2>&1 done HARD="-9" done -- 2.47.2