From 71388098b67bceee1530586c939d3437804593eb Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Sat, 7 Mar 2009 08:25:22 -0600 Subject: [PATCH] Clean up logic for auto vs. hostonly The mass of conditional checking and multiple variables was a little hard to read, split some of it into its own function. --- dracut | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dracut b/dracut index 1172ebbe..ce833804 100755 --- a/dracut +++ b/dracut @@ -35,18 +35,18 @@ done dracutfunctions=$dsrc/dracut-functions export dracutfunctions -[[ $dracutmodules ]] || dracutmodules="auto" +[[ $dracutmodules ]] || dracutmodules="all" [[ $dracutmodules = "auto" ]] && { dracutmodules="all" skipmissing="yes" } - [[ $dracutmodules = "hostonly" ]] && { dracutmodules="all" skipmissing="yes" hostonly="-h" } + [[ $2 ]] && kernel=$2 || kernel=$(uname -r) [[ $1 ]] && outfile=$(readlink -f $1) || outfile="/boot/initrd-$kernel.img" @@ -67,20 +67,20 @@ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do mkdir -p "$initdir/$d"; done +skip_missing() { + # $1 = location of module + [[ $skipmissing ]] || return 0 + [[ -x $1/check ]] || return 0 + "$1/check" $hostonly +} + can_source_module() { # $1 = location of module mod=${1##*/}; mod=${mod#[0-9][0-9]}; - case $dracutmodules in - all) [[ $skipmissing ]] || return 0;; - *) strstr "$dracutmodules " "$mod " || return 1;; - esac - - [[ $skipmissing ]] && [[ -x $1/check ]] && { - return $("$1/check" $hostonly >/dev/null 2>&1;) - } - - [[ $skipmissing ]] || return 1 - return 0 + if [[ $dracutmodules != all ]]; then + strstr "$dracutmodules " "$mod " || return 1;; + fi + skip_missing "$1" } # source all our modules