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.master
parent
76c88488c4
commit
71388098b6
26
dracut
26
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
|
||||
|
|
Loading…
Reference in New Issue