]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(multipath): shellcheck for modules.d/90multipath
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:22 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 29 Mar 2021 08:52:28 +0000 (10:52 +0200)
modules.d/90multipath/.shchkdir [new file with mode: 0644]
modules.d/90multipath/module-setup.sh
modules.d/90multipath/multipath-shutdown.sh
modules.d/90multipath/multipathd-needshutdown.sh
modules.d/90multipath/multipathd-stop.sh

diff --git a/modules.d/90multipath/.shchkdir b/modules.d/90multipath/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index 554583e2a4f8cbe321f4ec51b3197c135199c467..452be655612271f52c4f0504352cce7289bd60f8 100755 (executable)
@@ -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
 
index 3c9e96fc8a66190bb451e87f40efd10d14d2fed1..220da8f5c750e8a9b08467b37e16a6759377f7a8 100755 (executable)
@@ -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
index 4f5c76c50c064cdfedf95b173a0e644ea3cf5116..cb2602e2e99e17c085b1b992efd807a6f9a4bd21 100755 (executable)
@@ -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
index 31d573bf7c3652a8ccb946cb8e9b9d2ba63eb25e..cf9b782e9c03d67d514e224d7af7fc0a2000012b 100755 (executable)
@@ -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