From 30e6e809ed8d189cc8374df3c28cfbcab5a299b9 Mon Sep 17 00:00:00 2001 From: Harald Hoyer 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. --- 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 | 20 ++++++---- modules.d/95cifs/module-setup.sh | 2 +- modules.d/95dasd/module-setup.sh | 2 +- modules.d/95dasd_mod/module-setup.sh | 1 + modules.d/95dasd_rules/module-setup.sh | 2 +- 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 | 3 +- modules.d/95zfcp_rules/module-setup.sh | 2 +- modules.d/95znet/module-setup.sh | 3 +- 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 +- 39 files changed, 113 insertions(+), 71 deletions(-) diff --git a/dracut-functions.sh b/dracut-functions.sh index c766ca3..32f264b 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() { @@ -1084,7 +1129,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 @@ -1110,7 +1155,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 @@ -1134,7 +1179,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 @@ -1155,7 +1200,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 @@ -1176,7 +1221,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 @@ -1197,7 +1242,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 f599940..e8fc115 100755 --- a/modules.d/00bash/module-setup.sh +++ b/modules.d/00bash/module-setup.sh @@ -4,7 +4,7 @@ # called by dracut check() { - [ -x /bin/bash ] + require_binaries /bin/bash } # called by dracut diff --git a/modules.d/00bootchart/module-setup.sh b/modules.d/00bootchart/module-setup.sh index 107ee5b..95e5c4b 100755 --- a/modules.d/00bootchart/module-setup.sh +++ b/modules.d/00bootchart/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 47f7b03..8f7deec 100755 --- a/modules.d/00dash/module-setup.sh +++ b/modules.d/00dash/module-setup.sh @@ -4,7 +4,7 @@ # called by dracut check() { - [ -x /bin/dash ] + require_binaries /bin/dash } # called by dracut diff --git a/modules.d/00systemd-bootchart/module-setup.sh b/modules.d/00systemd-bootchart/module-setup.sh index a897cef..5cca254 100755 --- a/modules.d/00systemd-bootchart/module-setup.sh +++ b/modules.d/00systemd-bootchart/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 6019188..46e35a0 100755 --- a/modules.d/02caps/module-setup.sh +++ b/modules.d/02caps/module-setup.sh @@ -4,7 +4,7 @@ # called by dracut check() { - type -P capsh >/dev/null 2>&1 + require_binaries capsh } # called by dracut @@ -14,9 +14,13 @@ depends() { # called by dracut 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 5dfd90c..09285d3 100755 --- a/modules.d/03modsign/module-setup.sh +++ b/modules.d/03modsign/module-setup.sh @@ -9,7 +9,7 @@ # called by dracut 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 6e508a6..228ff8c 100755 --- a/modules.d/05busybox/module-setup.sh +++ b/modules.d/05busybox/module-setup.sh @@ -4,7 +4,7 @@ # called by dracut 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 fcb18d1..a091f89 100755 --- a/modules.d/10i18n/module-setup.sh +++ b/modules.d/10i18n/module-setup.sh @@ -6,9 +6,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 48afc5a..1df4174 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -6,12 +6,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 1ed97ac..1b785c2 100755 --- a/modules.d/45url-lib/module-setup.sh +++ b/modules.d/45url-lib/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut 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 1360924..b818324 100755 --- a/modules.d/50plymouth/module-setup.sh +++ b/modules.d/50plymouth/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut check() { [[ "$mount_needs" ]] && return 1 - type -P plymouthd >/dev/null && type -P plymouth >/dev/null + require_binaries plymouthd plymouth } # called by dracut diff --git a/modules.d/90btrfs/module-setup.sh b/modules.d/90btrfs/module-setup.sh index 80a538f..406fd6d 100755 --- a/modules.d/90btrfs/module-setup.sh +++ b/modules.d/90btrfs/module-setup.sh @@ -7,7 +7,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 7d18e33..21d49c4 100755 --- a/modules.d/90crypt/module-setup.sh +++ b/modules.d/90crypt/module-setup.sh @@ -6,7 +6,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 bafad67..829c24b 100755 --- a/modules.d/90dm/module-setup.sh +++ b/modules.d/90dm/module-setup.sh @@ -4,7 +4,7 @@ # called by dracut 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 a9e27a6..d3888a4 100755 --- a/modules.d/90dmraid/module-setup.sh +++ b/modules.d/90dmraid/module-setup.sh @@ -7,7 +7,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 a64e5d6..357797f 100755 --- a/modules.d/90lvm/module-setup.sh +++ b/modules.d/90lvm/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 61483f2..7d72098 100755 --- a/modules.d/90mdraid/module-setup.sh +++ b/modules.d/90mdraid/module-setup.sh @@ -6,7 +6,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 261a957..b60cc60 100755 --- a/modules.d/90multipath/module-setup.sh +++ b/modules.d/90multipath/module-setup.sh @@ -6,7 +6,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 90c7bc2..b2154f0 100755 --- a/modules.d/91crypt-gpg/module-setup.sh +++ b/modules.d/91crypt-gpg/module-setup.sh @@ -5,7 +5,7 @@ # GPG support is optional # called by dracut 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 00052d3..93ae92e 100644 --- a/modules.d/91crypt-loop/module-setup.sh +++ b/modules.d/91crypt-loop/module-setup.sh @@ -1,23 +1,27 @@ +#!/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 } # called by dracut depends() { - echo crypt + echo crypt } # called by dracut installkernel() { - instmods loop + instmods loop } # called by dracut 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 546d2ff..8f5a3bf 100755 --- a/modules.d/95cifs/module-setup.sh +++ b/modules.d/95cifs/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 9c93d40..da0f3c0 100755 --- a/modules.d/95dasd/module-setup.sh +++ b/modules.d/95dasd/module-setup.sh @@ -5,8 +5,8 @@ # called by dracut check() { local _arch=$(uname -m) - [ -x /sbin/normalize_dasd_arg ] || return 1 [ "$_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 8fde525..bee4998 100755 --- a/modules.d/95dasd_mod/module-setup.sh +++ b/modules.d/95dasd_mod/module-setup.sh @@ -6,6 +6,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/95dasd_rules/module-setup.sh b/modules.d/95dasd_rules/module-setup.sh index d313171..51c315d 100755 --- a/modules.d/95dasd_rules/module-setup.sh +++ b/modules.d/95dasd_rules/module-setup.sh @@ -5,8 +5,8 @@ # called by dracut check() { local _arch=$(uname -m) - [ -x /sbin/dasd_configure ] || return 1 [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + require_binaries dasd_configure /usr/lib/udev/collect || return 1 return 0 } diff --git a/modules.d/95fcoe-uefi/module-setup.sh b/modules.d/95fcoe-uefi/module-setup.sh index c91f775..0fb06e2 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 539c464..c502ba0 100755 --- a/modules.d/95fcoe/module-setup.sh +++ b/modules.d/95fcoe/module-setup.sh @@ -4,10 +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/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh index 8379f4b..1b0f292 100755 --- a/modules.d/95iscsi/module-setup.sh +++ b/modules.d/95iscsi/module-setup.sh @@ -6,7 +6,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 37ace21..e62f290 100755 --- a/modules.d/95nbd/module-setup.sh +++ b/modules.d/95nbd/module-setup.sh @@ -6,7 +6,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 345810a..dabf3b0 100755 --- a/modules.d/95nfs/module-setup.sh +++ b/modules.d/95nfs/module-setup.sh @@ -5,8 +5,8 @@ # called by dracut 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 1f2b733..2e3c505 100755 --- a/modules.d/95ssh-client/module-setup.sh +++ b/modules.d/95ssh-client/module-setup.sh @@ -6,11 +6,11 @@ # called by dracut 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 ebc4447..584d5c8 100755 --- a/modules.d/95udev-rules/module-setup.sh +++ b/modules.d/95udev-rules/module-setup.sh @@ -6,7 +6,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 dfbeed5..b96ccd2 100755 --- a/modules.d/95zfcp/module-setup.sh +++ b/modules.d/95zfcp/module-setup.sh @@ -5,9 +5,10 @@ # called by dracut check() { arch=$(uname -m) - [ -x /sbin/zfcp_cio_free ] || return 1 [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + require_binaries zfcp_cio_free grep sed seq || return 1 + return 0 } diff --git a/modules.d/95zfcp_rules/module-setup.sh b/modules.d/95zfcp_rules/module-setup.sh index 9a1ab20..d9879cb 100755 --- a/modules.d/95zfcp_rules/module-setup.sh +++ b/modules.d/95zfcp_rules/module-setup.sh @@ -5,8 +5,8 @@ # called by dracut check() { local _arch=$(uname -m) - [ -x /sbin/zfcp_disk_configure ] || return 1 [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + require_binaries zfcp_disk_configure /usr/lib/udev/collect || return 1 return 0 } diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh index 5012b77..346f893 100755 --- a/modules.d/95znet/module-setup.sh +++ b/modules.d/95znet/module-setup.sh @@ -5,9 +5,10 @@ # called by dracut check() { arch=$(uname -m) - [ -z /sbin/znet_cio_free ] || return 1 [ "$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 b51c472..e285a7f 100755 --- a/modules.d/97biosdevname/module-setup.sh +++ b/modules.d/97biosdevname/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 e6e3690..82a6515 100755 --- a/modules.d/97masterkey/module-setup.sh +++ b/modules.d/97masterkey/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 036f1c1..badce3c 100755 --- a/modules.d/98systemd/module-setup.sh +++ b/modules.d/98systemd/module-setup.sh @@ -5,7 +5,7 @@ # called by dracut 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 2c3c992..69346b2 100755 --- a/modules.d/99img-lib/module-setup.sh +++ b/modules.d/99img-lib/module-setup.sh @@ -3,9 +3,7 @@ # called by dracut 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 }