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
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