From: Victor Lowther Date: Fri, 6 Mar 2009 20:23:37 +0000 (-0600) Subject: Add dracutmodules=auto functionality X-Git-Tag: 0.1~329 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8d02da427b55d5f3804745018e6550bef92faaf2;p=thirdparty%2Fdracut.git 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 --- 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