style: shfmt -s reformat

reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w -s .
```
master
Harald Hoyer 2021-02-25 09:43:35 +01:00 committed by Harald Hoyer
parent 9a52c3fdb0
commit 75d758e8f1
78 changed files with 333 additions and 333 deletions

View File

@ -18,7 +18,7 @@
__contains_word() { __contains_word() {
local word="$1" local word="$1"
shift shift
for w in "$@"; do [[ $w = "$word" ]] && return 0; done for w in "$@"; do [[ $w == "$word" ]] && return 0; done
return 1 return 1
} }


@ -78,7 +78,7 @@ _dracut() {
return 0 return 0
fi fi


if [[ $cur = -* ]]; then if [[ $cur == -* ]]; then
# shellcheck disable=SC2207 # shellcheck disable=SC2207
# shellcheck disable=SC2016 # shellcheck disable=SC2016
COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur")) COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur"))

View File

@ -22,16 +22,16 @@ export LC_MESSAGES=C
# is_func <command> # is_func <command>
# Check whether $1 is a function. # Check whether $1 is a function.
is_func() { is_func() {
[[ "$(type -t "$1")" = "function" ]] [[ "$(type -t "$1")" == "function" ]]
} }


# Generic substring function. If $2 is in $1, return 0. # Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 = *"$2"* ]]; } strstr() { [[ $1 == *"$2"* ]]; }
# Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK # Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK
strglobin() { [[ $1 = *$2* ]]; } strglobin() { [[ $1 == *$2* ]]; }
# Generic glob matching function. If glob pattern $2 matches all of $1, OK # Generic glob matching function. If glob pattern $2 matches all of $1, OK
# shellcheck disable=SC2053 # shellcheck disable=SC2053
strglob() { [[ $1 = $2 ]]; } strglob() { [[ $1 == $2 ]]; }
# returns OK if $1 contains literal string $2 at the beginning, and isn't empty # returns OK if $1 contains literal string $2 at the beginning, and isn't empty
str_starts() { [ "${1#"$2"*}" != "$1" ]; } str_starts() { [ "${1#"$2"*}" != "$1" ]; }
# returns OK if $1 contains literal string $2 at the end, and isn't empty # returns OK if $1 contains literal string $2 at the end, and isn't empty
@ -46,7 +46,7 @@ find_binary() {
local p local p
[[ -z ${1##/*} ]] || _delim="/" [[ -z ${1##/*} ]] || _delim="/"


if [[ "$1" == *.so* ]]; then if [[ $1 == *.so* ]]; then
# shellcheck disable=SC2154 # shellcheck disable=SC2154
for l in $libdirs; do for l in $libdirs; do
_path="${l}${_delim}${1}" _path="${l}${_delim}${1}"
@ -61,7 +61,7 @@ find_binary() {
return 0 return 0
fi fi
fi fi
if [[ "$1" == */* ]]; then if [[ $1 == */* ]]; then
_path="${_delim}${1}" _path="${_delim}${1}"
if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
printf "%s\n" "${_path}" printf "%s\n" "${_path}"
@ -76,7 +76,7 @@ find_binary() {
fi fi
done done


[[ -n "$dracutsysrootdir" ]] && return 1 [[ -n $dracutsysrootdir ]] && return 1
type -P "${1##*/}" type -P "${1##*/}"
} }


@ -163,13 +163,13 @@ convert_abs_rel() {
set -- "$(normalize_path "$1")" "$(normalize_path "$2")" set -- "$(normalize_path "$1")" "$(normalize_path "$2")"


# corner case #1 - self looping link # corner case #1 - self looping link
[[ "$1" == "$2" ]] && { [[ $1 == "$2" ]] && {
printf "%s\n" "${1##*/}" printf "%s\n" "${1##*/}"
return return
} }


# corner case #2 - own dir link # corner case #2 - own dir link
[[ "${1%/*}" == "$2" ]] && { [[ ${1%/*} == "$2" ]] && {
printf ".\n" printf ".\n"
return return
} }
@ -180,7 +180,7 @@ convert_abs_rel() {
__abssize=${#__absolute[@]} __abssize=${#__absolute[@]}
__cursize=${#__current[@]} __cursize=${#__current[@]}


while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]; do while [[ ${__absolute[__level]} == "${__current[__level]}" ]]; do
((__level++)) ((__level++))
if ((__level > __abssize || __level > __cursize)); then if ((__level > __abssize || __level > __cursize)); then
break break
@ -214,7 +214,7 @@ get_fs_env() {
unset ID_FS_TYPE unset ID_FS_TYPE
ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \ ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \
| while read line || [ -n "$line" ]; do | while read line || [ -n "$line" ]; do
if [[ "$line" == TYPE\=* ]]; then if [[ $line == TYPE\=* ]]; then
printf "%s" "${line#TYPE=}" printf "%s" "${line#TYPE=}"
exit 0 exit 0
fi fi
@ -244,8 +244,8 @@ get_devpath_block() {
_majmin=$(get_maj_min "$1") _majmin=$(get_maj_min "$1")


for _i in /sys/block/*/dev /sys/block/*/*/dev; do for _i in /sys/block/*/dev /sys/block/*/*/dev; do
[[ -e "$_i" ]] || continue [[ -e $_i ]] || continue
if [[ "$_majmin" == "$(< "$_i")" ]]; then if [[ $_majmin == "$(< "$_i")" ]]; then
printf "%s" "${_i%/dev}" printf "%s" "${_i%/dev}"
return 0 return 0
fi fi
@ -260,7 +260,7 @@ get_persistent_dev() {
_dev=$(get_maj_min "$1") _dev=$(get_maj_min "$1")
[ -z "$_dev" ] && return [ -z "$_dev" ] && return


if [[ -n "$persistent_policy" ]]; then if [[ -n $persistent_policy ]]; then
_pol="/dev/disk/${persistent_policy}/*" _pol="/dev/disk/${persistent_policy}/*"
else else
_pol= _pol=
@ -275,7 +275,7 @@ get_persistent_dev() {
/dev/disk/by-partlabel/* \ /dev/disk/by-partlabel/* \
/dev/disk/by-id/* \ /dev/disk/by-id/* \
/dev/disk/by-path/*; do /dev/disk/by-path/*; do
[[ -e "$i" ]] || continue [[ -e $i ]] || continue
[[ $i == /dev/mapper/control ]] && continue [[ $i == /dev/mapper/control ]] && continue
[[ $i == /dev/mapper/mpath* ]] && continue [[ $i == /dev/mapper/mpath* ]] && continue
_tmp=$(get_maj_min "$i") _tmp=$(get_maj_min "$i")
@ -361,7 +361,7 @@ find_block_device() {
fi fi
return 0 return 0
fi fi
if [[ $_dev = *:* ]]; then if [[ $_dev == *:* ]]; then
printf "%s\n" "$_dev" printf "%s\n" "$_dev"
return 0 return 0
fi fi
@ -386,7 +386,7 @@ find_block_device() {
fi fi
return 0 return 0
fi fi
if [[ $_dev = *:* ]]; then if [[ $_dev == *:* ]]; then
printf "%s\n" "$_dev" printf "%s\n" "$_dev"
return 0 return 0
fi fi
@ -412,7 +412,7 @@ find_mp_fstype() {
findmnt -e -v -n -o 'FSTYPE' --target "$1" | { findmnt -e -v -n -o 'FSTYPE' --target "$1" | {
while read _fs || [ -n "$_fs" ]; do while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue [[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue [[ $_fs == "autofs" ]] && continue
printf "%s" "$_fs" printf "%s" "$_fs"
return 0 return 0
done done
@ -423,7 +423,7 @@ find_mp_fstype() {
findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | { findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | {
while read _fs || [ -n "$_fs" ]; do while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue [[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue [[ $_fs == "autofs" ]] && continue
printf "%s" "$_fs" printf "%s" "$_fs"
return 0 return 0
done done
@ -444,7 +444,7 @@ find_mp_fstype() {
find_dev_fstype() { find_dev_fstype() {
local _find_dev _fs local _find_dev _fs
_find_dev="$1" _find_dev="$1"
if ! [[ "$_find_dev" = /dev* ]]; then if ! [[ $_find_dev == /dev* ]]; then
[[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev" [[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev"
fi fi


@ -452,7 +452,7 @@ find_dev_fstype() {
findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | { findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | {
while read _fs || [ -n "$_fs" ]; do while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue [[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue [[ $_fs == "autofs" ]] && continue
printf "%s" "$_fs" printf "%s" "$_fs"
return 0 return 0
done done
@ -463,7 +463,7 @@ find_dev_fstype() {
findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | { findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | {
while read _fs || [ -n "$_fs" ]; do while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue [[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue [[ $_fs == "autofs" ]] && continue
printf "%s" "$_fs" printf "%s" "$_fs"
return 0 return 0
done done
@ -501,7 +501,7 @@ find_mp_fsopts() {
find_dev_fsopts() { find_dev_fsopts() {
local _find_dev local _find_dev
_find_dev="$1" _find_dev="$1"
if ! [[ "$_find_dev" = /dev* ]]; then if ! [[ $_find_dev == /dev* ]]; then
[[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev" [[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev"
fi fi


@ -583,7 +583,7 @@ for_each_host_dev_and_slaves_all() {
[[ "${host_devs[*]}" ]] || return 2 [[ "${host_devs[*]}" ]] || return 2


for _dev in "${host_devs[@]}"; do for _dev in "${host_devs[@]}"; do
[[ -b "$_dev" ]] || continue [[ -b $_dev ]] || continue
if check_block_and_slaves_all $_func $(get_maj_min $_dev); then if check_block_and_slaves_all $_func $(get_maj_min $_dev); then
_ret=0 _ret=0
fi fi
@ -598,7 +598,7 @@ for_each_host_dev_and_slaves() {
[[ "${host_devs[*]}" ]] || return 2 [[ "${host_devs[*]}" ]] || return 2


for _dev in "${host_devs[@]}"; do for _dev in "${host_devs[@]}"; do
[[ -b "$_dev" ]] || continue [[ -b $_dev ]] || continue
check_block_and_slaves $_func $(get_maj_min $_dev) && return 0 check_block_and_slaves $_func $(get_maj_min $_dev) && return 0
done done
return 1 return 1

View File

@ -19,7 +19,7 @@
# #
export LC_MESSAGES=C export LC_MESSAGES=C


if [[ "$EUID" = "0" ]] && ! [[ $DRACUT_NO_XATTR ]]; then if [[ $EUID == "0" ]] && ! [[ $DRACUT_NO_XATTR ]]; then
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr" export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
else else
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr" export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"
@ -28,12 +28,12 @@ fi
# is_func <command> # is_func <command>
# Check whether $1 is a function. # Check whether $1 is a function.
is_func() { is_func() {
[[ "$(type -t "$1")" = "function" ]] [[ "$(type -t "$1")" == "function" ]]
} }


if ! [[ $dracutbasedir ]]; then if ! [[ $dracutbasedir ]]; then
dracutbasedir=${BASH_SOURCE[0]%/*} dracutbasedir=${BASH_SOURCE[0]%/*}
[[ $dracutbasedir = dracut-functions* ]] && dracutbasedir="." [[ $dracutbasedir == dracut-functions* ]] && dracutbasedir="."
[[ $dracutbasedir ]] || dracutbasedir="." [[ $dracutbasedir ]] || dracutbasedir="."
dracutbasedir="$(readlink -f $dracutbasedir)" dracutbasedir="$(readlink -f $dracutbasedir)"
fi fi
@ -114,7 +114,7 @@ require_binaries() {
local _module_name="${moddir##*/}" local _module_name="${moddir##*/}"
local _ret=0 local _ret=0


if [[ "$1" = "-m" ]]; then if [[ $1 == "-m" ]]; then
_module_name="$2" _module_name="$2"
shift 2 shift 2
fi fi
@ -132,7 +132,7 @@ require_any_binary() {
local _module_name="${moddir##*/}" local _module_name="${moddir##*/}"
local _ret=1 local _ret=1


if [[ "$1" = "-m" ]]; then if [[ $1 == "-m" ]]; then
_module_name="$2" _module_name="$2"
shift 2 shift 2
fi fi
@ -197,13 +197,13 @@ for i in $DRACUT_INSTALL; do
DRINSTALLPARTS=$((DRINSTALLPARTS + 1)) DRINSTALLPARTS=$((DRINSTALLPARTS + 1))
done done


if [[ $DRINSTALLPARTS = 1 ]] && ! command -v "$DRACUT_INSTALL" > /dev/null 2>&1; then if [[ $DRINSTALLPARTS == 1 ]] && ! command -v "$DRACUT_INSTALL" > /dev/null 2>&1; then
dfatal "dracut-install not found!" dfatal "dracut-install not found!"
exit 10 exit 10
fi fi


if [[ $hostonly == "-h" ]]; then if [[ $hostonly == "-h" ]]; then
if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f "$DRACUT_KERNEL_MODALIASES" ]]; then if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f $DRACUT_KERNEL_MODALIASES ]]; then
export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases" export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases"
"$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES" "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES"
fi fi
@ -219,7 +219,7 @@ inst_dir() {


inst() { inst() {
local _hostonly_install local _hostonly_install
if [[ "$1" == "-H" ]]; then if [[ $1 == "-H" ]]; then
_hostonly_install="-H" _hostonly_install="-H"
shift shift
fi fi
@ -232,7 +232,7 @@ inst() {


inst_simple() { inst_simple() {
local _hostonly_install local _hostonly_install
if [[ "$1" == "-H" ]]; then if [[ $1 == "-H" ]]; then
_hostonly_install="-H" _hostonly_install="-H"
shift shift
fi fi
@ -245,7 +245,7 @@ inst_simple() {


inst_symlink() { inst_symlink() {
local _hostonly_install local _hostonly_install
if [[ "$1" == "-H" ]]; then if [[ $1 == "-H" ]]; then
_hostonly_install="-H" _hostonly_install="-H"
shift shift
fi fi
@ -275,7 +275,7 @@ dracut_instmods() {
local _silent=0 local _silent=0
local i local i
# shellcheck disable=SC2154 # shellcheck disable=SC2154
[[ $no_kernel = yes ]] && return [[ $no_kernel == yes ]] && return
for i in "$@"; do for i in "$@"; do
[[ $i == "--silent" ]] && _silent=1 [[ $i == "--silent" ]] && _silent=1
done done
@ -292,7 +292,7 @@ dracut_instmods() {


inst_library() { inst_library() {
local _hostonly_install local _hostonly_install
if [[ "$1" == "-H" ]]; then if [[ $1 == "-H" ]]; then
_hostonly_install="-H" _hostonly_install="-H"
shift shift
fi fi
@ -328,7 +328,7 @@ inst_fsck_help() {
# given modules. # given modules.
optional_hostonly() { optional_hostonly() {
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [[ $hostonly_mode = "strict" ]]; then if [[ $hostonly_mode == "strict" ]]; then
printf -- "%s" "$hostonly" printf -- "%s" "$hostonly"
else else
printf "" printf ""
@ -382,7 +382,7 @@ inst_rule_programs() {
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [[ -x ${udevdir}/$_prog ]]; then if [[ -x ${udevdir}/$_prog ]]; then
_bin="${udevdir}"/$_prog _bin="${udevdir}"/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then elif [[ ${_prog/\$env\{/} == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || { _bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue continue
@ -397,7 +397,7 @@ inst_rule_programs() {
_bin="" _bin=""
if [[ -x ${udevdir}/$_prog ]]; then if [[ -x ${udevdir}/$_prog ]]; then
_bin=${udevdir}/$_prog _bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then elif [[ ${_prog/\$env\{/} == "$_prog" ]] && [[ ${_prog} != "/sbin/initqueue" ]]; then
_bin=$(find_binary "$_prog") || { _bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue continue
@ -412,7 +412,7 @@ inst_rule_programs() {
_bin="" _bin=""
if [[ -x ${udevdir}/$_prog ]]; then if [[ -x ${udevdir}/$_prog ]]; then
_bin=${udevdir}/$_prog _bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then elif [[ ${_prog/\$env\{/} == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || { _bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue continue
@ -554,7 +554,7 @@ inst_hook() {
dfatal "Cannot install a hook ($3) that does not exist." dfatal "Cannot install a hook ($3) that does not exist."
dfatal "Aborting initrd creation." dfatal "Aborting initrd creation."
exit 1 exit 1
elif ! [[ "$hookdirs" == *$1* ]]; then elif ! [[ $hookdirs == *$1* ]]; then
dfatal "No such hook type $1. Aborting initrd creation." dfatal "No such hook type $1. Aborting initrd creation."
exit 1 exit 1
fi fi
@ -577,7 +577,7 @@ inst_hook() {
inst_any() { inst_any() {
local to f local to f


[[ $1 = '-d' ]] && to="$2" && shift 2 [[ $1 == '-d' ]] && to="$2" && shift 2


for f in "$@"; do for f in "$@"; do
[[ -e $f ]] || continue [[ -e $f ]] || continue
@ -593,14 +593,14 @@ inst_any() {
# -n <pattern> install matching files # -n <pattern> install matching files
inst_libdir_file() { inst_libdir_file() {
local -a _files local -a _files
if [[ "$1" == "-n" ]]; then if [[ $1 == "-n" ]]; then
local _pattern=$2 local _pattern=$2
shift 2 shift 2
for _dir in $libdirs; do for _dir in $libdirs; do
for _i in "$@"; do for _i in "$@"; do
for _f in "$dracutsysrootdir$_dir"/$_i; do for _f in "$dracutsysrootdir$_dir"/$_i; do
[[ "${_f#$dracutsysrootdir}" =~ $_pattern ]] || continue [[ ${_f#$dracutsysrootdir} =~ $_pattern ]] || continue
[[ -e "$_f" ]] && _files+=("${_f#$dracutsysrootdir}") [[ -e $_f ]] && _files+=("${_f#$dracutsysrootdir}")
done done
done done
done done
@ -608,7 +608,7 @@ inst_libdir_file() {
for _dir in $libdirs; do for _dir in $libdirs; do
for _i in "$@"; do for _i in "$@"; do
for _f in "$dracutsysrootdir$_dir"/$_i; do for _f in "$dracutsysrootdir$_dir"/$_i; do
[[ -e "$_f" ]] && _files+=("${_f#$dracutsysrootdir}") [[ -e $_f ]] && _files+=("${_f#$dracutsysrootdir}")
done done
done done
done done
@ -635,7 +635,7 @@ inst_decompress() {


for _src in "$@"; do for _src in "$@"; do
_cmd=$(get_decompress_cmd "${_src}") _cmd=$(get_decompress_cmd "${_src}")
[[ -z "${_cmd}" ]] && return 1 [[ -z ${_cmd} ]] && return 1
inst_simple "${_src}" inst_simple "${_src}"
# Decompress with chosen tool. We assume that tool changes name e.g. # Decompress with chosen tool. We assume that tool changes name e.g.
# from 'name.gz' to 'name'. # from 'name.gz' to 'name'.
@ -839,10 +839,10 @@ check_mount() {
ret=$? ret=$?


# explicit module, so also accept ret=255 # explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1 [[ $ret == 0 || $ret == 255 ]] || return 1
else else
# module not in our list # module not in our list
if [[ $dracutmodules = all ]]; then if [[ $dracutmodules == all ]]; then
# check, if we can and should install this module # check, if we can and should install this module
module_check_mount "$_mod" "$_moddir" || return 1 module_check_mount "$_mod" "$_moddir" || return 1
else else
@ -909,10 +909,10 @@ check_module() {
ret=$? ret=$?
fi fi
# explicit module, so also accept ret=255 # explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1 [[ $ret == 0 || $ret == 255 ]] || return 1
else else
# module not in our list # module not in our list
if [[ $dracutmodules = all ]]; then if [[ $dracutmodules == all ]]; then
# check, if we can and should install this module # check, if we can and should install this module
module_check "$_mod" 0 "$_moddir" module_check "$_mod" 0 "$_moddir"
ret=$? ret=$?
@ -1010,13 +1010,13 @@ instmods() {
local _silent local _silent
local _ret local _ret


[[ $no_kernel = yes ]] && return [[ $no_kernel == yes ]] && return


if [[ $1 = '-c' ]]; then if [[ $1 == '-c' ]]; then
unset _optional unset _optional
shift shift
fi fi
if [[ $1 = '-s' ]]; then if [[ $1 == '-s' ]]; then
_silent=1 _silent=1
shift shift
fi fi
@ -1042,7 +1042,7 @@ instmods() {
-m "$@" -m "$@"
_ret=$? _ret=$?


if ((_ret != 0)) && [[ -z "$_silent" ]]; then if ((_ret != 0)) && [[ -z $_silent ]]; then
derror "FAILED: " \ derror "FAILED: " \
"$DRACUT_INSTALL" \ "$DRACUT_INSTALL" \
${initdir:+-D "$initdir"} \ ${initdir:+-D "$initdir"} \
@ -1068,7 +1068,7 @@ else
ln_r() { ln_r() {
local _source=$1 local _source=$1
local _dest=$2 local _dest=$2
[[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} [[ -d ${_dest%/*} ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
ln -sfn -- "$(convert_abs_rel "${_dest}" "${_source}")" "${initdir}/${_dest}" ln -sfn -- "$(convert_abs_rel "${_dest}" "${_source}")" "${initdir}/${_dest}"
} }
fi fi
@ -1081,17 +1081,17 @@ is_qemu_virtualized() {
if ! vm=$(systemd-detect-virt --vm > /dev/null 2>&1); then if ! vm=$(systemd-detect-virt --vm > /dev/null 2>&1); then
return 255 return 255
fi fi
[[ $vm = "qemu" ]] && return 0 [[ $vm == "qemu" ]] && return 0
[[ $vm = "kvm" ]] && return 0 [[ $vm == "kvm" ]] && return 0
[[ $vm = "bochs" ]] && return 0 [[ $vm == "bochs" ]] && return 0
fi fi


for i in /sys/class/dmi/id/*_vendor; do for i in /sys/class/dmi/id/*_vendor; do
[[ -f $i ]] || continue [[ -f $i ]] || continue
read -r vendor < "$i" read -r vendor < "$i"
[[ "$vendor" == "QEMU" ]] && return 0 [[ $vendor == "QEMU" ]] && return 0
[[ "$vendor" == "Red Hat" ]] && return 0 [[ $vendor == "Red Hat" ]] && return 0
[[ "$vendor" == "Bochs" ]] && return 0 [[ $vendor == "Bochs" ]] && return 0
done done
return 1 return 1
} }

View File

@ -332,7 +332,7 @@ _do_dlog() {
fi fi
fi fi


if ((lvl <= fileloglvl)) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then if ((lvl <= fileloglvl)) && [[ -w $logfile ]] && [[ -f $logfile ]]; then
echo "$lmsg" >> "$logfile" echo "$lmsg" >> "$logfile"
fi fi



136
dracut.sh
View File

@ -310,7 +310,7 @@ dropindirs_sort() {


for d in "$@"; do for d in "$@"; do
for i in "$d/"*"$suffix"; do for i in "$d/"*"$suffix"; do
if [[ -e "$i" ]]; then if [[ -e $i ]]; then
printf "%s\n" "${i##*/}" printf "%s\n" "${i##*/}"
fi fi
done done
@ -928,11 +928,11 @@ for i in $DRACUT_PATH; do
rl=$(readlink -f "$dracutsysrootdir$i") rl=$(readlink -f "$dracutsysrootdir$i")
fi fi
rl="${rl#$dracutsysrootdir}" rl="${rl#$dracutsysrootdir}"
if [[ "$NPATH" != *:$rl* ]]; then if [[ $NPATH != *:$rl* ]]; then
NPATH+=":$rl" NPATH+=":$rl"
fi fi
done done
[[ -z "$dracutsysrootdir" ]] && export PATH="${NPATH#:}" [[ -z $dracutsysrootdir ]] && export PATH="${NPATH#:}"
unset NPATH unset NPATH


export SYSTEMCTL=${SYSTEMCTL:-systemctl} export SYSTEMCTL=${SYSTEMCTL:-systemctl}
@ -965,11 +965,11 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l [[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l
[[ $do_hardlink ]] || do_hardlink=yes [[ $do_hardlink ]] || do_hardlink=yes
[[ $prefix_l ]] && prefix=$prefix_l [[ $prefix_l ]] && prefix=$prefix_l
[[ $prefix = "/" ]] && unset prefix [[ $prefix == "/" ]] && unset prefix
[[ $hostonly_l ]] && hostonly=$hostonly_l [[ $hostonly_l ]] && hostonly=$hostonly_l
[[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l [[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l
[[ $hostonly_mode_l ]] && hostonly_mode=$hostonly_mode_l [[ $hostonly_mode_l ]] && hostonly_mode=$hostonly_mode_l
[[ "$hostonly" == "yes" ]] && ! [[ $hostonly_cmdline ]] && hostonly_cmdline="yes" [[ $hostonly == "yes" ]] && ! [[ $hostonly_cmdline ]] && hostonly_cmdline="yes"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
[[ $i18n_install_all_l ]] && i18n_install_all=$i18n_install_all_l [[ $i18n_install_all_l ]] && i18n_install_all=$i18n_install_all_l
# shellcheck disable=SC2034 # shellcheck disable=SC2034
@ -1008,12 +1008,12 @@ if ! [[ $outfile ]]; then


if [[ $uefi == "yes" ]]; then if [[ $uefi == "yes" ]]; then
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [[ -n "$uefi_secureboot_key" && -z "$uefi_secureboot_cert" ]] || [[ -z $uefi_secureboot_key && -n $uefi_secureboot_cert ]]; then if [[ -n $uefi_secureboot_key && -z $uefi_secureboot_cert ]] || [[ -z $uefi_secureboot_key && -n $uefi_secureboot_cert ]]; then
dfatal "Need 'uefi_secureboot_key' and 'uefi_secureboot_cert' both to be set." dfatal "Need 'uefi_secureboot_key' and 'uefi_secureboot_cert' both to be set."
exit 1 exit 1
fi fi


if [[ -n "$uefi_secureboot_key" && -n "$uefi_secureboot_cert" ]] && ! command -v sbsign &> /dev/null; then if [[ -n $uefi_secureboot_key && -n $uefi_secureboot_cert ]] && ! command -v sbsign &> /dev/null; then
dfatal "Need 'sbsign' to create a signed UEFI executable" dfatal "Need 'sbsign' to create a signed UEFI executable"
exit 1 exit 1
fi fi
@ -1055,8 +1055,8 @@ export DRACUT_FIRMWARE_PATH=${fw_dir// /:}
fw_dir=${fw_dir//:/ } fw_dir=${fw_dir//:/ }


# check for logfile and try to create one if it doesn't exist # check for logfile and try to create one if it doesn't exist
if [[ -n "$logfile" ]]; then if [[ -n $logfile ]]; then
if [[ ! -f "$logfile" ]]; then if [[ ! -f $logfile ]]; then
if touch "$logfile"; then if touch "$logfile"; then
printf "%s\n" "dracut: touch $logfile failed." >&2 printf "%s\n" "dracut: touch $logfile failed." >&2
fi fi
@ -1075,11 +1075,11 @@ DRACUT_COMPRESS_ZSTD=${DRACUT_COMPRESS_ZSTD:-zstd}
DRACUT_COMPRESS_LZ4=${DRACUT_COMPRESS_LZ4:-lz4} DRACUT_COMPRESS_LZ4=${DRACUT_COMPRESS_LZ4:-lz4}
DRACUT_COMPRESS_CAT=${DRACUT_COMPRESS_CAT:-cat} DRACUT_COMPRESS_CAT=${DRACUT_COMPRESS_CAT:-cat}


if [[ $_no_compress_l = "$DRACUT_COMPRESS_CAT" ]]; then if [[ $_no_compress_l == "$DRACUT_COMPRESS_CAT" ]]; then
compress="$DRACUT_COMPRESS_CAT" compress="$DRACUT_COMPRESS_CAT"
fi fi


[[ $hostonly = yes ]] && hostonly="-h" [[ $hostonly == yes ]] && hostonly="-h"
[[ $hostonly != "-h" ]] && unset hostonly [[ $hostonly != "-h" ]] && unset hostonly


case $hostonly_mode in case $hostonly_mode in
@ -1103,7 +1103,7 @@ case "${drivers_dir}" in
'' | *lib/modules/${kernel} | *lib/modules/${kernel}/) ;; '' | *lib/modules/${kernel} | *lib/modules/${kernel}/) ;;
*) *)
[[ "$DRACUT_KMODDIR_OVERRIDE" ]] || { [[ "$DRACUT_KMODDIR_OVERRIDE" ]] || {
printf "%s\n" "dracut: -k/--kmoddir path must contain \"lib/modules\" as a parent of your kernel module directory," printf "%s\n" 'dracut: -k/--kmoddir path must contain "lib/modules" as a parent of your kernel module directory,'
printf "%s\n" "dracut: or modules may not be placed in the correct location inside the initramfs." printf "%s\n" "dracut: or modules may not be placed in the correct location inside the initramfs."
printf "%s\n" "dracut: was given: ${drivers_dir}" printf "%s\n" "dracut: was given: ${drivers_dir}"
printf "%s\n" "dracut: expected: $(dirname "${drivers_dir}")/lib/modules/${kernel}" printf "%s\n" "dracut: expected: $(dirname "${drivers_dir}")/lib/modules/${kernel}"
@ -1148,7 +1148,7 @@ readonly initdir="${DRACUT_TMPDIR}/initramfs"
mkdir -p "$initdir" mkdir -p "$initdir"


# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [[ $early_microcode = yes ]] || { [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; }; then if [[ $early_microcode == yes ]] || { [[ $acpi_override == yes ]] && [[ -d $acpi_table_dir ]]; }; then
readonly early_cpio_dir="${DRACUT_TMPDIR}/earlycpio" readonly early_cpio_dir="${DRACUT_TMPDIR}/earlycpio"
mkdir "$early_cpio_dir" mkdir "$early_cpio_dir"
fi fi
@ -1221,14 +1221,14 @@ unset omit_drivers_corrected


# prepare args for logging # prepare args for logging
for ((i = 0; i < ${#dracut_args[@]}; i++)); do for ((i = 0; i < ${#dracut_args[@]}; i++)); do
[[ "${dracut_args[$i]}" == *\ * ]] \ [[ ${dracut_args[$i]} == *\ * ]] \
&& dracut_args[$i]="\"${dracut_args[$i]}\"" && dracut_args[$i]="\"${dracut_args[$i]}\""
#" keep vim happy #" keep vim happy
done done


dinfo "Executing: $dracut_cmd ${dracut_args[*]}" dinfo "Executing: $dracut_cmd ${dracut_args[*]}"


[[ $do_list = yes ]] && { [[ $do_list == yes ]] && {
for mod in "$dracutbasedir"/modules.d/*; do for mod in "$dracutbasedir"/modules.d/*; do
[[ -d $mod ]] || continue [[ -d $mod ]] || continue
[[ -e $mod/install || -e $mod/installkernel || -e \ [[ -e $mod/install || -e $mod/installkernel || -e \
@ -1294,13 +1294,13 @@ if [[ ! $print_cmdline ]]; then
outdir=${outfile%/*} outdir=${outfile%/*}
[[ $outdir ]] || outdir="/" [[ $outdir ]] || outdir="/"


if [[ ! -d "$outdir" ]]; then if [[ ! -d $outdir ]]; then
dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible." dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
exit 1 exit 1
elif [[ ! -w "$outdir" ]]; then elif [[ ! -w $outdir ]]; then
dfatal "No permission to write to $outdir." dfatal "No permission to write to $outdir."
exit 1 exit 1
elif [[ -f "$outfile" && ! -w "$outfile" ]]; then elif [[ -f $outfile && ! -w $outfile ]]; then
dfatal "No permission to write $outfile." dfatal "No permission to write $outfile."
exit 1 exit 1
fi fi
@ -1313,7 +1313,7 @@ if [[ ! $print_cmdline ]]; then
loginstall=$(readlink -f "$loginstall") loginstall=$(readlink -f "$loginstall")
fi fi


if [[ $uefi = yes ]]; then if [[ $uefi == yes ]]; then
if ! command -v objcopy &> /dev/null; then if ! command -v objcopy &> /dev/null; then
dfatal "Need 'objcopy' to create a UEFI executable" dfatal "Need 'objcopy' to create a UEFI executable"
exit 1 exit 1
@ -1347,7 +1347,7 @@ if [[ ! $print_cmdline ]]; then


if ! [[ $kernel_image ]]; then if ! [[ $kernel_image ]]; then
for kernel_image in "$dracutsysrootdir/lib/modules/$kernel/vmlinuz" "$dracutsysrootdir/boot/vmlinuz-$kernel"; do for kernel_image in "$dracutsysrootdir/lib/modules/$kernel/vmlinuz" "$dracutsysrootdir/boot/vmlinuz-$kernel"; do
[[ -s "$kernel_image" ]] || continue [[ -s $kernel_image ]] || continue
break break
done done
fi fi
@ -1358,12 +1358,12 @@ if [[ ! $print_cmdline ]]; then
fi fi
fi fi


if [[ $acpi_override = yes ]] && ! (check_kernel_config CONFIG_ACPI_TABLE_UPGRADE || check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE); then if [[ $acpi_override == yes ]] && ! (check_kernel_config CONFIG_ACPI_TABLE_UPGRADE || check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE); then
dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y or CONFIG_ACPI_TABLE_UPGRADE!=y" dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y or CONFIG_ACPI_TABLE_UPGRADE!=y"
unset acpi_override unset acpi_override
fi fi


if [[ $early_microcode = yes ]]; then if [[ $early_microcode == yes ]]; then
if [[ $hostonly ]]; then if [[ $hostonly ]]; then
if [[ $(get_cpu_vendor) == "AMD" ]]; then if [[ $(get_cpu_vendor) == "AMD" ]]; then
check_kernel_config CONFIG_MICROCODE_AMD || unset early_microcode check_kernel_config CONFIG_MICROCODE_AMD || unset early_microcode
@ -1421,7 +1421,7 @@ for line in "${fstab_lines[@]}"; do
;; ;;
esac esac
[ -z "$dev" ] && dwarn "Bad fstab entry $*" && continue [ -z "$dev" ] && dwarn "Bad fstab entry $*" && continue
if [[ "$3" == btrfs ]]; then if [[ $3 == btrfs ]]; then
for i in $(btrfs_devs "$2"); do for i in $(btrfs_devs "$2"); do
push_host_devs "$i" push_host_devs "$i"
done done
@ -1446,7 +1446,7 @@ if ((${#add_device_l[@]})); then
push_host_devs "${add_device_l[@]}" push_host_devs "${add_device_l[@]}"
fi fi


if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then if [[ $hostonly ]] && [[ $hostonly_default_device != "no" ]]; then
# in hostonly mode, determine all devices, which have to be accessed # in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types # and examine them for filesystem types


@ -1470,11 +1470,11 @@ if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
_dev=$(find_block_device "$mp") _dev=$(find_block_device "$mp")
_bdev=$(readlink -f "/dev/block/$_dev") _bdev=$(readlink -f "/dev/block/$_dev")
[[ -b $_bdev ]] && _dev=$_bdev [[ -b $_bdev ]] && _dev=$_bdev
[[ "$mp" == "/" ]] && root_devs+=("$_dev") [[ $mp == "/" ]] && root_devs+=("$_dev")
push_host_devs "$_dev" push_host_devs "$_dev"
if [[ $(find_mp_fstype "$mp") == btrfs ]]; then if [[ $(find_mp_fstype "$mp") == btrfs ]]; then
for i in $(btrfs_devs "$mp"); do for i in $(btrfs_devs "$mp"); do
[[ "$mp" == "/" ]] && root_devs+=("$i") [[ $mp == "/" ]] && root_devs+=("$i")
push_host_devs "$i" push_host_devs "$i"
done done
fi fi
@ -1484,24 +1484,24 @@ if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
if [[ -f /proc/swaps ]] && [[ -f $dracutsysrootdir/etc/fstab ]]; then if [[ -f /proc/swaps ]] && [[ -f $dracutsysrootdir/etc/fstab ]]; then
while read -r dev type rest || [ -n "$dev" ]; do while read -r dev type rest || [ -n "$dev" ]; do
[[ -b $dev ]] || continue [[ -b $dev ]] || continue
[[ "$type" == "partition" ]] || continue [[ $type == "partition" ]] || continue


while read -r _d _m _t _o _ || [ -n "$_d" ]; do while read -r _d _m _t _o _ || [ -n "$_d" ]; do
[[ "$_d" == \#* ]] && continue [[ $_d == \#* ]] && continue
[[ $_d ]] || continue [[ $_d ]] || continue
[[ $_t != "swap" ]] && continue [[ $_t != "swap" ]] && continue
[[ $_m != "swap" ]] && [[ $_m != "none" ]] && continue [[ $_m != "swap" ]] && [[ $_m != "none" ]] && continue
[[ "$_o" == *noauto* ]] && continue [[ $_o == *noauto* ]] && continue
_d=$(expand_persistent_dev "$_d") _d=$(expand_persistent_dev "$_d")
[[ "$_d" -ef "$dev" ]] || continue [[ $_d -ef $dev ]] || continue


if [[ -f $dracutsysrootdir/etc/crypttab ]]; then if [[ -f $dracutsysrootdir/etc/crypttab ]]; then
while read -r _mapper _ _p _o || [ -n "$_mapper" ]; do while read -r _mapper _ _p _o || [ -n "$_mapper" ]; do
[[ $_mapper = \#* ]] && continue [[ $_mapper == \#* ]] && continue
[[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue [[ $_d -ef /dev/mapper/"$_mapper" ]] || continue
[[ "$_o" ]] || _o="$_p" [[ "$_o" ]] || _o="$_p"
# skip entries with password files # skip entries with password files
[[ "$_p" == /* ]] && [[ -f $_p ]] && continue 2 [[ $_p == /* ]] && [[ -f $_p ]] && continue 2
# skip mkswap swap # skip mkswap swap
[[ $_o == *swap* ]] && continue 2 [[ $_o == *swap* ]] && continue 2
done < "$dracutsysrootdir"/etc/crypttab done < "$dracutsysrootdir"/etc/crypttab
@ -1518,15 +1518,15 @@ if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
# collect all "x-initrd.mount" entries from /etc/fstab # collect all "x-initrd.mount" entries from /etc/fstab
if [[ -f $dracutsysrootdir/etc/fstab ]]; then if [[ -f $dracutsysrootdir/etc/fstab ]]; then
while read -r _d _m _t _o _ || [ -n "$_d" ]; do while read -r _d _m _t _o _ || [ -n "$_d" ]; do
[[ "$_d" == \#* ]] && continue [[ $_d == \#* ]] && continue
[[ $_d ]] || continue [[ $_d ]] || continue
[[ "$_o" != *x-initrd.mount* ]] && continue [[ $_o != *x-initrd.mount* ]] && continue
_dev=$(expand_persistent_dev "$_d") _dev=$(expand_persistent_dev "$_d")
_dev="$(readlink -f "$_dev")" _dev="$(readlink -f "$_dev")"
[[ -b $_dev ]] || continue [[ -b $_dev ]] || continue


push_host_devs "$_dev" push_host_devs "$_dev"
if [[ "$_t" == btrfs ]]; then if [[ $_t == btrfs ]]; then
for i in $(btrfs_devs "$_m"); do for i in $(btrfs_devs "$_m"); do
push_host_devs "$i" push_host_devs "$i"
done done
@ -1561,11 +1561,11 @@ for dev in "${host_devs[@]}"; do
done done


for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ ${host_fs_types[$dev]} = "reiserfs" ]] || [[ ${host_fs_types[$dev]} = "xfs" ]] || continue [[ ${host_fs_types[$dev]} == "reiserfs" ]] || [[ ${host_fs_types[$dev]} == "xfs" ]] || continue
rootopts=$(find_dev_fsopts "$dev") rootopts=$(find_dev_fsopts "$dev")
if [[ ${host_fs_types[$dev]} = "reiserfs" ]]; then if [[ ${host_fs_types[$dev]} == "reiserfs" ]]; then
journaldev=$(fs_get_option "$rootopts" "jdev") journaldev=$(fs_get_option "$rootopts" "jdev")
elif [[ ${host_fs_types[$dev]} = "xfs" ]]; then elif [[ ${host_fs_types[$dev]} == "xfs" ]]; then
journaldev=$(fs_get_option "$rootopts" "logdev") journaldev=$(fs_get_option "$rootopts" "logdev")
fi fi
if [[ $journaldev ]]; then if [[ $journaldev ]]; then
@ -1794,7 +1794,7 @@ fi


if [[ $prefix ]]; then if [[ $prefix ]]; then
for d in bin etc lib sbin tmp usr var $libdirs; do for d in bin etc lib sbin tmp usr var $libdirs; do
[[ "$d" == */* ]] && continue [[ $d == */* ]] && continue
ln -sfn "${prefix#/}/${d#/}" "$initdir/$d" ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
done done
fi fi
@ -1842,7 +1842,7 @@ if [[ $kernel_only != yes ]]; then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -m 0755 -p "${initdir}/lib/dracut/hooks/$_d" mkdir -m 0755 -p "${initdir}/lib/dracut/hooks/$_d"
done done
if [[ "$EUID" = "0" ]]; then if [[ $EUID == "0" ]]; then
[[ -c ${initdir}/dev/null ]] || mknod "${initdir}"/dev/null c 1 3 [[ -c ${initdir}/dev/null ]] || mknod "${initdir}"/dev/null c 1 3
[[ -c ${initdir}/dev/kmsg ]] || mknod "${initdir}"/dev/kmsg c 1 11 [[ -c ${initdir}/dev/kmsg ]] || mknod "${initdir}"/dev/kmsg c 1 11
[[ -c ${initdir}/dev/console ]] || mknod "${initdir}"/dev/console c 5 1 [[ -c ${initdir}/dev/console ]] || mknod "${initdir}"/dev/console c 5 1
@ -1857,8 +1857,8 @@ modules_loaded=" "
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_d_mod=${moddir##*/} _d_mod=${moddir##*/}
_d_mod=${_d_mod#[0-9][0-9]} _d_mod=${_d_mod#[0-9][0-9]}
[[ "$mods_to_load" == *\ $_d_mod\ * ]] || continue [[ $mods_to_load == *\ $_d_mod\ * ]] || continue
if [[ $show_modules = yes ]]; then if [[ $show_modules == yes ]]; then
printf "%s\n" "$_d_mod" printf "%s\n" "$_d_mod"
else else
dinfo "*** Including module: $_d_mod ***" dinfo "*** Including module: $_d_mod ***"
@ -1902,7 +1902,7 @@ dinfo "*** Including modules done ***"


## final stuff that has to happen ## final stuff that has to happen
if [[ $no_kernel != yes ]]; then if [[ $no_kernel != yes ]]; then
if [[ $hostonly_mode = "strict" ]]; then if [[ $hostonly_mode == "strict" ]]; then
cp "$DRACUT_KERNEL_MODALIASES" "$initdir"/lib/dracut/hostonly-kernel-modules.txt cp "$DRACUT_KERNEL_MODALIASES" "$initdir"/lib/dracut/hostonly-kernel-modules.txt
fi fi


@ -1911,7 +1911,7 @@ if [[ $no_kernel != yes ]]; then
hostonly='' instmods $drivers hostonly='' instmods $drivers
fi fi


if [[ -n "${add_drivers// /}" ]]; then if [[ -n ${add_drivers// /} ]]; then
# shellcheck disable=SC2086 # shellcheck disable=SC2086
hostonly='' instmods -c $add_drivers hostonly='' instmods -c $add_drivers
fi fi
@ -2015,11 +2015,11 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
# symlinks to $prefix # symlinks to $prefix
# Objectname is a file or a directory # Objectname is a file or a directory
for objectname in "$src"/*; do for objectname in "$src"/*; do
[[ -e "$objectname" || -L "$objectname" ]] || continue [[ -e $objectname || -L $objectname ]] || continue
if [[ -d "$objectname" ]]; then if [[ -d $objectname ]]; then
# objectname is a directory, let's compute the final directory name # objectname is a directory, let's compute the final directory name
object_destdir=${destdir}/${objectname#$src/} object_destdir=${destdir}/${objectname#$src/}
if ! [[ -e "$object_destdir" ]]; then if ! [[ -e $object_destdir ]]; then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -m 0755 -p "$object_destdir" mkdir -m 0755 -p "$object_destdir"
chmod --reference="$objectname" "$object_destdir" chmod --reference="$objectname" "$object_destdir"
@ -2037,14 +2037,14 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
fi fi
done done


if [[ $do_hardlink = yes ]] && command -v hardlink > /dev/null; then if [[ $do_hardlink == yes ]] && command -v hardlink > /dev/null; then
dinfo "*** Hardlinking files ***" dinfo "*** Hardlinking files ***"
hardlink "$initdir" 2>&1 hardlink "$initdir" 2>&1
dinfo "*** Hardlinking files done ***" dinfo "*** Hardlinking files done ***"
fi fi


# strip binaries # strip binaries
if [[ $do_strip = yes ]]; then if [[ $do_strip == yes ]]; then
# Prefer strip from elfutils for package size # Prefer strip from elfutils for package size
declare strip_cmd declare strip_cmd
strip_cmd=$(command -v eu-strip) strip_cmd=$(command -v eu-strip)
@ -2063,7 +2063,7 @@ for d in $(ldconfig_paths); do
rmdir -p --ignore-fail-on-non-empty "$initdir/$d" > /dev/null 2>&1 rmdir -p --ignore-fail-on-non-empty "$initdir/$d" > /dev/null 2>&1
done done


if [[ $early_microcode = yes ]]; then if [[ $early_microcode == yes ]]; then
dinfo "*** Generating early-microcode cpio image ***" dinfo "*** Generating early-microcode cpio image ***"
ucode_dir=(amd-ucode intel-ucode) ucode_dir=(amd-ucode intel-ucode)
ucode_dest=(AuthenticAMD.bin GenuineIntel.bin) ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
@ -2092,7 +2092,7 @@ if [[ $early_microcode = yes ]]; then
break 2 break 2
done done
for i in $_fwdir/$_fw/$_src; do for i in $_fwdir/$_fw/$_src; do
[[ -e "$i" ]] || continue [[ -e $i ]] || continue
# skip gpg files # skip gpg files
str_ends "$i" ".asc" && continue str_ends "$i" ".asc" && continue
cat "$i" >> "$_dest_dir/${ucode_dest[$idx]}" cat "$i" >> "$_dest_dir/${ucode_dest[$idx]}"
@ -2119,7 +2119,7 @@ if [[ $early_microcode = yes ]]; then
done done
fi fi


if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then if [[ $acpi_override == yes ]] && [[ -d $acpi_table_dir ]]; then
dinfo "*** Packaging ACPI tables to override BIOS provided ones ***" dinfo "*** Packaging ACPI tables to override BIOS provided ones ***"
_dest_dir="$early_cpio_dir/d/kernel/firmware/acpi" _dest_dir="$early_cpio_dir/d/kernel/firmware/acpi"
mkdir -p "$_dest_dir" mkdir -p "$_dest_dir"
@ -2155,7 +2155,7 @@ if [[ $kernel_only != yes ]]; then
# libpthread workaround: pthread_cancel wants to dlopen libgcc_s.so # libpthread workaround: pthread_cancel wants to dlopen libgcc_s.so
for _dir in $libdirs; do for _dir in $libdirs; do
for _f in "$dracutsysrootdir$_dir/libpthread.so"*; do for _f in "$dracutsysrootdir$_dir/libpthread.so"*; do
[[ -e "$_f" ]] || continue [[ -e $_f ]] || continue
inst_libdir_file "libgcc_s.so*" inst_libdir_file "libgcc_s.so*"
break 2 break 2
done done
@ -2165,7 +2165,7 @@ if [[ $kernel_only != yes ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then if [[ $DRACUT_FIPS_MODE ]]; then
for _dir in $libdirs; do for _dir in $libdirs; do
for _f in "$dracutsysrootdir$_dir/libcrypto.so"*; do for _f in "$dracutsysrootdir$_dir/libcrypto.so"*; do
[[ -e "$_f" ]] || continue [[ -e $_f ]] || continue
inst_libdir_file -o "libssl.so*" inst_libdir_file -o "libssl.so*"
break 2 break 2
done done
@ -2179,7 +2179,7 @@ if [[ $kernel_only != yes ]]; then
[[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}" [[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}"
done done
if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then
if [[ $EUID = 0 ]]; then if [[ $EUID == 0 ]]; then
derror "ldconfig exited ungracefully" derror "ldconfig exited ungracefully"
else else
derror "ldconfig might need uid=0 (root) for chroot()" derror "ldconfig might need uid=0 (root) for chroot()"
@ -2195,7 +2195,7 @@ if dracut_module_included "squash"; then
DRACUT_SQUASH_POST_INST=1 module_install "squash" DRACUT_SQUASH_POST_INST=1 module_install "squash"
fi fi


if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then if [[ $do_strip == yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then
dinfo "*** Stripping files ***" dinfo "*** Stripping files ***"
find "$initdir" -type f \ find "$initdir" -type f \
-executable -not -path '*/lib/modules/*.ko' -print0 \ -executable -not -path '*/lib/modules/*.ko' -print0 \
@ -2239,7 +2239,7 @@ fi


dinfo "*** Creating image file '$outfile' ***" dinfo "*** Creating image file '$outfile' ***"


if [[ $uefi = yes ]]; then if [[ $uefi == yes ]]; then
readonly uefi_outdir="$DRACUT_TMPDIR/uefi" readonly uefi_outdir="$DRACUT_TMPDIR/uefi"
mkdir -p "$uefi_outdir" mkdir -p "$uefi_outdir"
fi fi
@ -2255,9 +2255,9 @@ if [[ $DRACUT_REPRODUCIBLE ]]; then
fi fi
fi fi


[[ "$EUID" != 0 ]] && cpio_owner="0:0" [[ $EUID != 0 ]] && cpio_owner="0:0"


if [[ $create_early_cpio = yes ]]; then if [[ $create_early_cpio == yes ]]; then
echo 1 > "$early_cpio_dir/d/early_cpio" echo 1 > "$early_cpio_dir/d/early_cpio"


if [[ $DRACUT_REPRODUCIBLE ]]; then if [[ $DRACUT_REPRODUCIBLE ]]; then
@ -2285,7 +2285,7 @@ if ! [[ $compress ]]; then
compress="$i" compress="$i"
break break
done done
if [[ $compress = cat ]]; then if [[ $compress == cat ]]; then
printf "%s\n" "dracut: no compression tool available. Initramfs image is going to be big." >&2 printf "%s\n" "dracut: no compression tool available. Initramfs image is going to be big." >&2
fi fi
fi fi
@ -2293,7 +2293,7 @@ fi
# choose the right arguments for the compressor # choose the right arguments for the compressor
case $compress in case $compress in
bzip2 | lbzip2) bzip2 | lbzip2)
if [[ "$compress" = lbzip2 ]] || command -v "$DRACUT_COMPRESS_LBZIP2" &> /dev/null; then if [[ $compress == lbzip2 ]] || command -v "$DRACUT_COMPRESS_LBZIP2" &> /dev/null; then
compress="$DRACUT_COMPRESS_LBZIP2 -9" compress="$DRACUT_COMPRESS_LBZIP2 -9"
else else
compress="$DRACUT_COMPRESS_BZIP2 -9" compress="$DRACUT_COMPRESS_BZIP2 -9"
@ -2306,7 +2306,7 @@ case $compress in
compress="$DRACUT_COMPRESS_XZ --check=crc32 --lzma2=dict=1MiB -T0" compress="$DRACUT_COMPRESS_XZ --check=crc32 --lzma2=dict=1MiB -T0"
;; ;;
gzip | pigz) gzip | pigz)
if [[ "$compress" = pigz ]] || command -v "$DRACUT_COMPRESS_PIGZ" &> /dev/null; then if [[ $compress == pigz ]] || command -v "$DRACUT_COMPRESS_PIGZ" &> /dev/null; then
compress="$DRACUT_COMPRESS_PIGZ -9 -n -T -R" compress="$DRACUT_COMPRESS_PIGZ -9 -n -T -R"
elif command -v gzip &> /dev/null && $DRACUT_COMPRESS_GZIP --help 2>&1 | grep -q rsyncable; then elif command -v gzip &> /dev/null && $DRACUT_COMPRESS_GZIP --help 2>&1 | grep -q rsyncable; then
compress="$DRACUT_COMPRESS_GZIP -n -9 --rsyncable" compress="$DRACUT_COMPRESS_GZIP -n -9 --rsyncable"
@ -2347,17 +2347,17 @@ fi


umask 077 umask 077


if [[ $uefi = yes ]]; then if [[ $uefi == yes ]]; then
if [[ $kernel_cmdline ]]; then if [[ $kernel_cmdline ]]; then
echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt" echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt"
elif [[ $hostonly_cmdline = yes ]] && [ -d "$initdir/etc/cmdline.d" ]; then elif [[ $hostonly_cmdline == yes ]] && [ -d "$initdir/etc/cmdline.d" ]; then
for conf in "$initdir"/etc/cmdline.d/*.conf; do for conf in "$initdir"/etc/cmdline.d/*.conf; do
[ -e "$conf" ] || continue [ -e "$conf" ] || continue
printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt" printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt"
done done
fi fi


if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline = yes && -d "$initdir/etc/cmdline.d" ]]; then if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline == yes && -d "$initdir/etc/cmdline.d" ]]; then
echo -ne "\x00" >> "$uefi_outdir/cmdline.txt" echo -ne "\x00" >> "$uefi_outdir/cmdline.txt"
dinfo "Using UEFI kernel cmdline:" dinfo "Using UEFI kernel cmdline:"
dinfo "$(tr -d '\000' < "$uefi_outdir/cmdline.txt")" dinfo "$(tr -d '\000' < "$uefi_outdir/cmdline.txt")"
@ -2381,7 +2381,7 @@ if [[ $uefi = yes ]]; then
--add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \ --add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \
--add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \ --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \
"$uefi_stub" "${uefi_outdir}/linux.efi"; then "$uefi_stub" "${uefi_outdir}/linux.efi"; then
if [[ -n "${uefi_secureboot_key}" && -n "${uefi_secureboot_cert}" ]]; then if [[ -n ${uefi_secureboot_key} && -n ${uefi_secureboot_cert} ]]; then
if sbsign \ if sbsign \
--key "${uefi_secureboot_key}" \ --key "${uefi_secureboot_key}" \
--cert "${uefi_secureboot_cert}" \ --cert "${uefi_secureboot_cert}" \
@ -2428,7 +2428,7 @@ freeze_ok_for_btrfs() {
mnt=$(stat -c %m -- "$1") mnt=$(stat -c %m -- "$1")
uuid1=$(btrfs_uuid "$mnt") uuid1=$(btrfs_uuid "$mnt")
uuid2=$(btrfs_uuid "/") uuid2=$(btrfs_uuid "/")
[[ "$uuid1" && "$uuid2" && "$uuid1" != "$uuid2" ]] [[ $uuid1 && $uuid2 && $uuid1 != "$uuid2" ]]
} }


freeze_ok_for_fstype() { freeze_ok_for_fstype() {

View File

@ -2,7 +2,7 @@


set -e set -e


if [[ -z "$DRACUT_TMPDIR" ]]; then if [[ -z $DRACUT_TMPDIR ]]; then
echo "DRACUT_TMPDIR is unset, exiting" echo "DRACUT_TMPDIR is unset, exiting"
exit 0 exit 0
fi fi

View File

@ -18,7 +18,7 @@
__contains_word() { __contains_word() {
local word="$1" local word="$1"
shift shift
for w in "$@"; do [[ $w = "$word" ]] && return 0; done for w in "$@"; do [[ $w == "$word" ]] && return 0; done
return 1 return 1
} }


@ -52,7 +52,7 @@ _lsinitrd() {
return 0 return 0
fi fi


if [[ $cur = -* ]]; then if [[ $cur == -* ]]; then
# shellcheck disable=SC2207 # shellcheck disable=SC2207
# shellcheck disable=SC2016 # shellcheck disable=SC2016
COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur")) COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur"))

View File

@ -99,7 +99,7 @@ done


if [[ $1 ]]; then if [[ $1 ]]; then
image="$1" image="$1"
if ! [[ -f "$image" ]]; then if ! [[ -f $image ]]; then
{ {
echo "$image does not exist" echo "$image does not exist"
echo echo
@ -129,7 +129,7 @@ while (($# > 0)); do
shift shift
done done


if ! [[ -f "$image" ]]; then if ! [[ -f $image ]]; then
{ {
echo "No <initramfs file> specified and the default image '$image' cannot be accessed!" echo "No <initramfs file> specified and the default image '$image' cannot be accessed!"
echo echo
@ -220,7 +220,7 @@ if [ "$bin" = "MZ" ]; then
[ -f "$image" ] || exit 1 [ -f "$image" ] || exit 1
fi fi


if ((${#filenames[@]} <= 0)) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]]; then if ((${#filenames[@]} <= 0)) && [[ -z $unpack ]] && [[ -z $unpackearly ]]; then
if [ -n "$uefi" ]; then if [ -n "$uefi" ]; then
echo -n "initrd in UEFI: $uefi: " echo -n "initrd in UEFI: $uefi: "
du -h $image | while read a b || [ -n "$a" ]; do echo $a; done du -h $image | while read a b || [ -n "$a" ]; do echo $a; done
@ -254,10 +254,10 @@ case $bin in
# Debian mkinitramfs does not create the file 'early_cpio', so let's check if firmware files exist # Debian mkinitramfs does not create the file 'early_cpio', so let's check if firmware files exist
[[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2> /dev/null) [[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2> /dev/null)
if [[ "$is_early" ]]; then if [[ "$is_early" ]]; then
if [[ -n "$unpack" ]]; then if [[ -n $unpack ]]; then
# should use --unpackearly for early CPIO # should use --unpackearly for early CPIO
: :
elif [[ -n "$unpackearly" ]]; then elif [[ -n $unpackearly ]]; then
unpack_files unpack_files
elif ((${#filenames[@]} > 0)); then elif ((${#filenames[@]} > 0)); then
extract_files extract_files
@ -333,7 +333,7 @@ fi


ret=0 ret=0


if [[ -n "$unpack" ]]; then if [[ -n $unpack ]]; then
unpack_files unpack_files
elif ((${#filenames[@]} > 0)); then elif ((${#filenames[@]} > 0)); then
extract_files extract_files

View File

@ -9,7 +9,7 @@ force=0
error() { echo "$@" >&2; } error() { echo "$@" >&2; }


usage() { usage() {
[[ $1 = '-n' ]] && cmd=echo || cmd=error [[ $1 == '-n' ]] && cmd=echo || cmd=error


$cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]" $cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]"
$cmd " [--image-version] [--with=<module>]" $cmd " [--image-version] [--with=<module>]"
@ -18,7 +18,7 @@ usage() {
$cmd "" $cmd ""
$cmd " (ex: ${0##*/} /boot/initramfs-$kver.img $kver)" $cmd " (ex: ${0##*/} /boot/initramfs-$kver.img $kver)"


[[ $1 = '-n' ]] && exit 0 [[ $1 == '-n' ]] && exit 0
exit 1 exit 1
} }


@ -34,17 +34,17 @@ read_arg() {
if [[ $2 =~ $rematch ]]; then if [[ $2 =~ $rematch ]]; then
read "$param" <<< "${BASH_REMATCH[1]}" read "$param" <<< "${BASH_REMATCH[1]}"
else else
for ((i = 3; $i <= $#; i++)); do for ((i = 3; i <= $#; i++)); do
# Only read next arg if it not an arg itself. # Only read next arg if it not an arg itself.
if [[ ${*:$i:1} = -* ]]; then if [[ ${*:i:1} == -* ]]; then
break break
fi fi
result="$result ${@:$i:1}" result="$result ${@:i:1}"
# There is no way to shift our callers args, so # There is no way to shift our callers args, so
# return "no of args" to indicate they should do it instead. # return "no of args" to indicate they should do it instead.
done done
read "$1" <<< "$result" read "$1" <<< "$result"
return $(($i - 3)) return $((i - 3))
fi fi
} }


@ -210,7 +210,7 @@ targets=($targets)
[[ $force == 1 ]] && dracut_args="${dracut_args} -f" [[ $force == 1 ]] && dracut_args="${dracut_args} -f"


echo "Creating: target|kernel|dracut args|basicmodules " echo "Creating: target|kernel|dracut args|basicmodules "
for ((i = 0; $i < ${#targets[@]}; i++)); do for ((i = 0; i < ${#targets[@]}; i++)); do


if [[ $img_vers ]]; then if [[ $img_vers ]]; then
target="${targets[$i]}-${kernels[$i]}" target="${targets[$i]}-${kernels[$i]}"

View File

@ -26,7 +26,7 @@ dracut_cmd=dracut
error() { echo "$@" >&2; } error() { echo "$@" >&2; }


usage() { usage() {
[[ $1 = '-n' ]] && cmd=echo || cmd=error [[ $1 == '-n' ]] && cmd=echo || cmd=error


$cmd "usage: ${0##*/} [options]" $cmd "usage: ${0##*/} [options]"
$cmd "" $cmd ""
@ -37,27 +37,27 @@ usage() {
$cmd " for the root file system, or a network interface driver module for dhcp." $cmd " for the root file system, or a network interface driver module for dhcp."
$cmd "" $cmd ""
$cmd " options:" $cmd " options:"
$cmd " -f \"feature list\" Features to be enabled when generating initrd." $cmd ' -f "feature list" Features to be enabled when generating initrd.'
$cmd " Available features are:" $cmd " Available features are:"
$cmd " iscsi, md, multipath, lvm, lvm2," $cmd " iscsi, md, multipath, lvm, lvm2,"
$cmd " ifup, fcoe, dcbd" $cmd " ifup, fcoe, dcbd"
$cmd " -k \"kernel list\" List of kernel images for which initrd files are" $cmd ' -k "kernel list" List of kernel images for which initrd files are'
$cmd " created. Defaults to all kernels found in /boot." $cmd " created. Defaults to all kernels found in /boot."
$cmd " -i \"initrd list\" List of file names for the initrd; position have" $cmd ' -i "initrd list" List of file names for the initrd; position have'
$cmd " match to \"kernel list\". Defaults to all kernels" $cmd ' match to "kernel list". Defaults to all kernels'
$cmd " found in /boot." $cmd " found in /boot."
$cmd " -b boot_dir Boot directory. Defaults to /boot." $cmd " -b boot_dir Boot directory. Defaults to /boot."
$cmd " -t tmp_dir Temporary directory. Defaults to /var/tmp." $cmd " -t tmp_dir Temporary directory. Defaults to /var/tmp."
$cmd " -M map System.map file to use." $cmd " -M map System.map file to use."
$cmd " -A Create a so called \"monster initrd\" which" $cmd ' -A Create a so called "monster initrd" which'
$cmd " includes all features and modules possible." $cmd " includes all features and modules possible."
$cmd " -B Do not update bootloader configuration." $cmd " -B Do not update bootloader configuration."
$cmd " -v Verbose mode." $cmd " -v Verbose mode."
$cmd " -L Disable logging." $cmd " -L Disable logging."
$cmd " -h This help screen." $cmd " -h This help screen."
$cmd " -m \"module list\" Modules to include in initrd. Defaults to the" $cmd ' -m "module list" Modules to include in initrd. Defaults to the'
$cmd " INITRD_MODULES variable in /etc/sysconfig/kernel" $cmd " INITRD_MODULES variable in /etc/sysconfig/kernel"
$cmd " -u \"DomU module list\" Modules to include in initrd. Defaults to the" $cmd ' -u "DomU module list" Modules to include in initrd. Defaults to the'
$cmd " DOMU_INITRD_MODULES variable in" $cmd " DOMU_INITRD_MODULES variable in"
$cmd " /etc/sysconfig/kernel." $cmd " /etc/sysconfig/kernel."
$cmd " -d root_device Root device. Defaults to the device from" $cmd " -d root_device Root device. Defaults to the device from"
@ -69,7 +69,7 @@ usage() {
$cmd " -a acpi_dsdt Obsolete, do not use." $cmd " -a acpi_dsdt Obsolete, do not use."
$cmd " -s size Add splash animation and bootscreen to initrd." $cmd " -s size Add splash animation and bootscreen to initrd."


[[ $1 = '-n' ]] && exit 0 [[ $1 == '-n' ]] && exit 0
exit 1 exit 1
} }


@ -85,17 +85,17 @@ read_arg() {
if [[ $2 =~ $rematch ]]; then if [[ $2 =~ $rematch ]]; then
read "$param" <<< "${BASH_REMATCH[1]}" read "$param" <<< "${BASH_REMATCH[1]}"
else else
for ((i = 3; $i <= $#; i++)); do for ((i = 3; i <= $#; i++)); do
# Only read next arg if it not an arg itself. # Only read next arg if it not an arg itself.
if [[ ${*:$i:1} = -* ]]; then if [[ ${*:i:1} == -* ]]; then
break break
fi fi
result="$result ${@:$i:1}" result="$result ${@:i:1}"
# There is no way to shift our callers args, so # There is no way to shift our callers args, so
# return "no of args" to indicate they should do it instead. # return "no of args" to indicate they should do it instead.
done done
read "$1" <<< "$result" read "$1" <<< "$result"
return $(($i - 3)) return $((i - 3))
fi fi
} }


@ -104,7 +104,7 @@ calc_netmask() {
local prefix=$1 local prefix=$1


[ -z "$prefix" ] && return [ -z "$prefix" ] && return
mask=$((0xffffffff << (32 - $prefix))) mask=$((0xffffffff << (32 - prefix)))
byte1=$((mask >> 24)) byte1=$((mask >> 24))
byte2=$((mask >> 16)) byte2=$((mask >> 16))
byte3=$((mask >> 8)) byte3=$((mask >> 8))
@ -137,7 +137,7 @@ is_xen_kernel() {


for cfg in ${root_dir}/boot/config-$kversion $root_dir/lib/modules/$kversion/build/.config; do for cfg in ${root_dir}/boot/config-$kversion $root_dir/lib/modules/$kversion/build/.config; do
test -r $cfg || continue test -r $cfg || continue
grep -q "^CONFIG_XEN=y\$" $cfg grep -q '^CONFIG_XEN=y$' $cfg
return return
done done
test $kversion != "${kversion%-xen*}" test $kversion != "${kversion%-xen*}"
@ -146,7 +146,7 @@ is_xen_kernel() {


kernel_version_from_image() { kernel_version_from_image() {
local dir="${1%/*}/" local dir="${1%/*}/"
[[ "$dir" != "$1" ]] || dir="" [[ $dir != "$1" ]] || dir=""
local kernel_image="$1" kernel_image_gz="${dir}vmlinux-${1#*-}.gz" local kernel_image="$1" kernel_image_gz="${dir}vmlinux-${1#*-}.gz"
echo kernel_image_gz="'$kernel_image_gz'" >&2 echo kernel_image_gz="'$kernel_image_gz'" >&2


@ -337,7 +337,7 @@ shopt -s extglob


failed="" failed=""


for ((i = 0; $i < ${#targets[@]}; i++)); do for ((i = 0; i < ${#targets[@]}; i++)); do


if [[ $img_vers ]]; then if [[ $img_vers ]]; then
target="${targets[$i]}-${kernels[$i]}" target="${targets[$i]}-${kernels[$i]}"

View File

@ -40,8 +40,8 @@ installkernel() {
install() { install() {
local _mods local _mods


if [[ "$prefix" == /run/* ]]; then if [[ $prefix == /run/* ]]; then
dfatal "systemd does not work with a prefix, which contains \"/run\"!!" dfatal 'systemd does not work with a prefix, which contains "/run"!!'
exit 1 exit 1
fi fi



View File

@ -39,7 +39,7 @@ mount_boot() {
fi fi
[ -e $boot ] && break [ -e $boot ] && break
sleep 0.5 sleep 0.5
i=$(($i + 1)) i=$((i + 1))
[ $i -gt 40 ] && break [ $i -gt 40 ] && break
done done
fi fi

View File

@ -49,9 +49,9 @@ installkernel() {
done done


# with hostonly_default_device fs module for /boot is not installed by default # with hostonly_default_device fs module for /boot is not installed by default
if [[ $hostonly ]] && [[ "$hostonly_default_device" == "no" ]]; then if [[ $hostonly ]] && [[ $hostonly_default_device == "no" ]]; then
_bootfstype=$(find_mp_fstype /boot) _bootfstype=$(find_mp_fstype /boot)
if [[ -n "$_bootfstype" ]]; then if [[ -n $_bootfstype ]]; then
hostonly='' instmods $_bootfstype hostonly='' instmods $_bootfstype
else else
dwarning "Can't determine fs type for /boot, FIPS check may fail." dwarning "Can't determine fs type for /boot, FIPS check may fail."

View File

@ -13,7 +13,7 @@ check() {
# if no keys are present # if no keys are present
if [[ $hostonly ]]; then if [[ $hostonly ]]; then
x=$(echo "$dracutsysrootdir"/lib/modules/keys/*) x=$(echo "$dracutsysrootdir"/lib/modules/keys/*)
[[ "${x}" = "$dracutsysrootdir/lib/modules/keys/*" ]] && return 255 [[ ${x} == "$dracutsysrootdir/lib/modules/keys/*" ]] && return 255
fi fi


return 0 return 0
@ -32,7 +32,7 @@ install() {
inst_hook pre-trigger 01 "$moddir/load-modsign-keys.sh" inst_hook pre-trigger 01 "$moddir/load-modsign-keys.sh"


for x in "$dracutsysrootdir"/lib/modules/keys/*; do for x in "$dracutsysrootdir"/lib/modules/keys/*; do
[[ "${x}" = "$dracutsysrootdir/lib/modules/keys/*" ]] && break [[ ${x} == "$dracutsysrootdir/lib/modules/keys/*" ]] && break
inst_simple "${x#$dracutsysrootdir}" inst_simple "${x#$dracutsysrootdir}"
done done
} }

View File

@ -145,9 +145,9 @@ install() {


shopt -q -s nocasematch shopt -q -s nocasematch
if [[ ${UNICODE} ]]; then if [[ ${UNICODE} ]]; then
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]; then if [[ ${UNICODE} == YES || ${UNICODE} == 1 ]]; then
UNICODE=1 UNICODE=1
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]; then elif [[ ${UNICODE} == NO || ${UNICODE} == 0 ]]; then
UNICODE=0 UNICODE=0
else else
UNICODE='' UNICODE=''

View File

@ -2,12 +2,12 @@


ROOT="$1" ROOT="$1"


if [[ ! -d "$ROOT" ]]; then if [[ ! -d $ROOT ]]; then
echo "Usage: $0 <rootdir>" echo "Usage: $0 <rootdir>"
exit 1 exit 1
fi fi


if [[ "$ROOT" -ef / ]]; then if [[ $ROOT -ef / ]]; then
echo "Can't convert the running system." echo "Can't convert the running system."
echo "Please boot with 'rd.convertfs' on the kernel command line," echo "Please boot with 'rd.convertfs' on the kernel command line,"
echo "to update with the help of the initramfs," echo "to update with the help of the initramfs,"
@ -15,7 +15,7 @@ if [[ "$ROOT" -ef / ]]; then
exit 1 exit 1
fi fi


while [[ "$ROOT" != "${ROOT%/}" ]]; do while [[ $ROOT != "${ROOT%/}" ]]; do
ROOT=${ROOT%/} ROOT=${ROOT%/}
done done


@ -33,8 +33,8 @@ fi


needconvert() { needconvert() {
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64"; do for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64"; do
if [[ -e "$dir" ]]; then if [[ -e $dir ]]; then
[[ -L "$dir" ]] || return 0 [[ -L $dir ]] || return 0
fi fi
done done
return 1 return 1
@ -55,7 +55,7 @@ fi
testfile="$ROOT/.usrmovecheck$$" testfile="$ROOT/.usrmovecheck$$"
rm -f -- "$testfile" rm -f -- "$testfile"
> "$testfile" > "$testfile"
if [[ ! -e "$testfile" ]]; then if [[ ! -e $testfile ]]; then
echo "Cannot write to $ROOT/" echo "Cannot write to $ROOT/"
exit 1 exit 1
fi fi
@ -64,7 +64,7 @@ rm -f -- "$testfile"
testfile="$ROOT/usr/.usrmovecheck$$" testfile="$ROOT/usr/.usrmovecheck$$"
rm -f -- "$testfile" rm -f -- "$testfile"
> "$testfile" > "$testfile"
if [[ ! -e "$testfile" ]]; then if [[ ! -e $testfile ]]; then
echo "Cannot write to $ROOT/usr/" echo "Cannot write to $ROOT/usr/"
exit 1 exit 1
fi fi

View File

@ -58,7 +58,7 @@ do_dhclient() {
fi fi
fi fi


_COUNT=$(($_COUNT + 1)) _COUNT=$((_COUNT + 1))
[ $_COUNT -lt $_DHCPRETRY ] && sleep 1 [ $_COUNT -lt $_DHCPRETRY ] && sleep 1
done done
warn "dhcp for interface $netif failed" warn "dhcp for interface $netif failed"

View File

@ -87,7 +87,7 @@ do_dhcp() {
-lf /tmp/dhclient.$netif.lease \ -lf /tmp/dhclient.$netif.lease \
$netif \ $netif \
&& return 0 && return 0
_COUNT=$(($_COUNT + 1)) _COUNT=$((_COUNT + 1))
[ $_COUNT -lt $_DHCPRETRY ] && sleep 1 [ $_COUNT -lt $_DHCPRETRY ] && sleep 1
done done
warn "dhcp for interface $netif failed" warn "dhcp for interface $netif failed"
@ -102,7 +102,7 @@ load_ipv6() {
modprobe ipv6 modprobe ipv6
i=0 i=0
while [ ! -d /proc/sys/net/ipv6 ]; do while [ ! -d /proc/sys/net/ipv6 ]; do
i=$(($i + 1)) i=$((i + 1))
[ $i -gt 10 ] && break [ $i -gt 10 ] && break
sleep 0.1 sleep 0.1
done done

View File

@ -28,7 +28,7 @@ if [ -z "$NEEDBOOTDEV" ]; then
continue continue
;; ;;
esac esac
count=$(($count + 1)) count=$((count + 1))
done done
[ $count -gt 1 ] && NEEDBOOTDEV=1 [ $count -gt 1 ] && NEEDBOOTDEV=1
fi fi

View File

@ -214,7 +214,7 @@ set_ifname() {
done done
# otherwise, pick a new name and use that # otherwise, pick a new name and use that
while :; do while :; do
num=$(($num + 1)) num=$((num + 1))
[ -e /sys/class/net/$name$num ] && continue [ -e /sys/class/net/$name$num ] && continue
for n in $(getargs ifname=); do for n in $(getargs ifname=); do
[ "$name$num" = "${n%%:*}" ] && continue 2 [ "$name$num" = "${n%%:*}" ] && continue 2
@ -261,10 +261,10 @@ ibft_to_cmdline() {
echo $a echo $a
) )
# Skip invalid interfaces # Skip invalid interfaces
(($flags & 1)) || continue ((flags & 1)) || continue
# Skip interfaces not used for booting unless using multipath # Skip interfaces not used for booting unless using multipath
if ! getargbool 0 rd.iscsi.mp; then if ! getargbool 0 rd.iscsi.mp; then
(($flags & 2)) || continue ((flags & 2)) || continue
fi fi
[ -e ${iface}/dhcp ] && dhcp=$( [ -e ${iface}/dhcp ] && dhcp=$(
read a < ${iface}/dhcp read a < ${iface}/dhcp
@ -639,7 +639,7 @@ parse_ifname_opts() {
eth[0-9] | eth[0-9][0-9] | eth[0-9][0-9][0-9] | eth[0-9][0-9][0-9][0-9]) eth[0-9] | eth[0-9][0-9] | eth[0-9][0-9][0-9] | eth[0-9][0-9][0-9][0-9])
warn "ifname=$ifname_if uses the kernel name space for interfaces" warn "ifname=$ifname_if uses the kernel name space for interfaces"
warn "This can fail for multiple network interfaces and is discouraged!" warn "This can fail for multiple network interfaces and is discouraged!"
warn "Please use a custom name like \"netboot\" or \"bluesocket\"" warn 'Please use a custom name like "netboot" or "bluesocket"'
warn "or use biosdevname and no ifname= at all." warn "or use biosdevname and no ifname= at all."
;; ;;
esac esac
@ -652,13 +652,13 @@ wait_for_if_link() {
local li local li
local timeout="$(getargs rd.net.timeout.iflink=)" local timeout="$(getargs rd.net.timeout.iflink=)"
timeout=${timeout:-60} timeout=${timeout:-60}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


while [ $cnt -lt $timeout ]; do while [ $cnt -lt $timeout ]; do
li=$(ip link show dev $1 2> /dev/null) li=$(ip link show dev $1 2> /dev/null)
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -668,7 +668,7 @@ wait_for_if_up() {
local li local li
local timeout="$(getargs rd.net.timeout.ifup=)" local timeout="$(getargs rd.net.timeout.ifup=)"
timeout=${timeout:-20} timeout=${timeout:-20}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


while [ $cnt -lt $timeout ]; do while [ $cnt -lt $timeout ]; do
li=$(ip link show up dev $1) li=$(ip link show up dev $1)
@ -691,7 +691,7 @@ wait_for_if_up() {
return 0 return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -700,13 +700,13 @@ wait_for_route_ok() {
local cnt=0 local cnt=0
local timeout="$(getargs rd.net.timeout.route=)" local timeout="$(getargs rd.net.timeout.route=)"
timeout=${timeout:-20} timeout=${timeout:-20}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


while [ $cnt -lt $timeout ]; do while [ $cnt -lt $timeout ]; do
li=$(ip route show) li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -715,7 +715,7 @@ wait_for_ipv6_dad_link() {
local cnt=0 local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6dad=)" local timeout="$(getargs rd.net.timeout.ipv6dad=)"
timeout=${timeout:-50} timeout=${timeout:-50}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


while [ $cnt -lt $timeout ]; do while [ $cnt -lt $timeout ]; do
[ -n "$(ip -6 addr show dev "$1" scope link)" ] \ [ -n "$(ip -6 addr show dev "$1" scope link)" ] \
@ -724,7 +724,7 @@ wait_for_ipv6_dad_link() {
[ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \ [ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \
&& return 1 && return 1
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -733,7 +733,7 @@ wait_for_ipv6_dad() {
local cnt=0 local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6dad=)" local timeout="$(getargs rd.net.timeout.ipv6dad=)"
timeout=${timeout:-50} timeout=${timeout:-50}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


while [ $cnt -lt $timeout ]; do while [ $cnt -lt $timeout ]; do
[ -n "$(ip -6 addr show dev "$1")" ] \ [ -n "$(ip -6 addr show dev "$1")" ] \
@ -743,7 +743,7 @@ wait_for_ipv6_dad() {
[ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \ [ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \
&& return 1 && return 1
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -752,14 +752,14 @@ wait_for_ipv6_auto() {
local cnt=0 local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6auto=)" local timeout="$(getargs rd.net.timeout.ipv6auto=)"
timeout=${timeout:-40} timeout=${timeout:-40}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


while [ $cnt -lt $timeout ]; do while [ $cnt -lt $timeout ]; do
[ -z "$(ip -6 addr show dev "$1" tentative)" ] \ [ -z "$(ip -6 addr show dev "$1" tentative)" ] \
&& [ -n "$(ip -6 route list proto ra dev "$1" | grep ^default)" ] \ && [ -n "$(ip -6 route list proto ra dev "$1" | grep ^default)" ] \
&& return 0 && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -781,7 +781,7 @@ iface_has_carrier() {
[ -d "$interface" ] || return 2 [ -d "$interface" ] || return 2
local timeout="$(getargs rd.net.timeout.carrier=)" local timeout="$(getargs rd.net.timeout.carrier=)"
timeout=${timeout:-10} timeout=${timeout:-10}
timeout=$(($timeout * 10)) timeout=$((timeout * 10))


linkup "$1" linkup "$1"


@ -800,7 +800,7 @@ iface_has_carrier() {
# double check the syscfs carrier flag # double check the syscfs carrier flag
[ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0 [ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -15,7 +15,7 @@ installkernel() {
local _modname local _modname
# Include KMS capable drm drivers # Include KMS capable drm drivers


if [[ "${DRACUT_ARCH:-$(uname -m)}" == arm* || "${DRACUT_ARCH:-$(uname -m)}" == aarch64 ]]; then if [[ ${DRACUT_ARCH:-$(uname -m)} == arm* || ${DRACUT_ARCH:-$(uname -m)} == aarch64 ]]; then
# arm/aarch64 specific modules needed by drm # arm/aarch64 specific modules needed by drm
instmods \ instmods \
"=drivers/gpu/drm/i2c" \ "=drivers/gpu/drm/i2c" \

View File

@ -32,7 +32,7 @@ install() {
dwarn "${line}" dwarn "${line}"
else else
derror "${line}" derror "${line}"
(($_ret == 0)) && _ret=1 ((_ret == 0)) && _ret=1
fi fi
done done
fi fi

View File

@ -32,7 +32,7 @@ if [[ $hostonly ]]; then
fi fi
else else
for x in "$dracutsysrootdir"/usr/share/plymouth/themes/{text,details}/*; do for x in "$dracutsysrootdir"/usr/share/plymouth/themes/{text,details}/*; do
[[ -f "$x" ]] || continue [[ -f $x ]] || continue
THEME_DIR=$(dirname "${x#$dracutsysrootdir}") THEME_DIR=$(dirname "${x#$dracutsysrootdir}")
mkdir -m 0755 -p "${initdir}/$THEME_DIR" mkdir -m 0755 -p "${initdir}/$THEME_DIR"
inst_multiple "${x#$dracutsysrootdir}" inst_multiple "${x#$dracutsysrootdir}"

View File

@ -16,7 +16,7 @@ function sysecho() {
done done
local status local status
read status < "$file" read status < "$file"
if [[ ! $status == $* ]]; then if [[ $status != $* ]]; then
[ -f "$file" ] && echo $* > "$file" [ -f "$file" ] && echo $* > "$file"
fi fi
} }
@ -155,7 +155,7 @@ processcmsfile() {
echo -n $NETTYPE,$SUBCHANNELS echo -n $NETTYPE,$SUBCHANNELS
[[ $PORTNAME ]] && echo -n ",portname=$PORTNAME" [[ $PORTNAME ]] && echo -n ",portname=$PORTNAME"
[[ $LAYER2 ]] && echo -n ",layer2=$LAYER2" [[ $LAYER2 ]] && echo -n ",layer2=$LAYER2"
[[ "$NETTYPE" = "ctc" ]] && [[ $CTCPROT ]] && echo -n ",protocol=$CTCPROT" [[ $NETTYPE == "ctc" ]] && [[ $CTCPROT ]] && echo -n ",protocol=$CTCPROT"
echo echo
) >> /etc/ccw.conf ) >> /etc/ccw.conf



View File

@ -9,7 +9,7 @@ check() {


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "btrfs" ]] && return 0 [[ $fs == "btrfs" ]] && return 0
done done
return 255 return 255
} }

View File

@ -126,7 +126,7 @@ ask_for_password() {
&& printf "$tty_prompt [$i/$tty_tries]:" >&2 && printf "$tty_prompt [$i/$tty_tries]:" >&2
eval "$tty_cmd" && ret=0 && break eval "$tty_cmd" && ret=0 && break
ret=$? ret=$?
i=$(($i + 1)) i=$((i + 1))
[ -n "$tty_prompt" ] && printf '\n' >&2 [ -n "$tty_prompt" ] && printf '\n' >&2
done done



View File

@ -157,7 +157,7 @@ else
info "No key found for $device. Will try $numtries time(s) more later." info "No key found for $device. Will try $numtries time(s) more later."
initqueue --unique --onetime --settled \ initqueue --unique --onetime --settled \
--name cryptroot-ask-$luksname \ --name cryptroot-ask-$luksname \
$(command -v cryptroot-ask) "$device" "$luksname" "$is_keysource" "$(($numtries - 1))" $(command -v cryptroot-ask) "$device" "$luksname" "$is_keysource" "$((numtries - 1))"
exit 0 exit 0
fi fi
unset tmp unset tmp

View File

@ -8,7 +8,7 @@ check() {


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for fs in "${host_fs_types[@]}"; do
[[ $fs = "crypto_LUKS" ]] && return 0 [[ $fs == "crypto_LUKS" ]] && return 0
done done
return 255 return 255
} }
@ -57,12 +57,12 @@ installkernel() {
cmdline() { cmdline() {
local dev UUID local dev UUID
for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ "${host_fs_types[$dev]}" != "crypto_LUKS" ]] && continue [[ ${host_fs_types[$dev]} != "crypto_LUKS" ]] && continue


UUID=$( UUID=$(
blkid -u crypto -o export $dev \ blkid -u crypto -o export $dev \
| while read line || [ -n "$line" ]; do | while read line || [ -n "$line" ]; do
[[ ${line#UUID} = $line ]] && continue [[ ${line#UUID} == $line ]] && continue
printf "%s" "${line#UUID=}" printf "%s" "${line#UUID=}"
break break
done done
@ -92,7 +92,7 @@ install() {
if [[ $hostonly ]] && [[ -f $dracutsysrootdir/etc/crypttab ]]; then if [[ $hostonly ]] && [[ -f $dracutsysrootdir/etc/crypttab ]]; then
# filter /etc/crypttab for the devices we need # filter /etc/crypttab for the devices we need
while read _mapper _dev _luksfile _luksoptions || [ -n "$_mapper" ]; do while read _mapper _dev _luksfile _luksoptions || [ -n "$_mapper" ]; do
[[ $_mapper = \#* ]] && continue [[ $_mapper == \#* ]] && continue
[[ $_dev ]] || continue [[ $_dev ]] || continue


[[ $_dev == PARTUUID=* ]] \ [[ $_dev == PARTUUID=* ]] \

View File

@ -10,12 +10,12 @@ check() {


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue


DEVPATH=$(get_devpath_block "$dev") DEVPATH=$(get_devpath_block "$dev")


for holder in "$DEVPATH"/holders/*; do for holder in "$DEVPATH"/holders/*; do
[[ -e "$holder" ]] || continue [[ -e $holder ]] || continue
[[ -e "$holder/dm" ]] && return 0 [[ -e "$holder/dm" ]] && return 0
break break
done done
@ -40,12 +40,12 @@ cmdline() {


for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
local holder DEVPATH DM_NAME majmin local holder DEVPATH DM_NAME majmin
[[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue


DEVPATH=$(get_devpath_block "$dev") DEVPATH=$(get_devpath_block "$dev")


for holder in "$DEVPATH"/holders/*; do for holder in "$DEVPATH"/holders/*; do
[[ -e "$holder" ]] || continue [[ -e $holder ]] || continue
dev="/dev/${holder##*/}" dev="/dev/${holder##*/}"
DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2> /dev/null)" DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2> /dev/null)"
[[ ${DM_NAME} ]] && break [[ ${DM_NAME} ]] && break

View File

@ -249,8 +249,8 @@ do_live_overlay() {
mkdir -m 0755 -p /run/initramfs/thin-overlay mkdir -m 0755 -p /run/initramfs/thin-overlay


# In block units (512b) # In block units (512b)
thin_data_sz=$(($overlay_size * 1024 * 1024 / 512)) thin_data_sz=$((overlay_size * 1024 * 1024 / 512))
thin_meta_sz=$(($thin_data_sz / 10)) thin_meta_sz=$((thin_data_sz / 10))


# It is important to have the backing file on a tmpfs # It is important to have the backing file on a tmpfs
# this is needed to let the loopdevice support TRIM # this is needed to let the loopdevice support TRIM

View File

@ -25,7 +25,7 @@ installkernel() {
: "${depmod_modules_dep:=$srcmods/modules.dep}" : "${depmod_modules_dep:=$srcmods/modules.dep}"
: "${depmod_module_dir:=$srcmods}" : "${depmod_module_dir:=$srcmods}"


[[ -f "${depmod_modules_dep}" ]] || return 0 [[ -f ${depmod_modules_dep} ]] || return 0


# Message printers with custom prefix # Message printers with custom prefix
local mod_name="kernel-modules-extra" local mod_name="kernel-modules-extra"
@ -61,7 +61,7 @@ installkernel() {
# configuration path # configuration path
if [ -d "$cfg" ]; then if [ -d "$cfg" ]; then
for f in "$cfg/"*; do for f in "$cfg/"*; do
[[ -e "$f" && ! -d "$f" ]] || { [[ -e $f && ! -d $f ]] || {
prdebug "configuration source" \ prdebug "configuration source" \
"\"$cfg\" is ignored" \ "\"$cfg\" is ignored" \
"(directory or doesn't exist)" "(directory or doesn't exist)"
@ -96,14 +96,14 @@ installkernel() {
override) # module_name kver_pattern dir override) # module_name kver_pattern dir
read -r mod kverpat path <<< "$v" read -r mod kverpat path <<< "$v"


if [[ ! "$mod" || ! "$kverpat" || ! "$path" ]]; then if [[ ! $mod || ! $kverpat || ! $path ]]; then
prinfo "$cfg: ignoring incorrect" \ prinfo "$cfg: ignoring incorrect" \
"override option: \"$k $v\"" "override option: \"$k $v\""
continue continue
fi fi


if [[ '*' = "$kverpat" ]] \ if [[ '*' == "$kverpat" ]] \
|| [[ "$kernel" =~ $kverpat ]]; then || [[ $kernel =~ $kverpat ]]; then
overrides+=("${path}/${mod}") overrides+=("${path}/${mod}")


prdebug "$cfg: added override" \ prdebug "$cfg: added override" \
@ -117,14 +117,14 @@ installkernel() {
external) # kverpat dir external) # kverpat dir
read -r kverpat path <<< "$v" read -r kverpat path <<< "$v"


if [[ ! "$kverpat" || ! "$path" ]]; then if [[ ! $kverpat || ! $path ]]; then
prinfo "$cfg: ignoring incorrect" \ prinfo "$cfg: ignoring incorrect" \
"external option: \"$k $v\"" "external option: \"$k $v\""
continue continue
fi fi


if [[ '*' = "$kverpat" || \ if [[ '*' == "$kverpat" || \
"$kernel" =~ $kverpat ]]; then $kernel =~ $kverpat ]]; then
external_dirs+=("$path") external_dirs+=("$path")


prdebug "$cfg: added external" \ prdebug "$cfg: added external" \

View File

@ -67,7 +67,7 @@ installkernel() {
virtio virtio_ring virtio_pci pci_hyperv \ virtio virtio_ring virtio_pci pci_hyperv \
"=drivers/pcmcia" "=drivers/pcmcia"


if [[ "${DRACUT_ARCH:-$(uname -m)}" == arm* || "${DRACUT_ARCH:-$(uname -m)}" == aarch64 ]]; then if [[ ${DRACUT_ARCH:-$(uname -m)} == arm* || ${DRACUT_ARCH:-$(uname -m)} == aarch64 ]]; then
# arm/aarch64 specific modules # arm/aarch64 specific modules
_blockfuncs+='|dw_mc_probe|dw_mci_pltfm_register' _blockfuncs+='|dw_mc_probe|dw_mci_pltfm_register'
instmods \ instmods \
@ -108,7 +108,7 @@ installkernel() {
|| for_each_host_dev_and_slaves_all record_block_dev_drv; then || for_each_host_dev_and_slaves_all record_block_dev_drv; then
hostonly='' instmods sg sr_mod sd_mod scsi_dh ata_piix hostonly='' instmods sg sr_mod sd_mod scsi_dh ata_piix


if [[ "$hostonly_mode" == "strict" ]]; then if [[ $hostonly_mode == "strict" ]]; then
install_block_modules_strict install_block_modules_strict
else else
install_block_modules install_block_modules

View File

@ -18,7 +18,7 @@ installkernel() {
local _unwanted_drivers='/(wireless|isdn|uwb|net/ethernet|net/phy|net/team)/' local _unwanted_drivers='/(wireless|isdn|uwb|net/ethernet|net/phy|net/team)/'
local _net_drivers local _net_drivers


if [[ "$_arch" = "s390" ]] || [[ "$_arch" = "s390x" ]]; then if [[ $_arch == "s390" ]] || [[ $_arch == "s390x" ]]; then
dracut_instmods -o -P ".*${_unwanted_drivers}.*" -s "$_net_symbols" "=drivers/s390/net" dracut_instmods -o -P ".*${_unwanted_drivers}.*" -s "$_net_symbols" "=drivers/s390/net"
fi fi



View File

@ -7,7 +7,7 @@ check() {


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for fs in "${host_fs_types[@]}"; do
[[ $fs = LVM*_member ]] && return 0 [[ $fs == LVM*_member ]] && return 0
done done
return 255 return 255
} }
@ -31,11 +31,11 @@ cmdline() {
[ -e /sys/block/${dev#/dev/}/dm/name ] || continue [ -e /sys/block/${dev#/dev/}/dm/name ] || continue
[ -e /sys/block/${dev#/dev/}/dm/uuid ] || continue [ -e /sys/block/${dev#/dev/}/dm/uuid ] || continue
uuid=$(< /sys/block/${dev#/dev/}/dm/uuid) uuid=$(< /sys/block/${dev#/dev/}/dm/uuid)
[[ "${uuid#LVM-}" == "$uuid" ]] && continue [[ ${uuid#LVM-} == "$uuid" ]] && continue
dev=$(< /sys/block/${dev#/dev/}/dm/name) dev=$(< /sys/block/${dev#/dev/}/dm/name)
eval $(dmsetup splitname --nameprefixes --noheadings --rows "$dev" 2> /dev/null) eval $(dmsetup splitname --nameprefixes --noheadings --rows "$dev" 2> /dev/null)
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1 [[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1
if ! [[ ${_activated[${DM_VG_NAME} / ${DM_LV_NAME}]} ]]; then if ! [[ ${_activated[DM_VG_NAME / DM_LV_NAME]} ]]; then
printf " rd.lvm.lv=%s " "${DM_VG_NAME}/${DM_LV_NAME} " printf " rd.lvm.lv=%s " "${DM_VG_NAME}/${DM_LV_NAME} "
_activated["${DM_VG_NAME}/${DM_LV_NAME}"]=1 _activated["${DM_VG_NAME}/${DM_LV_NAME}"]=1
fi fi
@ -59,7 +59,7 @@ install() {


inst_rules "$moddir/64-lvm.rules" inst_rules "$moddir/64-lvm.rules"


if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then if [[ $hostonly ]] || [[ $lvmconf == "yes" ]]; then
if [[ -f $dracutsysrootdir/etc/lvm/lvm.conf ]]; then if [[ -f $dracutsysrootdir/etc/lvm/lvm.conf ]]; then
inst_simple -H /etc/lvm/lvm.conf inst_simple -H /etc/lvm/lvm.conf
# FIXME: near-term hack to establish read-only locking; # FIXME: near-term hack to establish read-only locking;

View File

@ -8,7 +8,7 @@ _do_md_shutdown() {
ret=$? ret=$?
info "Disassembling mdraid devices." info "Disassembling mdraid devices."
mdadm -vv --stop --scan | vinfo mdadm -vv --stop --scan | vinfo
ret=$(($ret + $?)) ret=$((ret + $?))
if [ "x$final" != "x" ]; then if [ "x$final" != "x" ]; then
info "/proc/mdstat:" info "/proc/mdstat:"
vinfo < /proc/mdstat vinfo < /proc/mdstat

View File

@ -8,12 +8,12 @@ check() {


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue


DEVPATH=$(get_devpath_block "$dev") DEVPATH=$(get_devpath_block "$dev")


for holder in "$DEVPATH"/holders/*; do for holder in "$DEVPATH"/holders/*; do
[[ -e "$holder" ]] || continue [[ -e $holder ]] || continue
[[ -e "$holder/md" ]] && return 0 [[ -e "$holder/md" ]] && return 0
break break
done done
@ -42,17 +42,17 @@ cmdline() {
declare -A _activated declare -A _activated


for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue


UUID=$( UUID=$(
/sbin/mdadm --examine --export $dev \ /sbin/mdadm --examine --export $dev \
| while read line || [ -n "$line" ]; do | while read line || [ -n "$line" ]; do
[[ ${line#MD_UUID=} = $line ]] && continue [[ ${line#MD_UUID=} == $line ]] && continue
printf "%s" "${line#MD_UUID=} " printf "%s" "${line#MD_UUID=} "
done done
) )


[[ -z "$UUID" ]] && continue [[ -z $UUID ]] && continue


if ! [[ ${_activated[${UUID}]} ]]; then if ! [[ ${_activated[${UUID}]} ]]; then
printf "%s" " rd.md.uuid=${UUID}" printf "%s" " rd.md.uuid=${UUID}"
@ -103,7 +103,7 @@ install() {
inst_hook pre-trigger 30 "$moddir/md-noddf.sh" inst_hook pre-trigger 30 "$moddir/md-noddf.sh"
fi fi


if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then if [[ $hostonly ]] || [[ $mdadmconf == "yes" ]]; then
if [[ -f $dracutsysrootdir/etc/mdadm.conf ]]; then if [[ -f $dracutsysrootdir/etc/mdadm.conf ]]; then
inst -H /etc/mdadm.conf inst -H /etc/mdadm.conf
else else

View File

@ -94,7 +94,7 @@ install() {
/etc/multipath/* \ /etc/multipath/* \
/etc/multipath/conf.d/* /etc/multipath/conf.d/*


[[ $hostonly ]] && [[ $hostonly_mode = "strict" ]] && { [[ $hostonly ]] && [[ $hostonly_mode == "strict" ]] && {
for_each_host_dev_and_slaves_all add_hostonly_mpath_conf for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
[ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
} }

View File

@ -5,7 +5,7 @@ check() {
if [[ ! $hostonly ]]; then if [[ ! $hostonly ]]; then
return 0 return 0
fi fi
[[ $DRACUT_KERNEL_MODALIASES && -f "$DRACUT_KERNEL_MODALIASES" ]] \ [[ $DRACUT_KERNEL_MODALIASES && -f $DRACUT_KERNEL_MODALIASES ]] \
&& grep -q libnvdimm "$DRACUT_KERNEL_MODALIASES" && return 0 && grep -q libnvdimm "$DRACUT_KERNEL_MODALIASES" && return 0
return 255 return 255
} }

View File

@ -19,7 +19,7 @@
check() { check() {
local _arch=${DRACUT_ARCH:-$(uname -m)} local _arch=${DRACUT_ARCH:-$(uname -m)}
# only for PowerPC Macs # only for PowerPC Macs
[[ "$_arch" == ppc* && "$_arch" != ppc64le ]] || return 1 [[ $_arch == ppc* && $_arch != ppc64le ]] || return 1
return 0 return 0
} }


@ -36,7 +36,7 @@ installkernel() {
} }


# only PowerMac3,6 has a module, special case # only PowerMac3,6 has a module, special case
if [[ "${DRACUT_ARCH:-$(uname -m)}" != ppc64* ]]; then if [[ ${DRACUT_ARCH:-$(uname -m)} != ppc64* ]]; then
if ! [[ $hostonly ]] || [[ "$(pmac_model)" == "PowerMac3,6" ]]; then if ! [[ $hostonly ]] || [[ "$(pmac_model)" == "PowerMac3,6" ]]; then
instmods therm_windtunnel instmods therm_windtunnel
fi fi

View File

@ -42,7 +42,7 @@ sc_public_key() {
sc_supported() { sc_supported() {
local gpgMajor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* ([0-9]*).*|\1|p')" local gpgMajor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* ([0-9]*).*|\1|p')"
local gpgMinor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')" local gpgMinor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')"
if [[ "${gpgMajor}" -gt 2 || "${gpgMajor}" -eq 2 && "${gpgMinor}" -ge 1 ]] \ if [[ ${gpgMajor} -gt 2 || ${gpgMajor} -eq 2 && ${gpgMinor} -ge 1 ]] \
&& require_binaries gpg-agent \ && require_binaries gpg-agent \
&& require_binaries gpg-connect-agent \ && require_binaries gpg-connect-agent \
&& require_binaries /usr/libexec/scdaemon \ && require_binaries /usr/libexec/scdaemon \

View File

@ -7,7 +7,7 @@ check() {


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "cifs" ]] && return 0 [[ $fs == "cifs" ]] && return 0
done done
return 255 return 255
} }

View File

@ -31,7 +31,7 @@ check() {
for bdev in /sys/block/*; do for bdev in /sys/block/*; do
case "${bdev##*/}" in case "${bdev##*/}" in
dasd*) dasd*)
found=$(($found + 1)) found=$((found + 1))
break break
;; ;;
esac esac

View File

@ -43,7 +43,7 @@ EOF
} }


if [[ -f /sys/firmware/ipl/ipl_type && \ if [[ -f /sys/firmware/ipl/ipl_type && \
$(< /sys/firmware/ipl/ipl_type) = "ccw" ]]; then $(< /sys/firmware/ipl/ipl_type) == "ccw" ]]; then
( (
_ccw=$(cat /sys/firmware/ipl/device) _ccw=$(cat /sys/firmware/ipl/device)



View File

@ -5,7 +5,7 @@
# called by dracut # called by dracut
check() { check() {
local _arch=${DRACUT_ARCH:-$(uname -m)} local _arch=${DRACUT_ARCH:-$(uname -m)}
[[ "$_arch" = "s390" ]] || [[ "$_arch" = "s390x" ]] || return 1 [[ $_arch == "s390" ]] || [[ $_arch == "s390x" ]] || return 1
return 0 return 0
} }



View File

@ -14,7 +14,7 @@ check_edd() {


while [ $cnt -lt 600 ]; do while [ $cnt -lt 600 ]; do
[ -d /sys/firmware/edd ] && return 0 [ -d /sys/firmware/edd ] && return 0
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
sleep 0.1 sleep 0.1
done done
return 1 return 1

View File

@ -74,28 +74,28 @@ if [ "$dcb" = "dcb" ]; then
lldptool -p && break lldptool -p && break
info "Waiting for lldpad to be ready" info "Waiting for lldpad to be ready"
sleep 1 sleep 1
i=$(($i + 1)) i=$((i + 1))
done done


while [ $i -lt 60 ]; do while [ $i -lt 60 ]; do
dcbtool sc "$netif" dcb on && break dcbtool sc "$netif" dcb on && break
info "Retrying to turn dcb on" info "Retrying to turn dcb on"
sleep 1 sleep 1
i=$(($i + 1)) i=$((i + 1))
done done


while [ $i -lt 60 ]; do while [ $i -lt 60 ]; do
dcbtool sc "$netif" pfc e:1 a:1 w:1 && break dcbtool sc "$netif" pfc e:1 a:1 w:1 && break
info "Retrying to turn dcb on" info "Retrying to turn dcb on"
sleep 1 sleep 1
i=$(($i + 1)) i=$((i + 1))
done done


while [ $i -lt 60 ]; do while [ $i -lt 60 ]; do
dcbtool sc "$netif" app:fcoe e:1 a:1 w:1 && break dcbtool sc "$netif" app:fcoe e:1 a:1 w:1 && break
info "Retrying to turn fcoe on" info "Retrying to turn fcoe on"
sleep 1 sleep 1
i=$(($i + 1)) i=$((i + 1))
done done


sleep 1 sleep 1

View File

@ -15,5 +15,5 @@ while [ $i -lt 60 ]; do
lldptool -p && break lldptool -p && break
info "Waiting for lldpad to be ready" info "Waiting for lldpad to be ready"
sleep 1 sleep 1
i=$(($i + 1)) i=$((i + 1))
done done

View File

@ -78,10 +78,10 @@ cmdline() {
# DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no". # DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no".
# #
# Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent). # Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent).
grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &> /dev/null grep -q '^[[:blank:]]*DCB_REQUIRED="no"' /etc/fcoe/cfg-${i##*/} &> /dev/null
[ $? -eq 0 ] && dcb="nodcb" [ $? -eq 0 ] && dcb="nodcb"
if [ "$p" ]; then if [ "$p" ]; then
grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &> /dev/null grep -q '^[[:blank:]]*DCB_REQUIRED="no"' /etc/fcoe/cfg-${p} &> /dev/null
[ $? -eq 0 ] && dcb="nodcb" [ $? -eq 0 ] && dcb="nodcb"
fi fi



View File

@ -290,7 +290,7 @@ if ! [ "$netif" = "online" ]; then
nroot="${nroot##iscsi:}" nroot="${nroot##iscsi:}"
if [ -n "$nroot" ]; then if [ -n "$nroot" ]; then
handle_netroot "$nroot" handle_netroot "$nroot"
ret=$(($ret + $?)) ret=$((ret + $?))
fi fi
done done
else else

View File

@ -94,7 +94,7 @@ while [ ! -b /dev/nbd0 ]; do
else else
sleep 0.1 sleep 0.1
fi fi
i=$(($i + 1)) i=$((i + 1))
done done


# If we didn't get a root= on the command line, then we need to # If we didn't get a root= on the command line, then we need to

View File

@ -8,9 +8,9 @@ get_nfs_type() {
local _nfs _nfs4 local _nfs _nfs4


for fs in "${host_fs_types[@]}"; do for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "nfs" ]] && _nfs=1 [[ $fs == "nfs" ]] && _nfs=1
[[ "$fs" == "nfs3" ]] && _nfs=1 [[ $fs == "nfs3" ]] && _nfs=1
[[ "$fs" == "nfs4" ]] && _nfs4=1 [[ $fs == "nfs4" ]] && _nfs4=1
done done


[[ "$_nfs" ]] && echo "nfs" && return [[ "$_nfs" ]] && echo "nfs" && return

View File

@ -22,7 +22,7 @@ check() {
break break
fi fi
done done
[[ "$trtype" == "fc" ]] || [[ "$trtype" == "tcp" ]] || [[ "$trtype" == "rdma" ]] [[ $trtype == "fc" ]] || [[ $trtype == "tcp" ]] || [[ $trtype == "rdma" ]]
} }


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {

View File

@ -13,11 +13,11 @@ depends() {
cmdline_journal() { cmdline_journal() {
if [[ $hostonly ]]; then if [[ $hostonly ]]; then
for dev in "${!host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ ${host_fs_types[$dev]} = "reiserfs" ]] || [[ ${host_fs_types[$dev]} = "xfs" ]] || continue [[ ${host_fs_types[$dev]} == "reiserfs" ]] || [[ ${host_fs_types[$dev]} == "xfs" ]] || continue
rootopts=$(find_dev_fsopts "$dev") rootopts=$(find_dev_fsopts "$dev")
if [[ ${host_fs_types[$dev]} = "reiserfs" ]]; then if [[ ${host_fs_types[$dev]} == "reiserfs" ]]; then
journaldev=$(fs_get_option $rootopts "jdev") journaldev=$(fs_get_option $rootopts "jdev")
elif [[ ${host_fs_types[$dev]} = "xfs" ]]; then elif [[ ${host_fs_types[$dev]} == "xfs" ]]; then
journaldev=$(fs_get_option $rootopts "logdev") journaldev=$(fs_get_option $rootopts "logdev")
fi fi


@ -47,7 +47,7 @@ cmdline_rootfs() {
if [ -n "$_fstype" ]; then if [ -n "$_fstype" ]; then
printf " rootfstype=%s" "$_fstype" printf " rootfstype=%s" "$_fstype"
fi fi
if [[ $use_fstab != yes ]] && [[ $_fstype = btrfs ]]; then if [[ $use_fstab != yes ]] && [[ $_fstype == btrfs ]]; then
_subvol=$(findmnt -e -v -n -o FSROOT --target /) \ _subvol=$(findmnt -e -v -n -o FSROOT --target /) \
&& _subvol=${_subvol#/} && _subvol=${_subvol#/}
_flags="$_flags${_subvol:+,subvol=$_subvol}" _flags="$_flags${_subvol:+,subvol=$_subvol}"

View File

@ -4,7 +4,7 @@
check() { check() {
[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for fs in "${host_fs_types[@]}"; do
[[ "$fs" == "9p" ]] && return 0 [[ $fs == "9p" ]] && return 0
done done
return 255 return 255
} }

View File

@ -50,7 +50,7 @@ check() {
found=0 found=0
for _ccw in /sys/bus/ccw/devices/*/host*; do for _ccw in /sys/bus/ccw/devices/*/host*; do
[ -d "$_ccw" ] || continue [ -d "$_ccw" ] || continue
found=$(($found + 1)) found=$((found + 1))
done done
[ $found -eq 0 ] && return 255 [ $found -eq 0 ] && return 255
} }

View File

@ -42,7 +42,7 @@ EOF
} }


if [[ -f /sys/firmware/ipl/ipl_type && \ if [[ -f /sys/firmware/ipl/ipl_type && \
$(< /sys/firmware/ipl/ipl_type) = "fcp" ]]; then $(< /sys/firmware/ipl/ipl_type) == "fcp" ]]; then
( (
_wwpn=$(cat /sys/firmware/ipl/wwpn) _wwpn=$(cat /sys/firmware/ipl/wwpn)
_lun=$(cat /sys/firmware/ipl/lun) _lun=$(cat /sys/firmware/ipl/lun)

View File

@ -13,7 +13,7 @@ getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initque


RDRETRY=$(getarg rd.retry -d 'rd_retry=') RDRETRY=$(getarg rd.retry -d 'rd_retry=')
RDRETRY=${RDRETRY:-180} RDRETRY=${RDRETRY:-180}
RDRETRY=$(($RDRETRY * 2)) RDRETRY=$((RDRETRY * 2))
export RDRETRY export RDRETRY


main_loop=0 main_loop=0
@ -54,7 +54,7 @@ while :; do
[ -e "$i" ] && continue 2 [ -e "$i" ] && continue 2
done done


if [ $main_loop -gt $((2 * $RDRETRY / 3)) ]; then if [ $main_loop -gt $((2 * RDRETRY / 3)) ]; then
warn "dracut-initqueue: timeout, still waiting for following initqueue hooks:" warn "dracut-initqueue: timeout, still waiting for following initqueue hooks:"
for _f in $hookdir/initqueue/finished/*.sh; do for _f in $hookdir/initqueue/finished/*.sh; do
warn "$_f: \"$(cat "$_f")\"" warn "$_f: \"$(cat "$_f")\""
@ -71,7 +71,7 @@ while :; do
fi fi
fi fi


main_loop=$(($main_loop + 1)) main_loop=$((main_loop + 1))
if [ $main_loop -gt $RDRETRY ]; then if [ $main_loop -gt $RDRETRY ]; then
if ! [ -f /sysroot/etc/fstab ] || ! [ -e /sysroot/sbin/init ]; then if ! [ -f /sysroot/etc/fstab ] || ! [ -e /sysroot/sbin/init ]; then
emergency_shell "Could not boot." emergency_shell "Could not boot."

View File

@ -28,7 +28,7 @@ while :; do
fi fi
done done


i=$(($i + 1)) i=$((i + 1))
[ $i -gt 20 ] && emergency_shell "Can't mount root filesystem" [ $i -gt 20 ] && emergency_shell "Can't mount root filesystem"
done done



View File

@ -270,7 +270,7 @@ getargnum() {
_b=$(getarg "$1") _b=$(getarg "$1")
[ $? -ne 0 -a -z "$_b" ] && _b=$_default [ $? -ne 0 -a -z "$_b" ] && _b=$_default
if [ -n "$_b" ]; then if [ -n "$_b" ]; then
isdigit "$_b" && _b=$(($_b)) \ isdigit "$_b" && _b=$((_b)) \
&& [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return && [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
fi fi
echo $_default echo $_default
@ -471,7 +471,7 @@ check_occurances() {


while [ "${str#*$ch}" != "${str}" ]; do while [ "${str#*$ch}" != "${str}" ]; do
str="${str#*$ch}" str="${str#*$ch}"
count=$(($count + 1)) count=$((count + 1))
done done


[ $count -eq $expected ] [ $count -eq $expected ]
@ -609,7 +609,7 @@ funiq() {
[ -d "${dir}" ] || return 1 [ -d "${dir}" ] || return 1


while [ -e "${dir}/${prefix}$i" ]; do while [ -e "${dir}/${prefix}$i" ]; do
i=$(($i + 1)) || return 1 i=$((i + 1)) || return 1
done done


echo "${dir}/${prefix}$i" echo "${dir}/${prefix}$i"
@ -998,7 +998,7 @@ wait_for_loginit() {
[ -z "${j##*Running*}" ] || break [ -z "${j##*Running*}" ] || break
fi fi
sleep 0.1 sleep 0.1
i=$(($i + 1)) i=$((i + 1))
done done


if [ $i -eq 10 ]; then if [ $i -eq 10 ]; then

View File

@ -174,7 +174,7 @@ getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initque


RDRETRY=$(getarg rd.retry -d 'rd_retry=') RDRETRY=$(getarg rd.retry -d 'rd_retry=')
RDRETRY=${RDRETRY:-180} RDRETRY=${RDRETRY:-180}
RDRETRY=$(($RDRETRY * 2)) RDRETRY=$((RDRETRY * 2))
export RDRETRY export RDRETRY
main_loop=0 main_loop=0
export main_loop export main_loop
@ -209,7 +209,7 @@ while :; do
# no more udev jobs and queues empty. # no more udev jobs and queues empty.
sleep 0.5 sleep 0.5


if [ $main_loop -gt $((2 * $RDRETRY / 3)) ]; then if [ $main_loop -gt $((2 * RDRETRY / 3)) ]; then
for job in $hookdir/initqueue/timeout/*.sh; do for job in $hookdir/initqueue/timeout/*.sh; do
[ -e "$job" ] || break [ -e "$job" ] || break
job=$job . $job job=$job . $job
@ -218,7 +218,7 @@ while :; do
done done
fi fi


main_loop=$(($main_loop + 1)) main_loop=$((main_loop + 1))
[ $main_loop -gt $RDRETRY ] \ [ $main_loop -gt $RDRETRY ] \
&& { && {
flock -s 9 flock -s 9
@ -255,7 +255,7 @@ while :; do
fi fi
done done


_i_mount=$(($_i_mount + 1)) _i_mount=$((_i_mount + 1))
[ $_i_mount -gt 20 ] \ [ $_i_mount -gt 20 ] \
&& { && {
flock -s 9 flock -s 9

View File

@ -65,7 +65,7 @@ install() {
fi fi


ln -fs /proc/self/mounts "$initdir/etc/mtab" ln -fs /proc/self/mounts "$initdir/etc/mtab"
if [[ $ro_mnt = yes ]]; then if [[ $ro_mnt == yes ]]; then
echo ro >> "${initdir}/etc/cmdline.d/base.conf" echo ro >> "${initdir}/etc/cmdline.d/base.conf"
fi fi


@ -106,7 +106,7 @@ install() {


## save host_devs which we need bring up ## save host_devs which we need bring up
if [[ $hostonly_cmdline == "yes" ]]; then if [[ $hostonly_cmdline == "yes" ]]; then
if [[ -n "${host_devs[*]}" ]]; then if [[ -n ${host_devs[*]} ]]; then
dracut_need_initqueue dracut_need_initqueue
fi fi
if [[ -f $initdir/lib/dracut/need-initqueue ]] || ! dracut_module_included "systemd"; then if [[ -f $initdir/lib/dracut/need-initqueue ]] || ! dracut_module_included "systemd"; then
@ -120,14 +120,14 @@ install() {


for _dev in "${host_devs[@]}"; do for _dev in "${host_devs[@]}"; do
for _dev2 in "${root_devs[@]}"; do for _dev2 in "${root_devs[@]}"; do
[[ "$_dev" == "$_dev2" ]] && continue 2 [[ $_dev == "$_dev2" ]] && continue 2
done done


# We only actually wait for real devs - swap is only needed # We only actually wait for real devs - swap is only needed
# for resume and udev rules generated when parsing resume= # for resume and udev rules generated when parsing resume=
# argument take care of the waiting for us # argument take care of the waiting for us
for _dev2 in "${swap_devs[@]}"; do for _dev2 in "${swap_devs[@]}"; do
[[ "$_dev" == "$_dev2" ]] && continue 2 [[ $_dev == "$_dev2" ]] && continue 2
done done


_pdev=$(get_persistent_dev $_dev) _pdev=$(get_persistent_dev $_dev)

View File

@ -64,9 +64,9 @@ install() {
inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh" inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh"
> ${initdir}/etc/fstab.empty > ${initdir}/etc/fstab.empty


[[ "$nofscks" = "yes" ]] && return [[ $nofscks == "yes" ]] && return


if [[ "$fscks" = "${fscks#*[^ ]*}" ]]; then if [[ $fscks == "${fscks#*[^ ]*}" ]]; then
_helpers="\ _helpers="\
umount mount /sbin/fsck* /usr/sbin/fsck* umount mount /sbin/fsck* /usr/sbin/fsck*
xfs_db xfs_check xfs_repair xfs_metadump xfs_db xfs_check xfs_repair xfs_metadump
@ -80,7 +80,7 @@ install() {
_helpers="$fscks" _helpers="$fscks"
fi fi


if [[ "$_helpers" == *e2fsck* ]] && [[ -e $dracutsysrootdir/etc/e2fsck.conf ]]; then if [[ $_helpers == *e2fsck* ]] && [[ -e $dracutsysrootdir/etc/e2fsck.conf ]]; then
inst_simple /etc/e2fsck.conf inst_simple /etc/e2fsck.conf
fi fi



View File

@ -96,7 +96,7 @@ umount_a() {
_cnt=0 _cnt=0
while [ $_cnt -le 40 ]; do while [ $_cnt -le 40 ]; do
umount_a || break umount_a || break
_cnt=$(($_cnt + 1)) _cnt=$((_cnt + 1))
done done


[ $_cnt -ge 40 ] && umount_a -v [ $_cnt -ge 40 ] && umount_a -v
@ -142,7 +142,7 @@ _check_shutdown() {
_cnt=0 _cnt=0
while [ $_cnt -le 40 ]; do while [ $_cnt -le 40 ]; do
_check_shutdown && break _check_shutdown && break
_cnt=$(($_cnt + 1)) _cnt=$((_cnt + 1))
done done
[ $_cnt -ge 40 ] && _check_shutdown final [ $_cnt -ge 40 ] && _check_shutdown final



View File

@ -25,7 +25,7 @@ installpost() {
# Move everything under $initdir except $squash_dir # Move everything under $initdir except $squash_dir
# itself into squash image # itself into squash image
for i in "$initdir"/*; do for i in "$initdir"/*; do
[[ "$squash_dir" == "$i"/* ]] || mv "$i" "$squash_dir"/ [[ $squash_dir == "$i"/* ]] || mv "$i" "$squash_dir"/
done done


# Create mount points for squash loader # Create mount points for squash loader

View File

@ -61,7 +61,7 @@ uefi_device_path() {
0101) 0101)
# PCI # PCI
tt=$(getword) tt=$(getword)
printf "PCI(0x%x,0x%x)" $(($tt / 256)) $(($tt & 255)) printf "PCI(0x%x,0x%x)" $((tt / 256)) $((tt & 255))
;; ;;
0201) 0201)
# ACPI # ACPI

View File

@ -20,7 +20,7 @@ wait_for_if_link() {
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -32,7 +32,7 @@ wait_for_if_up() {
li=$(ip -o link show up dev $1) li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -43,7 +43,7 @@ wait_for_route_ok() {
li=$(ip route show) li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -82,7 +82,7 @@ client_test() {
# nfsinfo=( server:/path nfs{,4} options ) # nfsinfo=( server:/path nfs{,4} options )
nfsinfo=($(awk '{print $2, $3, $4; exit}' $TESTDIR/client.img)) nfsinfo=($(awk '{print $2, $3, $4; exit}' $TESTDIR/client.img))


if [[ "${nfsinfo[0]%%:*}" != "$server" ]]; then if [[ ${nfsinfo[0]%%:*} != "$server" ]]; then
echo "CLIENT TEST INFO: got server: ${nfsinfo[0]%%:*}" echo "CLIENT TEST INFO: got server: ${nfsinfo[0]%%:*}"
echo "CLIENT TEST INFO: expected server: $server" echo "CLIENT TEST INFO: expected server: $server"
echo "CLIENT TEST END: $test_name [FAILED - WRONG SERVER]" echo "CLIENT TEST END: $test_name [FAILED - WRONG SERVER]"
@ -91,14 +91,14 @@ client_test() {


found=0 found=0
expected=1 expected=1
if [[ ${check_opt:0:1} = '-' ]]; then if [[ ${check_opt:0:1} == '-' ]]; then
expected=0 expected=0
check_opt=${check_opt:1} check_opt=${check_opt:1}
fi fi


opts=${nfsinfo[2]}, opts=${nfsinfo[2]},
while [[ $opts ]]; do while [[ $opts ]]; do
if [[ ${opts%%,*} = $check_opt ]]; then if [[ ${opts%%,*} == $check_opt ]]; then
found=1 found=1
break break
fi fi

View File

@ -19,7 +19,7 @@ wait_for_if_link() {
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -19,7 +19,7 @@ wait_for_if_link() {
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -31,7 +31,7 @@ wait_for_if_up() {
li=$(ip -o link show up dev $1) li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -42,7 +42,7 @@ wait_for_route_ok() {
li=$(ip route show) li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -19,7 +19,7 @@ wait_for_if_link() {
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -31,7 +31,7 @@ wait_for_if_up() {
li=$(ip -o link show up dev $1) li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -42,7 +42,7 @@ wait_for_route_ok() {
li=$(ip route show) li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -91,14 +91,14 @@ client_test() {
# nbdinfo=( fstype fsoptions ) # nbdinfo=( fstype fsoptions )
nbdinfo=($(awk '{print $2, $3; exit}' $TESTDIR/flag.img)) nbdinfo=($(awk '{print $2, $3; exit}' $TESTDIR/flag.img))


if [[ "${nbdinfo[0]}" != "$fstype" ]]; then if [[ ${nbdinfo[0]} != "$fstype" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - WRONG FS TYPE] \"${nbdinfo[0]}\" != \"$fstype\"" echo "CLIENT TEST END: $test_name [FAILED - WRONG FS TYPE] \"${nbdinfo[0]}\" != \"$fstype\""
return 1 return 1
fi fi


opts=${nbdinfo[1]}, opts=${nbdinfo[1]},
while [[ $opts ]]; do while [[ $opts ]]; do
if [[ ${opts%%,*} = $fsopt ]]; then if [[ ${opts%%,*} == $fsopt ]]; then
found=1 found=1
break break
fi fi

View File

@ -20,7 +20,7 @@ wait_for_if_link() {
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -32,7 +32,7 @@ wait_for_if_up() {
li=$(ip -o link show up dev $1) li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -43,7 +43,7 @@ wait_for_route_ok() {
li=$(ip route show) li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -83,7 +83,7 @@ client_test() {
read IFACES read IFACES
} < "$TESTDIR"/client.img } < "$TESTDIR"/client.img


if [[ "$OK" != "OK" ]]; then if [[ $OK != "OK" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1 return 1
fi fi

View File

@ -22,7 +22,7 @@ wait_for_if_link() {
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
fi fi
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -34,7 +34,7 @@ wait_for_if_up() {
li=$(ip -o link show up dev $1) li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0 [ -n "$li" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }
@ -45,7 +45,7 @@ wait_for_route_ok() {
li=$(ip route show) li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1 sleep 0.1
cnt=$(($cnt + 1)) cnt=$((cnt + 1))
done done
return 1 return 1
} }

View File

@ -96,7 +96,7 @@ client_test() {


{ {
read OK read OK
if [[ "$OK" != "OK" ]]; then if [[ $OK != "OK" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1 return 1
fi fi
@ -107,7 +107,7 @@ client_test() {
done done
} < "$TESTDIR"/client.img || return 1 } < "$TESTDIR"/client.img || return 1


if [[ "$check" != "$CONF" ]]; then if [[ $check != "$CONF" ]]; then
echo "Expected: '$check'" echo "Expected: '$check'"
echo echo
echo echo

View File

@ -21,8 +21,8 @@ test_run() {
set -x set -x
( (
cd "$TESTDIR" cd "$TESTDIR"
export CMDLINE="key1=0 key2=val key2=val2 key3=\" val 3 \" \" key 4 =\"val4 \"key 5=val 5\" \"key 6=\"\"val 6\" key7=\"foo\"bar\" baz=\"end \" key8 = val 8 \" export CMDLINE='key1=0 key2=val key2=val2 key3=" val 3 " " key 4 ="val4 "key 5=val 5" "key 6=""val 6" key7="foo"bar" baz="end " key8 = val 8 "
\"key 9\"=\"val 9\"" "key 9"="val 9"'


ret=0 ret=0


@ -33,10 +33,10 @@ test_run() {
["key3"]=" val 3 " ["key3"]=" val 3 "
[" key 4 "]="val4" [" key 4 "]="val4"
["key 5"]="val 5" ["key 5"]="val 5"
["key 6"]="\"val 6" ["key 6"]='"val 6'
["key7"]="foo\"bar\" baz=\"end" ["key7"]='foo"bar" baz="end'
[" key8 "]=" val 8 " [" key8 "]=" val 8 "
["key 9\""]="val 9" ['key 9"']="val 9"
) )
for key in "${!TEST[@]}"; do for key in "${!TEST[@]}"; do
if ! val=$(./dracut-getarg "${key}="); then if ! val=$(./dracut-getarg "${key}="); then
@ -52,7 +52,7 @@ test_run() {


declare -a INVALIDKEYS declare -a INVALIDKEYS


INVALIDKEYS=("key" "4" "5" "6" "key8" "9" "\"" "baz") INVALIDKEYS=("key" "4" "5" "6" "key8" "9" '"' "baz")
for key in "${INVALIDKEYS[@]}"; do for key in "${INVALIDKEYS[@]}"; do
val=$(./dracut-getarg "$key") val=$(./dracut-getarg "$key")
if (($? == 0)); then if (($? == 0)); then

View File

@ -20,7 +20,7 @@ $(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu -cpu ho
# Provide rng device sourcing the hosts /dev/urandom and other standard parameters # Provide rng device sourcing the hosts /dev/urandom and other standard parameters
ARGS="$ARGS -smp 2 -m 512 -nodefaults -vga none -display none -no-reboot -device virtio-rng-pci" ARGS="$ARGS -smp 2 -m 512 -nodefaults -vga none -display none -no-reboot -device virtio-rng-pci"


if ! [[ $* = *-daemonize* ]] && ! [[ $* = *-daemonize* ]]; then if ! [[ $* == *-daemonize* ]] && ! [[ $* == *-daemonize* ]]; then
ARGS="$ARGS -serial stdio" ARGS="$ARGS -serial stdio"
fi fi



View File

@ -3,7 +3,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH export PATH


[[ -e .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} ]] && . .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} [[ -e .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} ]] && . .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
if [[ -z "$TESTDIR" ]] || [[ ! -d "$TESTDIR" ]]; then if [[ -z $TESTDIR ]] || [[ ! -d $TESTDIR ]]; then
TESTDIR=$(mktemp -d -p "/var/tmp" -t dracut-test.XXXXXX) TESTDIR=$(mktemp -d -p "/var/tmp" -t dracut-test.XXXXXX)
fi fi
echo "TESTDIR=\"$TESTDIR\"" > .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} echo "TESTDIR=\"$TESTDIR\"" > .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
@ -28,7 +28,7 @@ COLOR_WARNING='\033[0;33m'
COLOR_NORMAL='\033[0;39m' COLOR_NORMAL='\033[0;39m'


check_root() { check_root() {
if (($EUID != 0)); then if ((EUID != 0)); then
SETCOLOR_FAILURE SETCOLOR_FAILURE
echo "Tests must be run as root! Please use 'sudo'." echo "Tests must be run as root! Please use 'sudo'."
SETCOLOR_NORMAL SETCOLOR_NORMAL
@ -65,7 +65,7 @@ while (($# > 0)); do
else else
echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[STARTED]" $COLOR_NORMAL echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[STARTED]" $COLOR_NORMAL
fi fi
if [[ "$V" == "1" ]]; then if [[ $V == "1" ]]; then
set -o pipefail set -o pipefail
( (
test_setup && test_run test_setup && test_run
@ -78,7 +78,7 @@ while (($# > 0)); do
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $ret exit $ret
) < /dev/null 2>&1 | tee test${TEST_RUN_ID:+-$TEST_RUN_ID}.log ) < /dev/null 2>&1 | tee test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
elif [[ "$V" == "2" ]]; then elif [[ $V == "2" ]]; then
set -o pipefail set -o pipefail
( (
test_setup && test_run test_setup && test_run