Blob Blame History Raw
From da3dacfa5e63ca00d4c8efd8c3c603bce7937cdd Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 6 Feb 2014 16:45:20 +0100
Subject: [PATCH] Factor out all the "type -V" commands

Add new functions require_binaries() and require_any_binary() to be used
in the check() section of module-setup.sh.

These functions print a warning line telling the user, which binary is
missing for the specific dracut module.

This unifies the way of checking for binaries and makes the life of an
initramfs creator easier, if he wants to find out why a specific dracut
module is not included in the initramfs.

(cherry picked from commit 30e6e809ed8d189cc8374df3c28cfbcab5a299b9)
---
 dracut-functions.sh                           | 57 ++++++++++++++++++++++++---
 modules.d/00bash/module-setup.sh              |  2 +-
 modules.d/00bootchart/module-setup.sh         |  2 +-
 modules.d/00dash/module-setup.sh              |  2 +-
 modules.d/00systemd-bootchart/module-setup.sh |  2 +-
 modules.d/02caps/module-setup.sh              | 14 ++++---
 modules.d/03modsign/module-setup.sh           |  2 +-
 modules.d/05busybox/module-setup.sh           |  2 +-
 modules.d/10i18n/module-setup.sh              |  4 +-
 modules.d/40network/module-setup.sh           |  7 +---
 modules.d/45url-lib/module-setup.sh           |  2 +-
 modules.d/50plymouth/module-setup.sh          |  2 +-
 modules.d/90btrfs/module-setup.sh             |  2 +-
 modules.d/90crypt/module-setup.sh             |  2 +-
 modules.d/90dm/module-setup.sh                |  2 +-
 modules.d/90dmraid/module-setup.sh            |  2 +-
 modules.d/90lvm/module-setup.sh               |  2 +-
 modules.d/90mdraid/module-setup.sh            |  2 +-
 modules.d/90multipath/module-setup.sh         |  2 +-
 modules.d/91crypt-gpg/module-setup.sh         |  2 +-
 modules.d/91crypt-loop/module-setup.sh        | 21 ++++++----
 modules.d/95cifs/module-setup.sh              |  2 +-
 modules.d/95dasd/module-setup.sh              |  1 +
 modules.d/95dasd_mod/module-setup.sh          |  1 +
 modules.d/95fcoe-uefi/module-setup.sh         |  4 +-
 modules.d/95fcoe/module-setup.sh              |  5 +--
 modules.d/95iscsi/module-setup.sh             |  2 +-
 modules.d/95nbd/module-setup.sh               |  2 +-
 modules.d/95nfs/module-setup.sh               |  4 +-
 modules.d/95ssh-client/module-setup.sh        |  6 +--
 modules.d/95udev-rules/module-setup.sh        |  2 +-
 modules.d/95zfcp/module-setup.sh              |  2 +
 modules.d/95znet/module-setup.sh              |  2 +
 modules.d/97biosdevname/module-setup.sh       |  2 +-
 modules.d/97masterkey/module-setup.sh         |  2 +-
 modules.d/98systemd/module-setup.sh           |  2 +-
 modules.d/99img-lib/module-setup.sh           |  4 +-
 37 files changed, 112 insertions(+), 66 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index 89438b29..4ea3204d 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -35,6 +35,51 @@ fi
 # Generic substring function.  If $2 is in $1, return 0.
 strstr() { [[ $1 = *$2* ]]; }
 
+# helper function for check() in module-setup.sh
+# to check for required installed binaries
+# issues a standardized warning message
+require_binaries() {
+    local _module_name="${moddir##*/}"
+    local _ret=0
+
+    if [[ "$1" = "-m" ]]; then
+        _module_name="$2"
+        shift 2
+    fi
+
+    for cmd in "$@"; do
+        if ! find_binary "$cmd" &>/dev/null; then
+            dwarning "$_module_name: Could not find command '$cmd'!"
+            ((_ret++))
+        fi
+    done
+    return $_ret
+}
+
+require_any_binary() {
+    local _module_name="${moddir##*/}"
+    local _ret=1
+
+    if [[ "$1" = "-m" ]]; then
+        _module_name="$2"
+        shift 2
+    fi
+
+    for cmd in "$@"; do
+        if find_binary "$cmd" &>/dev/null; then
+            _ret=0
+            break
+        fi
+    done
+
+    if (( $_ret != 0 )); then
+        dwarning "$_module_name: Could not find any command of '$@'!"
+        return 1
+    fi
+
+    return 0
+}
+
 # find a binary.  If we were not passed the full path directly,
 # search in the usual places to find the binary.
 find_binary() {
@@ -1055,7 +1100,7 @@ module_check() {
         . $_moddir/module-setup.sh
         is_func check || return 0
         [ $_forced -ne 0 ] && unset hostonly
-        check $hostonly
+        moddir=$_moddir check $hostonly
         _ret=$?
         unset check depends cmdline install installkernel
     fi
@@ -1081,7 +1126,7 @@ module_check_mount() {
         unset check depends cmdline install installkernel
         check() { false; }
         . $_moddir/module-setup.sh
-        check 0
+        moddir=$_moddir check 0
         _ret=$?
         unset check depends cmdline install installkernel
     fi
@@ -1105,7 +1150,7 @@ module_depends() {
         unset check depends cmdline install installkernel
         depends() { true; }
         . $_moddir/module-setup.sh
-        depends
+        moddir=$_moddir depends
         _ret=$?
         unset check depends cmdline install installkernel
         return $_ret
@@ -1126,7 +1171,7 @@ module_cmdline() {
         unset check depends cmdline install installkernel
         cmdline() { true; }
         . $_moddir/module-setup.sh
-        cmdline
+        moddir=$_moddir cmdline
         _ret=$?
         unset check depends cmdline install installkernel
         return $_ret
@@ -1147,7 +1192,7 @@ module_install() {
         unset check depends cmdline install installkernel
         install() { true; }
         . $_moddir/module-setup.sh
-        install
+        moddir=$_moddir install
         _ret=$?
         unset check depends cmdline install installkernel
         return $_ret
@@ -1168,7 +1213,7 @@ module_installkernel() {
         unset check depends cmdline install installkernel
         installkernel() { true; }
         . $_moddir/module-setup.sh
-        installkernel
+        moddir=$_moddir installkernel
         _ret=$?
         unset check depends cmdline install installkernel
         return $_ret
diff --git a/modules.d/00bash/module-setup.sh b/modules.d/00bash/module-setup.sh
index e874e73d..109642ac 100755
--- a/modules.d/00bash/module-setup.sh
+++ b/modules.d/00bash/module-setup.sh
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
-    [ -x /bin/bash ]
+    require_binaries /bin/bash
 }
 
 depends() {
diff --git a/modules.d/00bootchart/module-setup.sh b/modules.d/00bootchart/module-setup.sh
index 72b60633..f03fc540 100755
--- a/modules.d/00bootchart/module-setup.sh
+++ b/modules.d/00bootchart/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     [[ "$mount_needs" ]] && return 1
-    [ -x /sbin/bootchartd ] || return 1
+    require_binaries /sbin/bootchartd || return 1
     return 255
 }
 
diff --git a/modules.d/00dash/module-setup.sh b/modules.d/00dash/module-setup.sh
index dfd4d7bf..9a2a92fc 100755
--- a/modules.d/00dash/module-setup.sh
+++ b/modules.d/00dash/module-setup.sh
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
-    [ -x /bin/dash ]
+    require_binaries /bin/dash
 }
 
 depends() {
diff --git a/modules.d/00systemd-bootchart/module-setup.sh b/modules.d/00systemd-bootchart/module-setup.sh
index 3eb4de1e..eb6f383c 100755
--- a/modules.d/00systemd-bootchart/module-setup.sh
+++ b/modules.d/00systemd-bootchart/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     [[ "$mount_needs" ]] && return 1
-    [ -x $systemdutildir/systemd-bootchart ] || return 1
+    require_binaries $systemdutildir/systemd-bootchart || return 1
     return 255
 }
 
diff --git a/modules.d/02caps/module-setup.sh b/modules.d/02caps/module-setup.sh
index c9d94eeb..73eb215b 100755
--- a/modules.d/02caps/module-setup.sh
+++ b/modules.d/02caps/module-setup.sh
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
-    type -P capsh >/dev/null 2>&1
+    require_binaries capsh
 }
 
 depends() {
@@ -11,9 +11,13 @@ depends() {
 }
 
 install() {
-    inst_hook pre-pivot 00 "$moddir/caps.sh"
-    inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
-    # capsh wants bash and we need bash also
-    inst /bin/bash
+    if ! dracut_module_included "systemd"; then
+        inst_hook pre-pivot 00 "$moddir/caps.sh"
+        inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
+        # capsh wants bash and we need bash also
+        inst /bin/bash
+    else
+        dwarning "caps: does not work with systemd in the initramfs"
+    fi
 }
 
diff --git a/modules.d/03modsign/module-setup.sh b/modules.d/03modsign/module-setup.sh
index 730cd86e..bed5cfe1 100755
--- a/modules.d/03modsign/module-setup.sh
+++ b/modules.d/03modsign/module-setup.sh
@@ -8,7 +8,7 @@
 # Peter Jones <pjones@redhat.com>
 
 check() {
-    [[ -x /usr/bin/keyctl ]] || return 1
+    require_binaries keyctl || return 1
 
     # do not include module in hostonly mode,
     # if no keys are present
diff --git a/modules.d/05busybox/module-setup.sh b/modules.d/05busybox/module-setup.sh
index edcc8daa..c35ab2e9 100755
--- a/modules.d/05busybox/module-setup.sh
+++ b/modules.d/05busybox/module-setup.sh
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
-    type -P busybox >/dev/null || return 1
+    require_binaries busybox || return 1
 
     return 255
 }
diff --git a/modules.d/10i18n/module-setup.sh b/modules.d/10i18n/module-setup.sh
index 413ee123..2c0a275c 100755
--- a/modules.d/10i18n/module-setup.sh
+++ b/modules.d/10i18n/module-setup.sh
@@ -5,9 +5,7 @@
 check() {
     [[ "$mount_needs" ]] && return 1
 
-    for i in setfont loadkeys kbd_mode; do
-        type -P "$i" >/dev/null || return 1
-    done
+    require_binaries setfont loadkeys kbd_mode || return 1
 
     return 0
 }
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index a52e881b..3134b5ff 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -5,12 +5,7 @@
 check() {
     local _program
 
-    for _program in ip arping dhclient ; do
-        if ! type -P $_program >/dev/null; then
-            derror "Could not find program \"$_program\" required by network."
-            return 1
-        fi
-    done
+    require_binaries ip arping dhclient || return 1
 
     return 255
 }
diff --git a/modules.d/45url-lib/module-setup.sh b/modules.d/45url-lib/module-setup.sh
index b5cf36f2..f2d068b3 100755
--- a/modules.d/45url-lib/module-setup.sh
+++ b/modules.d/45url-lib/module-setup.sh
@@ -2,7 +2,7 @@
 # module-setup for url-lib
 
 check() {
-    command -v curl >/dev/null || return 1
+    require_binaries curl || return 1
     return 255
 }
 
diff --git a/modules.d/50plymouth/module-setup.sh b/modules.d/50plymouth/module-setup.sh
index e0e69367..961c1e39 100755
--- a/modules.d/50plymouth/module-setup.sh
+++ b/modules.d/50plymouth/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     [[ "$mount_needs" ]] && return 1
-    type -P plymouthd >/dev/null && type -P plymouth >/dev/null
+    require_binaries plymouthd plymouth
 }
 
 depends() {
diff --git a/modules.d/90btrfs/module-setup.sh b/modules.d/90btrfs/module-setup.sh
index a2805946..4804f58b 100755
--- a/modules.d/90btrfs/module-setup.sh
+++ b/modules.d/90btrfs/module-setup.sh
@@ -6,7 +6,7 @@ check() {
     local _rootdev
     # if we don't have btrfs installed on the host system,
     # no point in trying to support it in the initramfs.
-    type -P btrfs >/dev/null || return 1
+    require_binaries btrfs || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in ${host_fs_types[@]}; do
diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh
index 272e527d..dbc87a43 100755
--- a/modules.d/90crypt/module-setup.sh
+++ b/modules.d/90crypt/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
     local _rootdev
     # if cryptsetup is not installed, then we cannot support encrypted devices.
-    type -P cryptsetup >/dev/null || return 1
+    require_binaries cryptsetup || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
diff --git a/modules.d/90dm/module-setup.sh b/modules.d/90dm/module-setup.sh
index 1fd92987..ed94f436 100755
--- a/modules.d/90dm/module-setup.sh
+++ b/modules.d/90dm/module-setup.sh
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
-    type -P dmsetup >/dev/null || return 1
+    require_binaries dmsetup || return 1
     return 255
 }
 
diff --git a/modules.d/90dmraid/module-setup.sh b/modules.d/90dmraid/module-setup.sh
index b230cb0e..8ca69aa8 100755
--- a/modules.d/90dmraid/module-setup.sh
+++ b/modules.d/90dmraid/module-setup.sh
@@ -6,7 +6,7 @@ check() {
     local _rootdev
     # if we don't have dmraid installed on the host system, no point
     # in trying to support it in the initramfs.
-    type -P dmraid >/dev/null || return 1
+    require_binaries dmraid || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for dev in "${!host_fs_types[@]}"; do
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
index 0c5890a7..5ec62812 100755
--- a/modules.d/90lvm/module-setup.sh
+++ b/modules.d/90lvm/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     # No point trying to support lvm if the binaries are missing
-    type -P lvm >/dev/null || return 1
+    require_binaries lvm || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
index 815a3ebc..2092daea 100755
--- a/modules.d/90mdraid/module-setup.sh
+++ b/modules.d/90mdraid/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
     local _rootdev
     # No mdadm?  No mdraid support.
-    type -P mdadm >/dev/null || return 1
+    require_binaries mdadm || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for dev in "${!host_fs_types[@]}"; do
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
index feb58dcd..d37f9587 100755
--- a/modules.d/90multipath/module-setup.sh
+++ b/modules.d/90multipath/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
     local _rootdev
     # if there's no multipath binary, no go.
-    type -P multipath >/dev/null || return 1
+    require_binaries multipath || return 1
 
     is_mpath() {
         local _dev=$1
diff --git a/modules.d/91crypt-gpg/module-setup.sh b/modules.d/91crypt-gpg/module-setup.sh
index 43a5a000..17b58f1a 100755
--- a/modules.d/91crypt-gpg/module-setup.sh
+++ b/modules.d/91crypt-gpg/module-setup.sh
@@ -4,7 +4,7 @@
 
 # GPG support is optional
 check() {
-    type -P gpg >/dev/null || return 1
+    require_binaries gpg || return 1
 
     return 255
 }
diff --git a/modules.d/91crypt-loop/module-setup.sh b/modules.d/91crypt-loop/module-setup.sh
index c14fd45a..d0a49567 100644
--- a/modules.d/91crypt-loop/module-setup.sh
+++ b/modules.d/91crypt-loop/module-setup.sh
@@ -1,19 +1,24 @@
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+# called by dracut
 check() {
-	type -P losetup >/dev/null || return 1
-	
-	return 255
+    require_binaries losetup || return 1
+
+    return 255
 }
 
 depends() {
-	echo crypt
+    echo crypt
 }
 
 installkernel() {
-	    instmods loop
+    instmods loop
 }
 
 install() {
-	inst_multiple losetup
-	inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
-        dracut_need_initqueue
+    inst_multiple losetup
+    inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
+    dracut_need_initqueue
 }
diff --git a/modules.d/95cifs/module-setup.sh b/modules.d/95cifs/module-setup.sh
index c17b973a..9e36f87f 100755
--- a/modules.d/95cifs/module-setup.sh
+++ b/modules.d/95cifs/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     # If our prerequisites are not met, fail anyways.
-    type -P mount.cifs >/dev/null || return 1
+    require_binaries mount.cifs || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in ${host_fs_types[@]}; do
diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh
index 3b8396db..70b2fcc8 100755
--- a/modules.d/95dasd/module-setup.sh
+++ b/modules.d/95dasd/module-setup.sh
@@ -5,6 +5,7 @@
 check() {
     local _arch=$(uname -m)
     [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
+    require_binaries normalize_dasd_arg || return 1
     return 0
 }
 
diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh
index 9c9eeead..d20764eb 100755
--- a/modules.d/95dasd_mod/module-setup.sh
+++ b/modules.d/95dasd_mod/module-setup.sh
@@ -5,6 +5,7 @@
 check() {
     local _arch=$(uname -m)
     [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
+    require_binaries grep sed seq
 
     return 0
 }
diff --git a/modules.d/95fcoe-uefi/module-setup.sh b/modules.d/95fcoe-uefi/module-setup.sh
index c91f7754..0fb06e23 100755
--- a/modules.d/95fcoe-uefi/module-setup.sh
+++ b/modules.d/95fcoe-uefi/module-setup.sh
@@ -4,9 +4,7 @@
 
 # called by dracut
 check() {
-    for i in dcbtool fipvlan lldpad ip readlink; do
-        type -P $i >/dev/null || return 1
-    done
+    require_binaries dcbtool fipvlan lldpad ip readlink || return 1
     return 0
 }
 
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
index 3ffaf5a5..8c6290d4 100755
--- a/modules.d/95fcoe/module-setup.sh
+++ b/modules.d/95fcoe/module-setup.sh
@@ -3,10 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
-    for i in dcbtool fipvlan lldpad ip readlink; do
-        type -P $i >/dev/null || return 1
-    done
-
+    require_binaries dcbtool fipvlan lldpad ip readlink || return 1
     return 0
 }
 
diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh
index c6901c08..49f9a0ed 100755
--- a/modules.d/95iscsi/module-setup.sh
+++ b/modules.d/95iscsi/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
     local _rootdev
     # If our prerequisites are not met, fail anyways.
-    type -P iscsistart hostname iscsi-iname >/dev/null || return 1
+    require_binaries iscsistart hostname iscsi-iname || return 1
 
     # If hostonly was requested, fail the check if we are not actually
     # booting from root.
diff --git a/modules.d/95nbd/module-setup.sh b/modules.d/95nbd/module-setup.sh
index 3ac00f60..7e8a416c 100755
--- a/modules.d/95nbd/module-setup.sh
+++ b/modules.d/95nbd/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
     local _rootdev
     # If our prerequisites are not met, fail.
-    type -P nbd-client >/dev/null || return 1
+    require_binaries nbd-client || return 1
 
     # if an nbd device is not somewhere in the chain of devices root is
     # mounted on, fail the hostonly check.
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
index 75beb746..02838a49 100755
--- a/modules.d/95nfs/module-setup.sh
+++ b/modules.d/95nfs/module-setup.sh
@@ -4,8 +4,8 @@
 
 check() {
     # If our prerequisites are not met, fail anyways.
-    type -P rpcbind >/dev/null || type -P portmap >/dev/null || return 1
-    type -P rpc.statd mount.nfs mount.nfs4 umount >/dev/null || return 1
+    require_any_binary rpcbind portmap || return 1
+    require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in ${host_fs_types[@]}; do
diff --git a/modules.d/95ssh-client/module-setup.sh b/modules.d/95ssh-client/module-setup.sh
index c7d8ee24..6b441075 100755
--- a/modules.d/95ssh-client/module-setup.sh
+++ b/modules.d/95ssh-client/module-setup.sh
@@ -5,11 +5,11 @@
 # fixme: assume user is root
 
 check() {
-    # If our prerequisites are not met, fail.
-    type -P ssh >/dev/null || return 1
-    type -P scp >/dev/null || return 1
     [[ $mount_needs ]] && return 1
 
+    # If our prerequisites are not met, fail.
+    require_binaries ssh scp  || return 1
+
     if [[ $sshkey ]]; then
         [ ! -f $sshkey ] && {
             derror "ssh key: $sshkey is not found!"
diff --git a/modules.d/95udev-rules/module-setup.sh b/modules.d/95udev-rules/module-setup.sh
index 094479a3..fdea8c6d 100755
--- a/modules.d/95udev-rules/module-setup.sh
+++ b/modules.d/95udev-rules/module-setup.sh
@@ -5,7 +5,7 @@
 install() {
     local _i
 
-    # Fixme: would be nice if we didn't have to know which rules to grab....
+    # Fixme: would be nice if we didn't have to guess, which rules to grab....
     # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
     # of the rules we want so that we just copy those in would be best
     inst_multiple udevadm cat uname blkid \
diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh
index 99066958..d19eba4c 100755
--- a/modules.d/95zfcp/module-setup.sh
+++ b/modules.d/95zfcp/module-setup.sh
@@ -6,6 +6,8 @@ check() {
     arch=$(uname -m)
     [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
 
+    require_binaries zfcp_cio_free grep sed seq || return 1
+
     return 0
 }
 
diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh
index 16f84938..b052ec37 100755
--- a/modules.d/95znet/module-setup.sh
+++ b/modules.d/95znet/module-setup.sh
@@ -6,6 +6,8 @@ check() {
     arch=$(uname -m)
     [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
 
+    require_binaries znet_cio_free grep sed seq readlink || return 1
+
     return 0
 }
 
diff --git a/modules.d/97biosdevname/module-setup.sh b/modules.d/97biosdevname/module-setup.sh
index 4a0b4f41..fd4d4632 100755
--- a/modules.d/97biosdevname/module-setup.sh
+++ b/modules.d/97biosdevname/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     [[ "$mount_needs" ]] && return 1
-    type -P biosdevname >/dev/null || return 1
+    require_binaries biosdevname || return 1
     return 0
 }
 
diff --git a/modules.d/97masterkey/module-setup.sh b/modules.d/97masterkey/module-setup.sh
index a94c4f53..cda6e809 100755
--- a/modules.d/97masterkey/module-setup.sh
+++ b/modules.d/97masterkey/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     [[ $hostonly ]] && {
-        [ -x "/bin/keyctl" ] || return 1
+        require_binaries keyctl uname || return 1
     }
 
     return 255
diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh
index aae0319a..d0271f15 100755
--- a/modules.d/98systemd/module-setup.sh
+++ b/modules.d/98systemd/module-setup.sh
@@ -4,7 +4,7 @@
 
 check() {
     [[ $mount_needs ]] && return 1
-    if [[ -x $systemdutildir/systemd ]]; then
+    if require_binaries $systemdutildir/systemd; then
         SYSTEMD_VERSION=$($systemdutildir/systemd --version | { read a b a; echo $b; })
         (( $SYSTEMD_VERSION >= 198 )) && return 0
        return 255
diff --git a/modules.d/99img-lib/module-setup.sh b/modules.d/99img-lib/module-setup.sh
index 28bfc2aa..a951b930 100755
--- a/modules.d/99img-lib/module-setup.sh
+++ b/modules.d/99img-lib/module-setup.sh
@@ -2,9 +2,7 @@
 # module-setup for img-lib
 
 check() {
-    for cmd in tar gzip dd; do
-        command -v $cmd >/dev/null || return 1
-    done
+    require_binaries tar gzip dd bash || return 1
     return 255
 }