]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(multipath): revise multipathd-stop
authorHarald Hoyer <harald@redhat.com>
Wed, 31 Mar 2021 08:18:27 +0000 (10:18 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Wed, 31 Mar 2021 09:30:10 +0000 (11:30 +0200)
A shellcheck regression quoted `HARD` in
```shell
    kill "$HARD" "$pid" > /dev/null 2>&1
```

which would error on an empty "HARD".

Instead of fixing this, use `pkill` instead and also add it to the
non-optional list of binaries to install, which was revised also.

Fixes: https://github.com/dracutdevs/dracut/issues/1275
modules.d/90multipath/module-setup.sh
modules.d/90multipath/multipathd-stop.sh

index 681006d80831b3d38b6fe267628a9b3efa90bb78..b6002c6a3c9c160de492ba82cf14884b50a1801c 100755 (executable)
@@ -74,14 +74,18 @@ install() {
         fi
     }
 
-    inst_multiple -o \
-        dmsetup \
+    inst_multiple \
+        pkill \
+        pidof \
         kpartx \
+        dmsetup \
+        multipath \
+        multipathd
+
+    inst_multiple -o \
         mpath_wait \
         mpathconf \
         mpathpersist \
-        multipath \
-        multipathd \
         xdrgetprio \
         xdrgetuid \
         /etc/xdrdevices.conf \
index cf9b782e9c03d67d514e224d7af7fc0a2000012b..cc5aece57a94a7be96ee8f981014f4b525f7160f 100755 (executable)
@@ -1,11 +1,13 @@
 #!/bin/sh
 
 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
-        done
-        HARD="-9"
-    done
+    pkill multipathd > /dev/null 2>&1
+
+    if pidof multipathd > /dev/null 2>&1; then
+        sleep 0.2
+    fi
+
+    if pidof multipathd > /dev/null 2>&1; then
+        pkill -9 multipathd > /dev/null 2>&1
+    fi
 fi