From 8d02da427b55d5f3804745018e6550bef92faaf2 Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Fri, 6 Mar 2009 14:23:37 -0600 Subject: [PATCH] Add dracutmodules=auto functionality To use this, your module needs to supply a check script which returns 0 if the module is applicable to this system, 1 otherwise. If a module does not include a check script, it will be sourced. If no modules have check scripts, then dracutmodules=auto behaves exactly like dracutmodules=all --- dracut | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dracut b/dracut index 04c645730..12d343141 100755 --- a/dracut +++ b/dracut @@ -50,14 +50,23 @@ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do mkdir -p "$initdir/$d"; done +can_source_module() { + # $1 = location of module + mod=${1##*/}; mod=${mod#[0-9][0-9]}; + case $dracutmodules in + all) return 0;; + auto) [[ -x $1/check ]] || return 0 + "$1/check" >/dev/null 2>&1 && return 0 ;; + *) strstr "$dracutmodules" "$mod" && return 0;; + esac + return 1 +} + # source all our modules for moddir in "$dsrc/modules.d"/*; do [[ -d $moddir || -L $moddir ]] || continue - mod=${moddir##*/}; mod=${mod#[0-9][0-9]}; - if [[ $dracutmodules = all ]] || strstr "$dracutmodules " "$mod "; then - echo "== Module $moddir == " - [[ -x $moddir/install ]] && . "$moddir/install" - fi + can_source_module "$moddir" || continue + [[ -x $moddir/install ]] && . "$moddir/install" done unset moddir -- 2.47.3