#!/bin/bash
# We don't support srcdir != builddir
-echo \#buildapi-variable-no-builddir >/dev/null
+echo \#buildapi-variable-no-builddir > /dev/null
prefix=/usr
while (($# > 0)); do
case "${1%%=*}" in
- --prefix) read_arg prefix "$@" || shift;;
- --libdir) read_arg libdir "$@" || shift;;
- --datadir) read_arg datadir "$@" || shift;;
- --sysconfdir) read_arg sysconfdir "$@" || shift;;
- --sbindir) read_arg sbindir "$@" || shift;;
- --mandir) read_arg mandir "$@" || shift;;
- --disable-documentation) enable_documentation=no;;
- --program-prefix) read_arg programprefix "$@" || shift;;
- --exec-prefix) read_arg execprefix "$@" || shift;;
- --bindir) read_arg bindir "$@" || shift;;
- --includedir) read_arg includedir "$@" || shift;;
- --libexecdir) read_arg libexecdir "$@" || shift;;
- --localstatedir) read_arg localstatedir "$@" || shift;;
- --sharedstatedir) read_arg sharedstatedir "$@" || shift;;
- --infodir) read_arg infodir "$@" || shift;;
- --systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift;;
- --bashcompletiondir) read_arg bashcompletiondir "$@" || shift;;
- *) echo "Ignoring unknown option '$1'";;
+ --prefix) read_arg prefix "$@" || shift ;;
+ --libdir) read_arg libdir "$@" || shift ;;
+ --datadir) read_arg datadir "$@" || shift ;;
+ --sysconfdir) read_arg sysconfdir "$@" || shift ;;
+ --sbindir) read_arg sbindir "$@" || shift ;;
+ --mandir) read_arg mandir "$@" || shift ;;
+ --disable-documentation) enable_documentation=no ;;
+ --program-prefix) read_arg programprefix "$@" || shift ;;
+ --exec-prefix) read_arg execprefix "$@" || shift ;;
+ --bindir) read_arg bindir "$@" || shift ;;
+ --includedir) read_arg includedir "$@" || shift ;;
+ --libexecdir) read_arg libexecdir "$@" || shift ;;
+ --localstatedir) read_arg localstatedir "$@" || shift ;;
+ --sharedstatedir) read_arg sharedstatedir "$@" || shift ;;
+ --infodir) read_arg infodir "$@" || shift ;;
+ --systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift ;;
+ --bashcompletiondir) read_arg bashcompletiondir "$@" || shift ;;
+ *) echo "Ignoring unknown option '$1'" ;;
esac
shift
done
exit 1
fi
-cat <<EOF >conftest.c
+cat << EOF > conftest.c
#include <fts.h>
int main() {
return 0;
EOF
# shellcheck disable=SC2086
-${CC} $CFLAGS $LDFLAGS conftest.c >/dev/null 2>&1
+${CC} $CFLAGS $LDFLAGS conftest.c > /dev/null 2>&1
ret=$?
rm -f conftest.c a.out
# musl doesn't have fts.h included
if test $ret -ne 0; then
- echo "dracut needs fts development files." >&2
- exit 1
+ echo "dracut needs fts development files." >&2
+ exit 1
fi
-cat <<EOF >conftest.c
+cat << EOF > conftest.c
#include <fts.h>
int main(void) {
fts_open(0, 0, 0);
found=no
for lib in "-lc" "-lfts"; do
- # shellcheck disable=SC2086
- ${CC} $CFLAGS $LDFLAGS conftest.c -Wl,$lib >/dev/null 2>&1
- ret=$?
- if test $ret -eq 0; then
- FTS_LIBS="$lib"
- found=yes
- break;
- fi
+ # shellcheck disable=SC2086
+ ${CC} $CFLAGS $LDFLAGS conftest.c -Wl,$lib > /dev/null 2>&1
+ ret=$?
+ if test $ret -eq 0; then
+ FTS_LIBS="$lib"
+ found=yes
+ break
+ fi
done
rm -f conftest.c a.out
if test $found = no; then
- echo "dracut couldn't find usable fts library" >&2
- exit 1
+ echo "dracut couldn't find usable fts library" >&2
+ exit 1
fi
-cat > Makefile.inc.$$ <<EOF
+cat > Makefile.inc.$$ << EOF
prefix ?= ${prefix}
libdir ?= ${libdir:-${prefix}/lib}
datadir ?= ${datadir:-${prefix}/share}
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-__contains_word () {
- local word="$1"; shift
- for w in "$@"; do [[ $w = "$word" ]] && return 0; done
- return 1
+__contains_word() {
+ local word="$1"
+ shift
+ for w in "$@"; do [[ $w = "$word" ]] && return 0; done
+ return 1
}
_dracut() {
- local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
- local -A OPTS=(
- [STANDALONE]='-f -v -q -l -H -h -M -N
+ local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD - 1]}
+ local -A OPTS=(
+ [STANDALONE]='-f -v -q -l -H -h -M -N
--ro-mnt --force --kernel-only --no-kernel --strip --nostrip
--hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf
--lvmconf --nolvmconf --debug --profile --verbose --quiet
--xz --zstd --no-compress --gzip --list-modules --show-modules --keep
--printsize --regenerate-all --noimageifnotneeded --early-microcode
--no-early-microcode --print-cmdline --reproducible --uefi'
- [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
+ [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
--omit-drivers --modules --omit --drivers --filesystems --install
--fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
--kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
--kernel-cmdline --sshkey --persistent-policy --install-optional
--loginstall --uefi-stub --kernel-image
'
- )
+ )
- # shellcheck disable=SC2086
- if __contains_word "$prev" ${OPTS[ARG]}; then
- case $prev in
- --kmoddir|-k|--fwdir|--confdir|--tmpdir)
- comps=$(compgen -d -- "$cur")
- compopt -o filenames
- ;;
- -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
- comps=$(compgen -f -- "$cur")
- compopt -o filenames
- ;;
- -a|-m|-o|--add|--modules|--omit)
- comps=$(dracut --list-modules 2>/dev/null)
- ;;
- --persistent-policy)
- comps=$(cd /dev/disk/ || return 0; printf -- "%s " *)
- ;;
- --kver)
- comps=$(cd /lib/modules || return 0; echo [0-9]*)
- ;;
- *)
- return 0
- ;;
- esac
- # shellcheck disable=SC2207
- # shellcheck disable=SC2016
- COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
+ # shellcheck disable=SC2086
+ if __contains_word "$prev" ${OPTS[ARG]}; then
+ case $prev in
+ --kmoddir | -k | --fwdir | --confdir | --tmpdir)
+ comps=$(compgen -d -- "$cur")
+ compopt -o filenames
+ ;;
+ -c | --conf | --sshkey | --add-fstab | --add-device | -I | --install | --install-optional)
+ comps=$(compgen -f -- "$cur")
+ compopt -o filenames
+ ;;
+ -a | -m | -o | --add | --modules | --omit)
+ comps=$(dracut --list-modules 2> /dev/null)
+ ;;
+ --persistent-policy)
+ comps=$(
+ cd /dev/disk/ || return 0
+ printf -- "%s " *
+ )
+ ;;
+ --kver)
+ comps=$(
+ cd /lib/modules || return 0
+ echo [0-9]*
+ )
+ ;;
+ *)
return 0
- fi
+ ;;
+ esac
+ # shellcheck disable=SC2207
+ # shellcheck disable=SC2016
+ COMPREPLY=($(compgen -W '$comps' -- "$cur"))
+ return 0
+ fi
- if [[ $cur = -* ]]; then
- # shellcheck disable=SC2207
- # shellcheck disable=SC2016
- COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
- return 0
- fi
+ if [[ $cur = -* ]]; then
+ # shellcheck disable=SC2207
+ # shellcheck disable=SC2016
+ COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur"))
+ return 0
+ fi
- local args
- _count_args
- if [[ $args -eq 1 ]]; then
- _filedir
- return 0
- elif [[ $args -eq 2 ]]; then
- # shellcheck disable=SC2034
- comps=$(cd /lib/modules || return 0; echo [0-9]*)
- # shellcheck disable=SC2207
- # shellcheck disable=SC2016
- COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
- return 0
- fi
+ local args
+ _count_args
+ if [[ $args -eq 1 ]]; then
+ _filedir
+ return 0
+ elif [[ $args -eq 2 ]]; then
+ # shellcheck disable=SC2034
+ comps=$(
+ cd /lib/modules || return 0
+ echo [0-9]*
+ )
+ # shellcheck disable=SC2207
+ # shellcheck disable=SC2016
+ COMPREPLY=($(compgen -W '$comps' -- "$cur"))
+ return 0
+ fi
}
complete -F _dracut dracut
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-
dwarning() {
echo "Warning: $*" >&2
}
EOF
}
-
imagedir=/boot/dracut/
overlay=/var/lib/dracut/overlay
while (($# > 0)); do
case $1 in
- -f|--force) force=yes;;
- -i|--imagedir) imagedir=$2;shift;;
- -o|--overlaydir) overlay=$2;shift;;
- --nooverlay) no_overlay=yes;shift;;
- --noimagedir) no_imagedir=yes;shift;;
- -h|--help) usage; exit 1 ;;
- --debug) export debug="yes";;
- -v|--verbose) beverbose="yes";;
- -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
+ -f | --force) force=yes ;;
+ -i | --imagedir)
+ imagedir=$2
+ shift
+ ;;
+ -o | --overlaydir)
+ overlay=$2
+ shift
+ ;;
+ --nooverlay)
+ no_overlay=yes
+ shift
+ ;;
+ --noimagedir)
+ no_imagedir=yes
+ shift
+ ;;
+ -h | --help)
+ usage
+ exit 1
+ ;;
+ --debug) export debug="yes" ;;
+ -v | --verbose) beverbose="yes" ;;
+ -*)
+ printf "\nUnknown option: %s\n\n" "$1" >&2
+ usage
+ exit 1
+ ;;
*) break ;;
esac
shift
done
-outfile=$1; shift
+outfile=$1
+shift
if [[ -z $outfile ]]; then
derror "No output file specified."
exit 1
fi
-baseimage=$1; shift
+baseimage=$1
+shift
if [[ -z $baseimage ]]; then
derror "No base image specified."
if [[ ! $no_overlay ]]; then
ofile="$imagedir/90-overlay.img"
dinfo "Creating image $ofile from directory $overlay"
- type pigz &>/dev/null && gzip=pigz || gzip=gzip
- ( cd "$overlay" || return 1 ; find . |cpio --quiet -H newc -o |$gzip -9 > "$ofile"; )
+ type pigz &> /dev/null && gzip=pigz || gzip=gzip
+ (
+ cd "$overlay" || return 1
+ find . | cpio --quiet -H newc -o | $gzip -9 > "$ofile"
+ )
fi
if [[ ! $no_imagedir ]]; then
done
fi
-images+=( "$@" )
+images+=("$@")
dinfo "Using base image $baseimage"
cat -- "$baseimage" > "$outfile"
[[ "$(type -t "$1")" = "function" ]]
}
-
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 = *"$2"* ]]; }
# Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK
if [[ "$1" == *.so* ]]; then
# shellcheck disable=SC2154
- for l in $libdirs ; do
+ for l in $libdirs; do
_path="${l}${_delim}${1}"
- if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
+ if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &> /dev/null; }; then
printf "%s\n" "${_path}"
return 0
fi
done
_path="${_delim}${1}"
- if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
+ if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &> /dev/null; }; then
printf "%s\n" "${_path}"
return 0
fi
return 0
fi
fi
- for p in $DRACUT_PATH ; do
+ for p in $DRACUT_PATH; do
_path="${p}${_delim}${1}"
- if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
+ if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
printf "%s\n" "${_path}"
return 0
fi
type -P "${1##*/}"
}
-ldconfig_paths()
-{
- $DRACUT_LDCONFIG ${dracutsysrootdir:+-r ${dracutsysrootdir} -f /etc/ld.so.conf} -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
+ldconfig_paths() {
+ $DRACUT_LDCONFIG ${dracutsysrootdir:+-r ${dracutsysrootdir} -f /etc/ld.so.conf} -pN 2> /dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
}
# Version comparision function. Assumes Linux style version scheme.
read -a _n2 <<< "${3//./ }"
local _i _res
- for ((_i=0; ; _i++))
- do
- if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then _res=0
- elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then _res=1
- elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then _res=2
- else continue
+ for ((_i = 0; ; _i++)); do
+ if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then
+ _res=0
+ elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then
+ _res=1
+ elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then
+ _res=2
+ else
+ continue
fi
break
done
case $_op in
- gt) ((_res == 1));;
- ge) ((_res != 2));;
- eq) ((_res == 0));;
- le) ((_res != 1));;
- lt) ((_res == 2));;
- ne) ((_res != 0));;
+ gt) ((_res == 1)) ;;
+ ge) ((_res != 2)) ;;
+ eq) ((_res == 0)) ;;
+ le) ((_res != 1)) ;;
+ lt) ((_res == 2)) ;;
+ ne) ((_res != 0)) ;;
esac
}
print_vars() {
local _var _value
- for _var in "$@"
- do
+ for _var in "$@"; do
eval printf -v _value "%s" \""\$$_var"\"
[[ ${_value} ]] && printf '%s="%s"\n' "$_var" "$_value"
done
set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
# corner case #1 - self looping link
- [[ "$1" == "$2" ]] && { printf "%s\n" "${1##*/}"; return; }
+ [[ "$1" == "$2" ]] && {
+ printf "%s\n" "${1##*/}"
+ return
+ }
# corner case #2 - own dir link
- [[ "${1%/*}" == "$2" ]] && { printf ".\n"; return; }
+ [[ "${1%/*}" == "$2" ]] && {
+ printf ".\n"
+ return
+ }
read -d '/' -r -a __current <<< "$1"
read -d '/' -a __absolute <<< "$2"
__abssize=${#__absolute[@]}
__cursize=${#__current[@]}
- while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]
- do
- (( __level++ ))
- if (( __level > __abssize || __level > __cursize ))
- then
+ while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]; do
+ ((__level++))
+ if ((__level > __abssize || __level > __cursize)); then
break
fi
done
- for ((__i = __level; __i < __cursize-1; __i++))
- do
- if ((__i > __level))
- then
+ for ((__i = __level; __i < __cursize - 1; __i++)); do
+ if ((__i > __level)); then
__newpath=$__newpath"/"
fi
__newpath=$__newpath".."
done
- for ((__i = __level; __i < __abssize; __i++))
- do
- if [[ -n $__newpath ]]
- then
+ for ((__i = __level; __i < __abssize; __i++)); do
+ if [[ -n $__newpath ]]; then
__newpath=$__newpath"/"
fi
__newpath=$__newpath${__absolute[__i]}
printf -- "%s\n" "$__newpath"
}
-
# get_fs_env <device>
# Get and the ID_FS_TYPE variable from udev for a device.
# Example:
ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \
| while read line || [ -n "$line" ]; do
if [[ "$line" == TYPE\=* ]]; then
- printf "%s" "${line#TYPE=}";
- exit 0;
+ printf "%s" "${line#TYPE=}"
+ exit 0
fi
- done)
+ done)
if [[ $ID_FS_TYPE ]]; then
printf "%s" "$ID_FS_TYPE"
return 0
# 8:2
get_maj_min() {
local _majmin
- _majmin="$(stat -L -c '%t:%T' "$1" 2>/dev/null)"
+ _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)"
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))"
}
-
# get_devpath_block <device>
# get the DEVPATH in /sys of a block device
get_devpath_block() {
for _i in /sys/block/*/dev /sys/block/*/*/dev; do
[[ -e "$_i" ]] || continue
- if [[ "$_majmin" == "$(<"$_i")" ]]; then
+ if [[ "$_majmin" == "$(< "$_i")" ]]; then
printf "%s" "${_i%/dev}"
return 0
fi
[ -z "$_dev" ] && return
if [[ -n "$persistent_policy" ]]; then
- _pol="/dev/disk/${persistent_policy}/*"
+ _pol="/dev/disk/${persistent_policy}/*"
else
- _pol=
+ _pol=
fi
for i in \
/dev/disk/by-partuuid/* \
/dev/disk/by-partlabel/* \
/dev/disk/by-id/* \
- /dev/disk/by-path/* \
- ; do
+ /dev/disk/by-path/*; do
[[ -e "$i" ]] || continue
[[ $i == /dev/mapper/control ]] && continue
[[ $i == /dev/mapper/mpath* ]] && continue
local _dev="$1"
case "$_dev" in
/dev/disk/by-uuid/*)
- printf "%s" "UUID=${_dev##*/}";;
+ printf "%s" "UUID=${_dev##*/}"
+ ;;
/dev/disk/by-label/*)
- printf "%s" "LABEL=${_dev##*/}";;
+ printf "%s" "LABEL=${_dev##*/}"
+ ;;
/dev/disk/by-partuuid/*)
- printf "%s" "PARTUUID=${_dev##*/}";;
+ printf "%s" "PARTUUID=${_dev##*/}"
+ ;;
/dev/disk/by-partlabel/*)
- printf "%s" "PARTLABEL=${_dev##*/}";;
+ printf "%s" "PARTLABEL=${_dev##*/}"
+ ;;
*)
- printf "%s" "$_dev";;
+ printf "%s" "$_dev"
+ ;;
esac
}
if [[ $use_fstab != yes ]]; then
[[ -d $_find_mpt/. ]]
- findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \
+ findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | {
while read _majmin _dev || [ -n "$_dev" ]; do
if [[ -b $_dev ]]; then
if ! [[ $_majmin ]] || [[ $_majmin == 0:* ]]; then
printf "%s\n" "$_dev"
return 0
fi
- done; return 1; } && return 0
+ done
+ return 1
+ } && return 0
fi
# fall back to /etc/fstab
- findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \
+ findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | {
while read _majmin _dev || [ -n "$_dev" ]; do
if ! [[ $_dev ]]; then
_dev="$_majmin"
printf "%s\n" "$_dev"
return 0
fi
- done; return 1; } && return 0
+ done
+ return 1
+ } && return 0
return 1
}
local _fs
if [[ $use_fstab != yes ]]; then
- findmnt -e -v -n -o 'FSTYPE' --target "$1" | { \
+ findmnt -e -v -n -o 'FSTYPE' --target "$1" | {
while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
printf "%s" "$_fs"
return 0
- done; return 1; } && return 0
+ done
+ return 1
+ } && return 0
fi
- findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | { \
+ findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | {
while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
printf "%s" "$_fs"
return 0
- done; return 1; } && return 0
+ done
+ return 1
+ } && return 0
return 1
}
fi
if [[ $use_fstab != yes ]]; then
- findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | { \
+ findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | {
while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
printf "%s" "$_fs"
return 0
- done; return 1; } && return 0
+ done
+ return 1
+ } && return 0
fi
- 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
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
printf "%s" "$_fs"
return 0
- done; return 1; } && return 0
+ done
+ return 1
+ } && return 0
return 1
}
# rw,relatime,discard,data=ordered
find_mp_fsopts() {
if [[ $use_fstab != yes ]]; then
- findmnt -e -v -n -o 'OPTIONS' --target "$1" 2>/dev/null && return 0
+ findmnt -e -v -n -o 'OPTIONS' --target "$1" 2> /dev/null && return 0
fi
findmnt --fstab -e -v -n -o 'OPTIONS' --target "$1"
fi
if [[ $use_fstab != yes ]]; then
- findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2>/dev/null && return 0
+ findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2> /dev/null && return 0
fi
findmnt --fstab -e -v -n -o 'OPTIONS' --source "$_find_dev"
}
-
# finds the major:minor of the block device backing the root filesystem.
find_root_block_device() { find_block_device /; }
# for_each_host_dev_fs <func>
# Execute "<func> <dev> <filesystem>" for every "<dev> <fs>" pair found
# in ${host_fs_types[@]}
-for_each_host_dev_fs()
-{
+for_each_host_dev_fs() {
local _func="$1"
local _dev
local _ret=1
[[ "${#host_fs_types[@]}" ]] || return 2
-
for _dev in "${!host_fs_types[@]}"; do
$_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
done
return $_ret
}
-host_fs_all()
-{
+host_fs_all() {
printf "%s\n" "${host_fs_types[@]}"
}
if ! lvm_internal_dev $2; then "$1" $2 && return; fi
check_vol_slaves "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
- check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
+ check_block_and_slaves $1 $(< "/sys/dev/block/$2/../dev") && return 0
fi
for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
- check_block_and_slaves $1 $(<"$_x/dev") && return 0
+ check_block_and_slaves $1 $(< "$_x/dev") && return 0
done
return 1
}
fi
check_vol_slaves_all "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
- check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
+ check_block_and_slaves_all $1 $(< "/sys/dev/block/$2/../dev") && _ret=0
fi
for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
- check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0
+ check_block_and_slaves_all $1 $(< "$_x/dev") && _ret=0
done
return $_ret
}
# for_each_host_dev_and_slaves <func>
# Execute "<func> <dev>" for every "<dev>" found
# in ${host_devs[@]} and their slaves
-for_each_host_dev_and_slaves_all()
-{
+for_each_host_dev_and_slaves_all() {
local _func="$1"
local _dev
local _ret=1
return $_ret
}
-for_each_host_dev_and_slaves()
-{
+for_each_host_dev_and_slaves() {
local _func="$1"
local _dev
_majmin="$2"
_lv="/dev/block/$_majmin"
_dm=/sys/dev/block/$_majmin/dm
- [[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
- _vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
+ [[ -f $_dm/uuid && $(< $_dm/uuid) =~ LVM-* ]] || return 1
+ _vg=$(dmsetup splitname --noheadings -o vg_name $(< "$_dm/name"))
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
- for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
- do
+ for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2> /dev/null); do
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
done
fi
_majmin="$2"
_lv="/dev/block/$_majmin"
_dm="/sys/dev/block/$_majmin/dm"
- [[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
- _vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
+ [[ -f $_dm/uuid && $(< $_dm/uuid) =~ LVM-* ]] || return 1
+ _vg=$(dmsetup splitname --noheadings -o vg_name $(< "$_dm/name"))
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
# when filter/global_filter is set, lvm may be failed
- lvm lvs --noheadings -o vg_name $_vg 2>/dev/null 1>/dev/null
+ lvm lvs --noheadings -o vg_name $_vg 2> /dev/null 1> /dev/null
if [ $? -ne 0 ]; then
- return 1
+ return 1
fi
- for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
- do
+ for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2> /dev/null); do
check_block_and_slaves_all $1 $(get_maj_min $_pv)
done
return 0
return 1
}
-
-
# fs_get_option <filesystem options> <search for option>
# search for a specific option in a bunch of filesystem options
# and return the value
$_option=*)
echo ${1#${_option}=}
break
+ ;;
esac
shift
done
}
-check_kernel_config()
-{
+check_kernel_config() {
local _config_opt="$1"
local _config_file
[[ -f $dracutsysrootdir/boot/config-$kernel ]] \
# 0 if the kernel module is either built-in or available
# 1 if the kernel module is not enabled
check_kernel_module() {
- modprobe -S $kernel --dry-run $1 &>/dev/null || return 1
+ modprobe -S $kernel --dry-run $1 &> /dev/null || return 1
}
# get_cpu_vendor
# Only two values are returned: AMD or Intel
-get_cpu_vendor ()
-{
+get_cpu_vendor() {
if grep -qE AMD /proc/cpuinfo; then
printf "AMD"
fi
# get_host_ucode
# Get the hosts' ucode file based on the /proc/cpuinfo
-get_ucode_file ()
-{
- local family=`grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //`
- local model=`grep -E "model" /proc/cpuinfo |grep -v name | head -1 | sed s/.*:\ //`
- local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
+get_ucode_file() {
+ local family=$(grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //)
+ local model=$(grep -E "model" /proc/cpuinfo | grep -v name | head -1 | sed s/.*:\ //)
+ local stepping=$(grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //)
if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
if [[ $family -ge 21 ]]; then
# If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
lvm_internal_dev() {
local dev_dm_dir=/sys/dev/block/$1/dm
- [[ ! -f $dev_dm_dir/uuid || $(<$dev_dm_dir/uuid) != LVM-* ]] && return 1 # Not an LVM device
+ [[ ! -f $dev_dm_dir/uuid || $(< $dev_dm_dir/uuid) != LVM-* ]] && return 1 # Not an LVM device
local DM_VG_NAME DM_LV_NAME DM_LV_LAYER
- eval $(dmsetup splitname --nameprefixes --noheadings --rows "$(<$dev_dm_dir/name)" 2>/dev/null)
+ eval $(dmsetup splitname --nameprefixes --noheadings --rows "$(< $dev_dm_dir/name)" 2> /dev/null)
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 0 # Better skip this!
[[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
}
local _mp="$1"
btrfs device usage "$_mp" \
| while read _dev _rest; do
- str_starts "$_dev" "/" || continue
- _dev=${_dev%,}
- printf -- "%s\n" "$_dev"
+ str_starts "$_dev" "/" || continue
+ _dev=${_dev%,}
+ printf -- "%s\n" "$_dev"
done
}
# quote periods in IPv4 address
qtd=${addr//./\\.}
- ip -o addr show | \
- sed -n 's%^.* '"$qtd"' peer \([0-9a-f.:]\{1,\}\(/[0-9]*\)\?\).*$%\1%p'
+ ip -o addr show \
+ | sed -n 's%^.* '"$qtd"' peer \([0-9a-f.:]\{1,\}\(/[0-9]*\)\?\).*$%\1%p'
}
netmask_for_addr() {
local ifname=$1 addr=$2
case $addr in
- *.*) proto=4;;
- *:*) proto=6;;
- *) return;;
+ *.*) proto=4 ;;
+ *:*) proto=6 ;;
+ *) return ;;
esac
- ip -o -$proto route show | \
- sed -n "s/^default via \([0-9a-z.:]\{1,\}\) dev $ifname .*\$/\1/p"
+ ip -o -$proto route show \
+ | sed -n "s/^default via \([0-9a-z.:]\{1,\}\) dev $ifname .*\$/\1/p"
}
# This works only for ifcfg-style network configuration!
# ifname clause to bind the interface name to a MAC address
if [ -d "/sys/class/net/$ifname/bonding" ]; then
dinfo "Found bonded interface '${ifname}'. Make sure to provide an appropriate 'bond=' cmdline."
- elif [ -e "/sys/class/net/$ifname/address" ] ; then
+ elif [ -e "/sys/class/net/$ifname/address" ]; then
ifmac=$(cat "/sys/class/net/$ifname/address")
[[ $ifmac ]] && printf 'ifname=%s:%s ' "${ifname}" "${ifmac}"
fi
bootproto=$(bootproto_for_iface "$ifname")
case $bootproto in
- dhcp|dhcp6|auto6) ;;
+ dhcp | dhcp6 | auto6) ;;
dhcp4)
- bootproto=dhcp;;
- static*|"")
- bootproto=;;
+ bootproto=dhcp
+ ;;
+ static* | "")
+ bootproto=
+ ;;
*)
derror "bootproto \"$bootproto\" is unsupported by dracut, trying static configuration"
- bootproto=;;
+ bootproto=
+ ;;
esac
if [[ $bootproto ]]; then
printf 'ip=%s:%s ' "${ifname}" "${bootproto}"
is_unbracketed_ipv6_address "$peer" && peer="[$peer]"
is_unbracketed_ipv6_address "$gateway" && gateway="[$gateway]"
printf 'ip=%s:%s:%s:%s::%s:none ' \
- "${local_addr}" "${peer}" "${gateway}" "${netmask}" "${ifname}"
+ "${local_addr}" "${peer}" "${gateway}" "${netmask}" "${ifname}"
fi
}
dracutbasedir="$(readlink -f $dracutbasedir)"
fi
-if ! is_func dinfo >/dev/null 2>&1; then
+if ! is_func dinfo > /dev/null 2>&1; then
# shellcheck source=./dracut-logger.sh
. "$dracutbasedir/dracut-logger.sh"
dlog_init
# shellcheck disable=SC2154
[[ $drivers_dir ]] && {
- if ! command -v kmod &>/dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
+ if ! command -v kmod &> /dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
fi
. "$dracutbasedir"/dracut-functions.sh
# Detect lib paths
-if ! [[ $libdirs ]] ; then
- if [[ $("$DRACUT_LDD" "$dracutsysrootdir$DRACUT_TESTBIN") == */lib64/* ]] &>/dev/null \
+if ! [[ $libdirs ]]; then
+ if [[ $("$DRACUT_LDD" "$dracutsysrootdir$DRACUT_TESTBIN") == */lib64/* ]] &> /dev/null \
&& [[ -d $dracutsysrootdir/lib64 ]]; then
libdirs+=" /lib64"
[[ -d $dracutsysrootdir/usr/lib64 ]] && libdirs+=" /usr/lib64"
fi
for cmd in "$@"; do
- if ! find_binary "$cmd" &>/dev/null; then
+ if ! find_binary "$cmd" &> /dev/null; then
dinfo "dracut module '${_module_name#[0-9][0-9]}' will not be installed, because command '$cmd' could not be found!"
((_ret++))
fi
fi
for cmd in "$@"; do
- if find_binary "$cmd" &>/dev/null; then
+ if find_binary "$cmd" &> /dev/null; then
_ret=0
break
fi
done
- if (( _ret != 0 )); then
+ if ((_ret != 0)); then
dinfo "$_module_name: Could not find any command of '$*'!"
return 1
fi
}
dracut_need_initqueue() {
- : >"$initdir/lib/dracut/need-initqueue"
+ : > "$initdir/lib/dracut/need-initqueue"
}
dracut_module_included() {
}
dracut_no_switch_root() {
- : >"$initdir/lib/dracut/no-switch-root"
+ : > "$initdir/lib/dracut/no-switch-root"
}
dracut_module_path() {
# DRACUT_INSTALL="dracut-install --debug"
# in which case the string cannot be tested for being executable.
DRINSTALLPARTS=0
-for i in $DRACUT_INSTALL ; do
- DRINSTALLPARTS=$((DRINSTALLPARTS+1))
+for i in $DRACUT_INSTALL; do
+ DRINSTALLPARTS=$((DRINSTALLPARTS + 1))
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!"
exit 10
fi
[[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
inst_dir() {
- [[ -e ${initdir}/"$1" ]] && return 0 # already there
+ [[ -e ${initdir}/"$1" ]] && return 0 # already there
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"
fi
_hostonly_install="-H"
shift
fi
- [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
+ [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
# shellcheck disable=SC2154
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
_hostonly_install="-H"
shift
fi
- [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
- [[ -e $1 ]] || return 1 # no source
+ [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
+ [[ -e $1 ]] || return 1 # no source
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" || :
fi
_hostonly_install="-H"
shift
fi
- [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
+ [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -L $1 ]] || return 1
- if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
- derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
+ if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
+ derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
fi
}
inst_multiple() {
local _ret
- if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
+ if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
return 0
else
_ret=$?
- derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
+ derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
return $_ret
fi
}
}
dracut_instmods() {
- local _silent=0;
- local i;
+ local _silent=0
+ local i
# shellcheck disable=SC2154
[[ $no_kernel = yes ]] && return
for i in "$@"; do
_hostonly_install="-H"
shift
fi
- [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
- [[ -e $1 ]] || return 1 # no source
- if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
- derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
+ [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
+ [[ -e $1 ]] || return 1 # no source
+ if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
+ derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
fi
}
inst_binary() {
- if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
- derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
+ if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
+ derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
fi
}
inst_script() {
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
- derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
+ derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
fi
}
inst_fsck_help() {
local _helper="/run/dracut/fsck/fsck_help_$1.txt"
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper"; then
- derror "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper" || :
+ derror "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper" || :
fi
}
until [[ ${_fn##*.} == so ]]; do
_fn="${_fn%.*}"
- [[ -L ${_fn} ]] && [[ $(readlink -f "${_fn}") == "${_orig}" ]] && _links+=( "${_fn}" )
+ [[ -L ${_fn} ]] && [[ $(readlink -f "${_fn}") == "${_orig}" ]] && _links+=("${_fn}")
done
echo "${_links[*]}}"
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
- continue;
+ continue
}
fi
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
- continue;
+ continue
}
fi
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
- continue;
+ continue
}
fi
# shellcheck disable=SC2013
for i in $(sed -nr 's/.*OWNER=?"([^ "]+).*/\1/p' "$1"); do
- if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2>/dev/null; then
- grep -E "^$i:" "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
+ if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2> /dev/null; then
+ grep -E "^$i:" "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
fi
done
# shellcheck disable=SC2013
for i in $(sed -nr 's/.*GROUP=?"([^ "]+).*/\1/p' "$1"); do
- if ! grep -Eq "^$i:" "$initdir/etc/group" 2>/dev/null; then
- grep -E "^$i:" "$dracutsysrootdir"/etc/group 2>/dev/null >> "$initdir/etc/group"
+ if ! grep -Eq "^$i:" "$initdir/etc/group" 2> /dev/null; then
+ grep -E "^$i:" "$dracutsysrootdir"/etc/group 2> /dev/null >> "$initdir/etc/group"
fi
done
}
inst_dir "${udevdir}/rules.d"
inst_dir "$_target"
- for _rule in ${udevdir}/rules.d/$1 ${dracutbasedir}/rules.d/$1 ; do
+ for _rule in ${udevdir}/rules.d/$1 ${dracutbasedir}/rules.d/$1; do
[[ -e $_rule ]] || continue
inst_rule_programs "$_rule"
inst_rule_group_owner "$_rule"
inst_simple "$_rule"
_found=$_rule
done
- if [[ -n ${hostonly} ]] ; then
- for _rule in ${_target}/$1 ; do
+ if [[ -n ${hostonly} ]]; then
+ for _rule in ${_target}/$1; do
[[ -f $_rule ]] || continue
inst_rule_programs "$_rule"
inst_rule_group_owner "$_rule"
[ -e "$f" ] || continue
while read -r line || [ -n "$line" ]; do
if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
- if (( UDEVVERSION >= 174 )); then
+ if ((UDEVVERSION >= 174)); then
printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
else
printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
fi
elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
- if (( UDEVVERSION >= 176 )); then
+ if ((UDEVVERSION >= 176)); then
printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
else
# shellcheck disable=SC2016
return 1
}
-
# inst_libdir_file [-n <pattern>] <file> [<file>...]
# Install a <file> located on a lib directory to the initramfs image
# -n <pattern> install matching files
fi
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
- module_check_mount "$_mod" "$_moddir"; ret=$?
+ module_check_mount "$_mod" "$_moddir"
+ ret=$?
# explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1
fi
done
- [[ " $mods_to_load " == *\ $_mod\ * ]] || \
- mods_to_load+=" $_mod "
+ [[ " $mods_to_load " == *\ $_mod\ * ]] \
+ || mods_to_load+=" $_mod "
return 0
}
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
if [[ " $dracutmodules $force_add_dracutmodules " == *\ $_mod\ * ]]; then
- module_check "$_mod" 1 "$_moddir"; ret=$?
+ module_check "$_mod" 1 "$_moddir"
+ ret=$?
else
- module_check "$_mod" 0 "$_moddir"; ret=$?
+ module_check "$_mod" 0 "$_moddir"
+ ret=$?
fi
# explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1
# module not in our list
if [[ $dracutmodules = all ]]; then
# check, if we can and should install this module
- module_check "$_mod" 0 "$_moddir"; ret=$?
+ module_check "$_mod" 0 "$_moddir"
+ ret=$?
if [[ $ret != 0 ]]; then
[[ $2 ]] && return 1
[[ $ret != 255 ]] && return 1
fi
done
- [[ " $mods_to_load " == *\ $_mod\ * ]] || \
- mods_to_load+=" $_mod "
+ [[ " $mods_to_load " == *\ $_mod\ * ]] \
+ || mods_to_load+=" $_mod "
return 0
}
local _func
_func=$1
for _moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
- [[ -d $_moddir ]] || continue;
- [[ -e $_moddir/install || -e $_moddir/installkernel || \
- -e $_moddir/module-setup.sh ]] || continue
- _mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]}
+ [[ -d $_moddir ]] || continue
+ [[ -e $_moddir/install || -e $_moddir/installkernel || -e \
+ $_moddir/module-setup.sh ]] || continue
+ _mod=${_moddir##*/}
+ _mod=${_mod#[0-9][0-9]}
$_func "$_mod" 1 "$_moddir"
done
done
# generate module dependencies for the initrd
- if [[ -d $initdir/lib/modules/$kernel ]] && \
- ! depmod -a -b "$initdir" "$kernel"; then
+ if [[ -d $initdir/lib/modules/$kernel ]] \
+ && ! depmod -a -b "$initdir" "$kernel"; then
dfatal "\"depmod -a $kernel\" failed."
exit 1
fi
if ((_ret != 0)) && [[ -z "$_silent" ]]; then
derror "FAILED: " \
"$DRACUT_INSTALL" \
- ${initdir:+-D "$initdir"} \
- ${dracutsysrootdir:+-r "$dracutsysrootdir"} \
- ${loginstall:+-L "$loginstall"} \
- ${hostonly:+-H} \
- ${omit_drivers:+-N "$omit_drivers"} \
- ${srcmods:+--kerneldir "$srcmods"} \
- ${_optional:+-o} \
- ${_silent:+--silent} \
- -m "$@"
+ ${initdir:+-D "$initdir"} \
+ ${dracutsysrootdir:+-r "$dracutsysrootdir"} \
+ ${loginstall:+-L "$loginstall"} \
+ ${hostonly:+-H} \
+ ${omit_drivers:+-N "$omit_drivers"} \
+ ${srcmods:+--kerneldir "$srcmods"} \
+ ${_optional:+-o} \
+ ${_silent:+--silent} \
+ -m "$@"
fi
[[ "$optional" ]] && return 0
# 0 if a virt environment was detected
# 1 if a virt environment could not be detected
# 255 if any error was encountered
- if type -P systemd-detect-virt >/dev/null 2>&1; then
- if ! vm=$(systemd-detect-virt --vm >/dev/null 2>&1); then
+ if type -P systemd-detect-virt > /dev/null 2>&1; then
+ if ! vm=$(systemd-detect-virt --vm > /dev/null 2>&1); then
return 255
fi
[[ $vm = "qemu" ]] && return 0
for i in /sys/class/dmi/id/*_vendor; do
[[ -f $i ]] || continue
read -r vendor < "$i"
- [[ "$vendor" == "QEMU" ]] && return 0
+ [[ "$vendor" == "QEMU" ]] && return 0
[[ "$vendor" == "Red Hat" ]] && return 0
- [[ "$vendor" == "Bochs" ]] && return 0
+ [[ "$vendor" == "Bochs" ]] && return 0
done
return 1
}
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
-mount -o ro /boot &>/dev/null || true
+mount -o ro /boot &> /dev/null || true
if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
- && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]] ; then
+ && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then
IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
- && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
+ && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then
IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
else
IMG="/boot/initramfs-${KERNEL_VERSION}.img"
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
-if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then
+if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet > /dev/null; then
rm -f -- .need_shutdown
-elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then
+elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet > /dev/null; then
rm -f -- .need_shutdown
-elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
+elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet > /dev/null; then
rm -f -- .need_shutdown
-elif $SKIP "$IMG" | zstd -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
+elif $SKIP "$IMG" | zstd -d -c | cpio -id --no-absolute-filenames --quiet > /dev/null; then
rm -f -- .need_shutdown
else
# something failed, so we clean up
fi
if [[ -d squash ]]; then
- unsquashfs -no-xattrs -f -d . squash-root.img >/dev/null
+ unsquashfs -no-xattrs -f -d . squash-root.img > /dev/null
if [ $? -ne 0 ]; then
echo "Squash module is enabled for this initramfs but failed to unpack squash-root.img" >&2
rm -f -- /run/initramfs/shutdown
fi
fi
-if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ] ; then
+if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then
. /etc/selinux/config
/usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /run/initramfs > /dev/null
fi
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
export __DRACUT_LOGGER__=1
-
## @brief Logging facility module for dracut both at build- and boot-time.
#
# @section intro Introduction
#
# @see dlog_init()
-
## @brief Initializes dracut Logger.
#
# @retval 1 if something has gone wrong
# See file doc comment for details.
dlog_init() {
local __oldumask
- local ret=0; local errmsg
+ local ret=0
+ local errmsg
[ -z "$stdloglvl" ] && stdloglvl=4
[ -z "$sysloglvl" ] && sysloglvl=0
[ -z "$kmsgloglvl" ] && kmsgloglvl=0
if [ -z "$fileloglvl" ]; then
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
- elif (( fileloglvl > 0 )); then
+ elif ((fileloglvl > 0)); then
if [[ $logfile ]]; then
__oldumask=$(umask)
umask 0377
- ! [ -e "$logfile" ] && : >"$logfile"
+ ! [ -e "$logfile" ] && : > "$logfile"
umask "$__oldumask"
if [[ -w $logfile ]] && [[ -f $logfile ]]; then
- # Mark new run in the log file
- echo >>"$logfile"
- if command -v date >/dev/null; then
- echo "=== $(date) ===" >>"$logfile"
+ # Mark new run in the log file
+ echo >> "$logfile"
+ if command -v date > /dev/null; then
+ echo "=== $(date) ===" >> "$logfile"
else
- echo "===============================================" >>"$logfile"
+ echo "===============================================" >> "$logfile"
fi
- echo >>"$logfile"
+ echo >> "$logfile"
else
- # We cannot log to file, so turn this facility off.
+ # We cannot log to file, so turn this facility off.
fileloglvl=0
ret=1
errmsg="'$logfile' is not a writable file"
fi
fi
- if (( UID != 0 )); then
+ if ((UID != 0)); then
kmsgloglvl=0
sysloglvl=0
fi
- if (( sysloglvl > 0 )); then
+ if ((sysloglvl > 0)); then
if [[ -d /run/systemd/journal ]] \
- && type -P systemd-cat &>/dev/null \
- && systemctl --quiet is-active systemd-journald.socket &>/dev/null \
- && { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &>/dev/null; } ; then
+ && type -P systemd-cat &> /dev/null \
+ && systemctl --quiet is-active systemd-journald.socket &> /dev/null \
+ && { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &> /dev/null; }; then
readonly _systemdcatfile="$DRACUT_TMPDIR/systemd-cat"
mkfifo "$_systemdcatfile"
readonly _dlogfd=15
- systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" &
- exec 15>"$_systemdcatfile"
- elif ! [[ -S /dev/log ]] && [[ -w /dev/log ]] || ! command -v logger >/dev/null; then
+ systemd-cat -t 'dracut' --level-prefix=true < "$_systemdcatfile" &
+ exec 15> "$_systemdcatfile"
+ elif ! [[ -S /dev/log ]] && [[ -w /dev/log ]] || ! command -v logger > /dev/null; then
# We cannot log to syslog, so turn this facility off.
kmsgloglvl=$sysloglvl
sysloglvl=0
fi
fi
- if (( sysloglvl > 0 )) || (( kmsgloglvl > 0 )); then
+ if ((sysloglvl > 0)) || ((kmsgloglvl > 0)); then
if [ -n "$dracutbasedir" ]; then
readonly syslogfacility=user
else
export syslogfacility
fi
- local lvl; local maxloglvl_l=0
+ local lvl
+ local maxloglvl_l=0
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
- (( lvl > maxloglvl_l )) && maxloglvl_l=$lvl
+ ((lvl > maxloglvl_l)) && maxloglvl_l=$lvl
done
readonly maxloglvl=$maxloglvl_l
export maxloglvl
-
- if (( stdloglvl < 6 )) && ((kmsgloglvl < 6)) && ((fileloglvl < 6)) && ((sysloglvl < 6)); then
+ if ((stdloglvl < 6)) && ((kmsgloglvl < 6)) && ((fileloglvl < 6)) && ((sysloglvl < 6)); then
unset dtrace
- dtrace() { :; };
+ dtrace() { :; }
fi
if ((stdloglvl < 5)) && ((kmsgloglvl < 5)) && ((fileloglvl < 5)) && ((sysloglvl < 5)); then
unset ddebug
- ddebug() { :; };
+ ddebug() { :; }
fi
if ((stdloglvl < 4)) && ((kmsgloglvl < 4)) && ((fileloglvl < 4)) && ((sysloglvl < 4)); then
unset dinfo
- dinfo() { :; };
+ dinfo() { :; }
fi
if ((stdloglvl < 3)) && ((kmsgloglvl < 3)) && ((fileloglvl < 3)) && ((sysloglvl < 3)); then
unset dwarn
- dwarn() { :; };
+ dwarn() { :; }
unset dwarning
- dwarning() { :; };
+ dwarning() { :; }
fi
if ((stdloglvl < 2)) && ((kmsgloglvl < 2)) && ((fileloglvl < 2)) && ((sysloglvl < 2)); then
unset derror
- derror() { :; };
+ derror() { :; }
fi
if ((stdloglvl < 1)) && ((kmsgloglvl < 1)) && ((fileloglvl < 1)) && ((sysloglvl < 1)); then
unset dfatal
- dfatal() { :; };
+ dfatal() { :; }
fi
[ -n "$errmsg" ] && derror "$errmsg"
# @result Echoes first letter of level name.
_lvl2char() {
case "$1" in
- 1) echo F;;
- 2) echo E;;
- 3) echo W;;
- 4) echo I;;
- 5) echo D;;
- 6) echo T;;
- *) return 1;;
+ 1) echo F ;;
+ 2) echo E ;;
+ 3) echo W ;;
+ 4) echo I ;;
+ 5) echo D ;;
+ 6) echo T ;;
+ *) return 1 ;;
esac
}
_lvl2syspri() {
printf "%s" -- "$syslogfacility."
case "$1" in
- 1) echo crit;;
- 2) echo error;;
- 3) echo warning;;
- 4) echo info;;
- 5) echo debug;;
- 6) echo debug;;
- *) return 1;;
+ 1) echo crit ;;
+ 2) echo error ;;
+ 3) echo warning ;;
+ 4) echo info ;;
+ 5) echo debug ;;
+ 6) echo debug ;;
+ *) return 1 ;;
esac
}
local lvl
case "$1" in
- 1) lvl=2;;
- 2) lvl=3;;
- 3) lvl=4;;
- 4) lvl=6;;
- 5) lvl=7;;
- 6) lvl=7;;
- *) return 1;;
+ 1) lvl=2 ;;
+ 2) lvl=3 ;;
+ 3) lvl=4 ;;
+ 4) lvl=6 ;;
+ 5) lvl=7 ;;
+ 6) lvl=7 ;;
+ *) return 1 ;;
esac
- [ "$syslogfacility" = user ] && echo $(( 8 + lvl )) || echo $(( 24 + lvl ))
+ [ "$syslogfacility" = user ] && echo $((8 + lvl)) || echo $((24 + lvl))
}
## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg
# - @c INFO to @c info
# - @c DEBUG and @c TRACE both to @c debug
_do_dlog() {
- local lvl="$1"; shift
+ local lvl="$1"
+ shift
local lvlc=$(_lvl2char "$lvl") || return 0
local msg="$*"
local lmsg="$lvlc: $*"
- (( lvl <= stdloglvl )) && printf -- 'dracut: %s\n' "$msg" >&2
+ ((lvl <= stdloglvl)) && printf -- 'dracut: %s\n' "$msg" >&2
- if (( lvl <= sysloglvl )); then
+ if ((lvl <= sysloglvl)); then
if [[ "$_dlogfd" ]]; then
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$lvl") & 7))" "$msg" >&$_dlogfd
else
fi
fi
- if (( lvl <= fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
- echo "$lmsg" >>"$logfile"
+ if ((lvl <= fileloglvl)) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
+ echo "$lmsg" >> "$logfile"
fi
- (( lvl <= kmsgloglvl )) && \
- echo "<$(_dlvl2syslvl "$lvl")>dracut[$$] $msg" >/dev/kmsg
+ ((lvl <= kmsgloglvl)) \
+ && echo "<$(_dlvl2syslvl "$lvl")>dracut[$$] $msg" > /dev/kmsg
}
## @brief Internal helper function for _do_dlog()
# echo "This is a warning" | dwarn
dlog() {
[ -z "$maxloglvl" ] && return 0
- (( $1 <= maxloglvl )) || return 0
+ (($1 <= maxloglvl)) || return 0
- if (( $# > 1 )); then
+ if (($# > 1)); then
_do_dlog "$@"
else
while read -r line || [ -n "$line" ]; do
unset GZIP
# Verify bash version, current minimum is 4
-if (( BASH_VERSINFO[0] < 4 )); then
+if ((BASH_VERSINFO[0] < 4)); then
printf -- 'You need at least Bash 4 to use dracut, sorry.' >&2
exit 1
fi
-dracut_args=( "$@" )
+dracut_args=("$@")
readonly dracut_cmd=$(readlink -f "$0")
set -o pipefail
local _dev
for _dev in "$@"; do
[[ " ${host_devs[*]} " == *" $_dev "* ]] && return
- host_devs+=( "$_dev" )
+ host_devs+=("$_dev")
done
}
fi
}
-check_conf_file()
-{
+check_conf_file() {
if grep -H -e '^[^#]*[+]=\("[^ ]\|.*[^ ]"\)' "$@"; then
printf '\ndracut: WARNING: <key>+=" <values> ": <values> should have surrounding white spaces!\n' >&2
printf 'dracut: WARNING: This will lead to unwanted side effects! Please fix the configuration file.\n\n' >&2
fi
}
-dropindirs_sort()
-{
- local suffix=$1; shift
+dropindirs_sort() {
+ local suffix=$1
+ shift
local -a files
local f d
}
}
-rearrange_params()
-{
+rearrange_params() {
# Workaround -i, --include taking 2 arguments
newat=()
for i in "$@"; do
- if [[ $i == "-i" ]] || [[ $i == "--include" ]]; then
+ if [[ $i == "-i" ]] || [[ $i == "--include" ]]; then
newat+=("++include") # Replace --include by ++include
else
newat+=("$i")
done
set -- "${newat[@]}" # Set new $@
- TEMP=$(unset POSIXLY_CORRECT; getopt \
- -o "a:m:o:d:I:k:c:r:L:fvqlHhMN" \
- --long kver: \
- --long add: \
- --long force-add: \
- --long add-drivers: \
- --long force-drivers: \
- --long omit-drivers: \
- --long modules: \
- --long omit: \
- --long drivers: \
- --long filesystems: \
- --long install: \
- --long install-optional: \
- --long fwdir: \
- --long libdirs: \
- --long fscks: \
- --long add-fstab: \
- --long mount: \
- --long device: \
- --long add-device: \
- --long nofscks \
- --long ro-mnt \
- --long kmoddir: \
- --long conf: \
- --long confdir: \
- --long tmpdir: \
- --long sysroot: \
- --long stdlog: \
- --long compress: \
- --long prefix: \
- --long rebuild: \
- --long force \
- --long kernel-only \
- --long no-kernel \
- --long print-cmdline \
- --long kernel-cmdline: \
- --long strip \
- --long nostrip \
- --long hardlink \
- --long nohardlink \
- --long noprefix \
- --long mdadmconf \
- --long nomdadmconf \
- --long lvmconf \
- --long nolvmconf \
- --long debug \
- --long profile \
- --long sshkey: \
- --long logfile: \
- --long verbose \
- --long quiet \
- --long local \
- --long hostonly \
- --long host-only \
- --long no-hostonly \
- --long no-host-only \
- --long hostonly-mode: \
- --long hostonly-cmdline \
- --long no-hostonly-cmdline \
- --long no-hostonly-default-device \
- --long persistent-policy: \
- --long fstab \
- --long help \
- --long bzip2 \
- --long lzma \
- --long xz \
- --long lzo \
- --long lz4 \
- --long zstd \
- --long no-compress \
- --long gzip \
- --long list-modules \
- --long show-modules \
- --long keep \
- --long printsize \
- --long regenerate-all \
- --long noimageifnotneeded \
- --long early-microcode \
- --long no-early-microcode \
- --long reproducible \
- --long no-reproducible \
- --long loginstall: \
- --long uefi \
- --long no-uefi \
- --long uefi-stub: \
- --long uefi-splash-image: \
- --long kernel-image: \
- --long no-hostonly-i18n \
- --long hostonly-i18n \
- --long hostonly-nics: \
- --long no-machineid \
- --long version \
- -- "$@")
+ TEMP=$(
+ unset POSIXLY_CORRECT
+ getopt \
+ -o "a:m:o:d:I:k:c:r:L:fvqlHhMN" \
+ --long kver: \
+ --long add: \
+ --long force-add: \
+ --long add-drivers: \
+ --long force-drivers: \
+ --long omit-drivers: \
+ --long modules: \
+ --long omit: \
+ --long drivers: \
+ --long filesystems: \
+ --long install: \
+ --long install-optional: \
+ --long fwdir: \
+ --long libdirs: \
+ --long fscks: \
+ --long add-fstab: \
+ --long mount: \
+ --long device: \
+ --long add-device: \
+ --long nofscks \
+ --long ro-mnt \
+ --long kmoddir: \
+ --long conf: \
+ --long confdir: \
+ --long tmpdir: \
+ --long sysroot: \
+ --long stdlog: \
+ --long compress: \
+ --long prefix: \
+ --long rebuild: \
+ --long force \
+ --long kernel-only \
+ --long no-kernel \
+ --long print-cmdline \
+ --long kernel-cmdline: \
+ --long strip \
+ --long nostrip \
+ --long hardlink \
+ --long nohardlink \
+ --long noprefix \
+ --long mdadmconf \
+ --long nomdadmconf \
+ --long lvmconf \
+ --long nolvmconf \
+ --long debug \
+ --long profile \
+ --long sshkey: \
+ --long logfile: \
+ --long verbose \
+ --long quiet \
+ --long local \
+ --long hostonly \
+ --long host-only \
+ --long no-hostonly \
+ --long no-host-only \
+ --long hostonly-mode: \
+ --long hostonly-cmdline \
+ --long no-hostonly-cmdline \
+ --long no-hostonly-default-device \
+ --long persistent-policy: \
+ --long fstab \
+ --long help \
+ --long bzip2 \
+ --long lzma \
+ --long xz \
+ --long lzo \
+ --long lz4 \
+ --long zstd \
+ --long no-compress \
+ --long gzip \
+ --long list-modules \
+ --long show-modules \
+ --long keep \
+ --long printsize \
+ --long regenerate-all \
+ --long noimageifnotneeded \
+ --long early-microcode \
+ --long no-early-microcode \
+ --long reproducible \
+ --long no-reproducible \
+ --long loginstall: \
+ --long uefi \
+ --long no-uefi \
+ --long uefi-stub: \
+ --long uefi-splash-image: \
+ --long kernel-image: \
+ --long no-hostonly-i18n \
+ --long hostonly-i18n \
+ --long hostonly-nics: \
+ --long no-machineid \
+ --long version \
+ -- "$@"
+ )
# shellcheck disable=SC2181
- if (( $? != 0 )); then
+ if (($? != 0)); then
usage
exit 1
fi
# parse command line args to check if '--rebuild' option is present
unset append_args_l
unset rebuild_file
-while :
-do
+while :; do
if [ "$1" == "--" ]; then
- shift; break
+ shift
+ break
fi
if [ "$1" == "--rebuild" ]; then
append_args_l="yes"
- rebuild_file="$2"
- if [ ! -e "$rebuild_file" ]; then
- echo "Image file '$rebuild_file', for rebuild, does not exist!"
- exit 1
- fi
- abs_rebuild_file=$(readlink -f "$rebuild_file") && rebuild_file="$abs_rebuild_file"
- shift; continue
+ rebuild_file="$2"
+ if [ ! -e "$rebuild_file" ]; then
+ echo "Image file '$rebuild_file', for rebuild, does not exist!"
+ exit 1
+ fi
+ abs_rebuild_file=$(readlink -f "$rebuild_file") && rebuild_file="$abs_rebuild_file"
+ shift
+ continue
fi
shift
done
while (($# > 0)); do
case ${1%%=*} in
++include)
- shift 2;;
+ shift 2
+ ;;
*)
if ! [[ ${outfile+x} ]]; then
outfile=$1
kernel=$1
else
printf "\nUnknown arguments: %s\n\n" "$*" >&2
- usage; exit 1;
+ usage
+ exit 1
fi
;;
esac
while :; do
if [[ $1 != "--" ]] && [[ $1 != "--rebuild" ]]; then
- PARMS_TO_STORE+=" $1";
+ PARMS_TO_STORE+=" $1"
fi
case $1 in
- --kver) kernel="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- -a|--add) add_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --force-add) force_add_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --add-drivers) add_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --force-drivers) force_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --omit-drivers) omit_drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- -m|--modules) dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- -o|--omit) omit_dracutmodules_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- -d|--drivers) drivers_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --filesystems) filesystems_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- -I|--install) install_items_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --install-optional) install_optional_items_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --fwdir) fw_dir_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --libdirs) libdirs_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --fscks) fscks_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --add-fstab) add_fstab_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --mount) fstab_lines+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --add-device|--device) add_device_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --kernel-cmdline) kernel_cmdline_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
- --nofscks) nofscks_l="yes";;
- --ro-mnt) ro_mnt_l="yes";;
- -k|--kmoddir) drivers_dir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- -c|--conf) conffile="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --confdir) confdir="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --tmpdir) tmpdir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- -r|--sysroot) sysroot_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- -L|--stdlog) stdloglvl_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --compress) compress_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --prefix) prefix_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --loginstall) loginstall_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --rebuild) if [[ $rebuild_file == "$outfile" ]]; then
- force=yes
- fi
- shift
- ;;
- -f|--force) force=yes;;
- --kernel-only) kernel_only="yes"; no_kernel="no";;
- --no-kernel) kernel_only="no"; no_kernel="yes";;
+ --kver)
+ kernel="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -a | --add)
+ add_dracutmodules_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --force-add)
+ force_add_dracutmodules_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --add-drivers)
+ add_drivers_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --force-drivers)
+ force_drivers_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --omit-drivers)
+ omit_drivers_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -m | --modules)
+ dracutmodules_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -o | --omit)
+ omit_dracutmodules_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -d | --drivers)
+ drivers_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --filesystems)
+ filesystems_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -I | --install)
+ install_items_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --install-optional)
+ install_optional_items_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --fwdir)
+ fw_dir_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --libdirs)
+ libdirs_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --fscks)
+ fscks_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --add-fstab)
+ add_fstab_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --mount)
+ fstab_lines+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --add-device | --device)
+ add_device_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --kernel-cmdline)
+ kernel_cmdline_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --nofscks) nofscks_l="yes" ;;
+ --ro-mnt) ro_mnt_l="yes" ;;
+ -k | --kmoddir)
+ drivers_dir_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -c | --conf)
+ conffile="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --confdir)
+ confdir="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --tmpdir)
+ tmpdir_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -r | --sysroot)
+ sysroot_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ -L | --stdlog)
+ stdloglvl_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --compress)
+ compress_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --prefix)
+ prefix_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --loginstall)
+ loginstall_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --rebuild)
+ if [[ $rebuild_file == "$outfile" ]]; then
+ force=yes
+ fi
+ shift
+ ;;
+ -f | --force) force=yes ;;
+ --kernel-only)
+ kernel_only="yes"
+ no_kernel="no"
+ ;;
+ --no-kernel)
+ kernel_only="no"
+ no_kernel="yes"
+ ;;
--print-cmdline)
- print_cmdline="yes"; hostonly_l="yes"; kernel_only="yes"; no_kernel="yes";;
+ print_cmdline="yes"
+ hostonly_l="yes"
+ kernel_only="yes"
+ no_kernel="yes"
+ ;;
--early-microcode)
- early_microcode_l="yes";;
+ early_microcode_l="yes"
+ ;;
--no-early-microcode)
- early_microcode_l="no";;
- --strip) do_strip_l="yes";;
- --nostrip) do_strip_l="no";;
- --hardlink) do_hardlink_l="yes";;
- --nohardlink) do_hardlink_l="no";;
- --noprefix) prefix_l="/";;
- --mdadmconf) mdadmconf_l="yes";;
- --nomdadmconf) mdadmconf_l="no";;
- --lvmconf) lvmconf_l="yes";;
- --nolvmconf) lvmconf_l="no";;
- --debug) debug="yes";;
- --profile) profile="yes";;
- --sshkey) sshkey="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --logfile) logfile_l="$2"; shift;;
- -v|--verbose) ((verbosity_mod_l++));;
- -q|--quiet) ((verbosity_mod_l--));;
- -l|--local)
- allowlocal="yes"
- [[ -f "$(readlink -f "${0%/*}")/dracut-init.sh" ]] \
- && dracutbasedir="$(readlink -f "${0%/*}")"
- ;;
- -H|--hostonly|--host-only)
- hostonly_l="yes" ;;
- -N|--no-hostonly|--no-host-only)
- hostonly_l="no" ;;
+ early_microcode_l="no"
+ ;;
+ --strip) do_strip_l="yes" ;;
+ --nostrip) do_strip_l="no" ;;
+ --hardlink) do_hardlink_l="yes" ;;
+ --nohardlink) do_hardlink_l="no" ;;
+ --noprefix) prefix_l="/" ;;
+ --mdadmconf) mdadmconf_l="yes" ;;
+ --nomdadmconf) mdadmconf_l="no" ;;
+ --lvmconf) lvmconf_l="yes" ;;
+ --nolvmconf) lvmconf_l="no" ;;
+ --debug) debug="yes" ;;
+ --profile) profile="yes" ;;
+ --sshkey)
+ sshkey="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --logfile)
+ logfile_l="$2"
+ shift
+ ;;
+ -v | --verbose) ((verbosity_mod_l++)) ;;
+ -q | --quiet) ((verbosity_mod_l--)) ;;
+ -l | --local)
+ allowlocal="yes"
+ [[ -f "$(readlink -f "${0%/*}")/dracut-init.sh" ]] \
+ && dracutbasedir="$(readlink -f "${0%/*}")"
+ ;;
+ -H | --hostonly | --host-only)
+ hostonly_l="yes"
+ ;;
+ -N | --no-hostonly | --no-host-only)
+ hostonly_l="no"
+ ;;
--hostonly-mode)
- hostonly_mode_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ hostonly_mode_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
--hostonly-cmdline)
- hostonly_cmdline_l="yes" ;;
+ hostonly_cmdline_l="yes"
+ ;;
--hostonly-i18n)
- i18n_install_all_l="no" ;;
+ i18n_install_all_l="no"
+ ;;
--hostonly-nics)
- hostonly_nics_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
+ hostonly_nics_l+=("$2")
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
--no-hostonly-i18n)
- i18n_install_all_l="yes" ;;
+ i18n_install_all_l="yes"
+ ;;
--no-hostonly-cmdline)
- hostonly_cmdline_l="no" ;;
+ hostonly_cmdline_l="no"
+ ;;
--no-hostonly-default-device)
- hostonly_default_device="no" ;;
+ hostonly_default_device="no"
+ ;;
--persistent-policy)
- persistent_policy_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
- --fstab) use_fstab_l="yes" ;;
- -h|--help) long_usage; exit 1 ;;
- --bzip2) compress_l="bzip2";;
- --lzma) compress_l="lzma";;
- --xz) compress_l="xz";;
- --lzo) compress_l="lzo";;
- --lz4) compress_l="lz4";;
- --zstd) compress_l="zstd";;
- --no-compress) _no_compress_l="cat";;
- --gzip) compress_l="gzip";;
- --list-modules) do_list="yes";;
- -M|--show-modules)
- show_modules_l="yes"
- ;;
- --keep) keep="yes";;
- --printsize) printsize="yes";;
- --regenerate-all) regenerate_all="yes";;
- --noimageifnotneeded) noimageifnotneeded="yes";;
- --reproducible) reproducible_l="yes";;
- --no-reproducible) reproducible_l="no";;
- --uefi) uefi_l="yes";;
- --no-uefi) uefi_l="no";;
+ persistent_policy_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
+ --fstab) use_fstab_l="yes" ;;
+ -h | --help)
+ long_usage
+ exit 1
+ ;;
+ --bzip2) compress_l="bzip2" ;;
+ --lzma) compress_l="lzma" ;;
+ --xz) compress_l="xz" ;;
+ --lzo) compress_l="lzo" ;;
+ --lz4) compress_l="lz4" ;;
+ --zstd) compress_l="zstd" ;;
+ --no-compress) _no_compress_l="cat" ;;
+ --gzip) compress_l="gzip" ;;
+ --list-modules) do_list="yes" ;;
+ -M | --show-modules)
+ show_modules_l="yes"
+ ;;
+ --keep) keep="yes" ;;
+ --printsize) printsize="yes" ;;
+ --regenerate-all) regenerate_all="yes" ;;
+ --noimageifnotneeded) noimageifnotneeded="yes" ;;
+ --reproducible) reproducible_l="yes" ;;
+ --no-reproducible) reproducible_l="no" ;;
+ --uefi) uefi_l="yes" ;;
+ --no-uefi) uefi_l="no" ;;
--uefi-stub)
- uefi_stub_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ uefi_stub_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
--uefi-splash-image)
- uefi_splash_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ uefi_splash_image_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
--kernel-image)
- kernel_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ kernel_image_l="$2"
+ PARMS_TO_STORE+=" '$2'"
+ shift
+ ;;
--no-machineid)
- machine_id_l="no";;
- --version) long_version; exit 1 ;;
- --) shift; break;;
+ machine_id_l="no"
+ ;;
+ --version)
+ long_version
+ exit 1
+ ;;
+ --)
+ shift
+ break
+ ;;
- *) # should not even reach this point
- printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;;
+ *) # should not even reach this point
+ printf "\n!Unknown option: '%s'\n\n" "$1" >&2
+ usage
+ exit 1
+ ;;
esac
shift
done
exit 1
fi
- ((len=${#dracut_args[@]}))
- for ((i=0; i < len; i++)); do
- [[ ${dracut_args[$i]} == "--regenerate-all" ]] && \
- unset "dracut_args[$i]"
+ ((len = ${#dracut_args[@]}))
+ for ((i = 0; i < len; i++)); do
+ [[ ${dracut_args[$i]} == "--regenerate-all" ]] \
+ && unset "dracut_args[$i]"
done
cd "$dracutsysrootdir"/lib/modules || exit 1
for i in *; do
[[ -f $i/modules.dep ]] || [[ -f $i/modules.dep.bin ]] || continue
"$dracut_cmd" --kver="$i" "${dracut_args[@]}"
- ((ret+=$?))
+ ((ret += $?))
done
exit "$ret"
fi
export DRACUT_LOG_LEVEL=warning
[[ $debug ]] && {
export DRACUT_LOG_LEVEL=debug
- export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
+ export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
set -x
}
[[ $profile ]] && {
- export PS4='+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: ';
+ export PS4='+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: '
set -x
debug=yes
}
rl=$(readlink -f "$dracutsysrootdir$i")
fi
rl="${rl#$dracutsysrootdir}"
- if [[ "$NPATH" != *:$rl* ]] ; then
+ if [[ "$NPATH" != *:$rl* ]]; then
NPATH+=":$rl"
fi
done
export SYSTEMCTL=${SYSTEMCTL:-systemctl}
# these options add to the stuff in the config file
-(( ${#add_dracutmodules_l[@]} )) && add_dracutmodules+=" ${add_dracutmodules_l[*]} "
-(( ${#force_add_dracutmodules_l[@]} )) && force_add_dracutmodules+=" ${force_add_dracutmodules_l[*]} "
-(( ${#fscks_l[@]} )) && fscks+=" ${fscks_l[*]} "
-(( ${#add_fstab_l[@]} )) && add_fstab+=" ${add_fstab_l[*]} "
-(( ${#install_items_l[@]} )) && install_items+=" ${install_items_l[*]} "
-(( ${#install_optional_items_l[@]} )) && install_optional_items+=" ${install_optional_items_l[*]} "
-(( ${#hostonly_nics_l[@]} )) && hostonly_nics+=" ${hostonly_nics_l[*]} "
+((${#add_dracutmodules_l[@]})) && add_dracutmodules+=" ${add_dracutmodules_l[*]} "
+((${#force_add_dracutmodules_l[@]})) && force_add_dracutmodules+=" ${force_add_dracutmodules_l[*]} "
+((${#fscks_l[@]})) && fscks+=" ${fscks_l[*]} "
+((${#add_fstab_l[@]})) && add_fstab+=" ${add_fstab_l[*]} "
+((${#install_items_l[@]})) && install_items+=" ${install_items_l[*]} "
+((${#install_optional_items_l[@]})) && install_optional_items+=" ${install_optional_items_l[*]} "
+((${#hostonly_nics_l[@]})) && hostonly_nics+=" ${hostonly_nics_l[*]} "
# these options override the stuff in the config file
-(( ${#dracutmodules_l[@]} )) && dracutmodules="${dracutmodules_l[*]}"
-(( ${#omit_dracutmodules_l[@]} )) && omit_dracutmodules="${omit_dracutmodules_l[*]}"
-(( ${#filesystems_l[@]} )) && filesystems="${filesystems_l[*]}"
-(( ${#fw_dir_l[@]} )) && fw_dir="${fw_dir_l[*]}"
-(( ${#libdirs_l[@]} ))&& libdirs="${libdirs_l[*]}"
+((${#dracutmodules_l[@]})) && dracutmodules="${dracutmodules_l[*]}"
+((${#omit_dracutmodules_l[@]})) && omit_dracutmodules="${omit_dracutmodules_l[*]}"
+((${#filesystems_l[@]})) && filesystems="${filesystems_l[*]}"
+((${#fw_dir_l[@]})) && fw_dir="${fw_dir_l[*]}"
+((${#libdirs_l[@]})) && libdirs="${libdirs_l[*]}"
[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
[[ ! $stdloglvl ]] && stdloglvl=4
[[ $early_microcode_l ]] && early_microcode=$early_microcode_l
[[ $early_microcode ]] || early_microcode=yes
[[ $early_microcode_image_dir ]] || early_microcode_image_dir=('/boot')
-[[ $early_microcode_image_name ]] || \
- early_microcode_image_name=('intel-uc.img' 'intel-ucode.img' 'amd-uc.img' 'amd-ucode.img' 'early_ucode.cpio' 'microcode.cpio')
+[[ $early_microcode_image_name ]] \
+ || early_microcode_image_name=('intel-uc.img' 'intel-ucode.img' 'amd-uc.img' 'amd-ucode.img' 'early_ucode.cpio' 'microcode.cpio')
[[ $logfile_l ]] && logfile="$logfile_l"
[[ $reproducible_l ]] && reproducible="$reproducible_l"
[[ $loginstall_l ]] && loginstall="$loginstall_l"
exit 1
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"
exit 1
fi
BUILD_ID=$(cat "$dracutsysrootdir"/etc/os-release "$dracutsysrootdir"/usr/lib/os-release \
- | while read -r line || [[ $line ]]; do \
- [[ $line =~ BUILD_ID\=* ]] && eval "$line" && echo "$BUILD_ID" && break; \
- done)
+ | while read -r line || [[ $line ]]; do
+ [[ $line =~ BUILD_ID\=* ]] && eval "$line" && echo "$BUILD_ID" && break
+ done)
if [[ -z $dracutsysrootdir ]]; then
if [[ -d /efi ]] && mountpoint -q /efi; then
efidir=/efi/EFI
else
if [[ -e $dracutsysrootdir/boot/vmlinuz-$kernel ]]; then
outfile="/boot/initramfs-$kernel.img"
- elif [[ $MACHINE_ID ]] && { [[ -d $dracutsysrootdir/boot/${MACHINE_ID} ]] || [[ -L $dracutsysrootdir/boot/${MACHINE_ID} ]] ;}; then
+ elif [[ $MACHINE_ID ]] && { [[ -d $dracutsysrootdir/boot/${MACHINE_ID} ]] || [[ -L $dracutsysrootdir/boot/${MACHINE_ID} ]]; }; then
outfile="$dracutsysrootdir/boot/${MACHINE_ID}/$kernel/initrd"
else
outfile="$dracutsysrootdir/boot/initramfs-$kernel.img"
case $hostonly_mode in
'')
- [[ $hostonly ]] && hostonly_mode="sloppy" ;;
- sloppy|strict)
+ [[ $hostonly ]] && hostonly_mode="sloppy"
+ ;;
+ sloppy | strict)
if [[ ! $hostonly ]]; then
unset hostonly_mode
fi
*)
printf "%s\n" "dracut: Invalid hostonly mode '$hostonly_mode'." >&2
exit 1
+ ;;
esac
[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
case "${drivers_dir}" in
- ''|*lib/modules/${kernel}|*lib/modules/${kernel}/) ;;
+ '' | *lib/modules/${kernel} | *lib/modules/${kernel}/) ;;
*)
[[ "$DRACUT_KMODDIR_OVERRIDE" ]] || {
printf "%s\n" "dracut: -k/--kmoddir path must contain \"lib/modules\" as a parent of your kernel module directory,"
mkdir -p "$initdir"
# 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"
mkdir "$early_cpio_dir"
fi
if ! [[ $print_cmdline ]]; then
inst "$DRACUT_TESTBIN"
- if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R "$DRACUT_TESTBIN" &>/dev/null; then
+ if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R "$DRACUT_TESTBIN" &> /dev/null; then
unset DRACUT_RESOLVE_LAZY
export DRACUT_RESOLVE_DEPS=1
fi
dracutfunctions=$dracutbasedir/dracut-functions.sh
export dracutfunctions
-(( ${#drivers_l[@]} )) && drivers="${drivers_l[*]}"
+((${#drivers_l[@]})) && drivers="${drivers_l[*]}"
drivers=${drivers/-/_}
-(( ${#add_drivers_l[@]} )) && add_drivers+=" ${add_drivers_l[*]} "
+((${#add_drivers_l[@]})) && add_drivers+=" ${add_drivers_l[*]} "
add_drivers=${add_drivers/-/_}
-(( ${#force_drivers_l[@]} )) && force_drivers+=" ${force_drivers_l[*]} "
+((${#force_drivers_l[@]})) && force_drivers+=" ${force_drivers_l[*]} "
force_drivers=${force_drivers/-/_}
-(( ${#omit_drivers_l[@]} )) && omit_drivers+=" ${omit_drivers_l[*]} "
+((${#omit_drivers_l[@]})) && omit_drivers+=" ${omit_drivers_l[*]} "
omit_drivers=${omit_drivers/-/_}
-(( ${#kernel_cmdline_l[@]} )) && kernel_cmdline+=" ${kernel_cmdline_l[*]} "
+((${#kernel_cmdline_l[@]})) && kernel_cmdline+=" ${kernel_cmdline_l[*]} "
omit_drivers_corrected=""
for d in $omit_drivers; do
unset omit_drivers_corrected
# prepare args for logging
-for ((i=0; i < ${#dracut_args[@]}; i++)); do
- [[ "${dracut_args[$i]}" == *\ * ]] && \
- dracut_args[$i]="\"${dracut_args[$i]}\""
- #" keep vim happy
+for ((i = 0; i < ${#dracut_args[@]}; i++)); do
+ [[ "${dracut_args[$i]}" == *\ * ]] \
+ && dracut_args[$i]="\"${dracut_args[$i]}\""
+ #" keep vim happy
done
dinfo "Executing: $dracut_cmd ${dracut_args[*]}"
[[ $do_list = yes ]] && {
for mod in "$dracutbasedir"/modules.d/*; do
- [[ -d $mod ]] || continue;
- [[ -e $mod/install || -e $mod/installkernel || \
- -e $mod/module-setup.sh ]] || continue
+ [[ -d $mod ]] || continue
+ [[ -e $mod/install || -e $mod/installkernel || -e \
+ $mod/module-setup.sh ]] || continue
printf "%s\n" "${mod##*/??}"
done
exit 0
# This is kinda legacy -- eventually it should go away.
case $dracutmodules in
- ""|auto) dracutmodules="all" ;;
+ "" | auto) dracutmodules="all" ;;
esac
abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
-
[[ -d $dracutsysrootdir$systemdutildir ]] \
- || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
+ || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2> /dev/null)
if ! [[ -d $dracutsysrootdir$systemdutildir ]]; then
[[ -e $dracutsysrootdir/lib/systemd/systemd-udevd ]] && systemdutildir=/lib/systemd
fi
[[ -d $dracutsysrootdir$systemdutilconfdir ]] \
- || systemdutilconfdir=$(pkg-config systemd --variable=systemdutilconfdir 2>/dev/null)
+ || systemdutilconfdir=$(pkg-config systemd --variable=systemdutilconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$systemdutilconfdir ]] || systemdutilconfdir=/etc/systemd
else
dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
fi
- elif ! ( command -v gzip &>/dev/null && command -v xz &>/dev/null); then
+ elif ! (command -v gzip &> /dev/null && command -v xz &> /dev/null); then
read -r _mod < "$srcmods"/modules.dep
_mod=${_mod%%:*}
if [[ -f $srcmods/"$_mod" ]]; then
# Check, if kernel modules are compressed, and if we can uncompress them
case "$_mod" in
- *.ko.gz) kcompress=gzip;;
- *.ko.xz) kcompress=xz;;
+ *.ko.gz) kcompress=gzip ;;
+ *.ko.xz) kcompress=xz ;;
esac
if [[ $kcompress ]]; then
- if ! command -v "$kcompress" &>/dev/null; then
+ if ! command -v "$kcompress" &> /dev/null; then
dfatal "Kernel modules are compressed with $kcompress, but $kcompress is not available."
exit 1
fi
fi
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"
exit 1
fi
unset EFI_MACHINE_TYPE_NAME
case $(uname -m) in
x86_64)
- EFI_MACHINE_TYPE_NAME=x64;;
+ EFI_MACHINE_TYPE_NAME=x64
+ ;;
i?86)
- EFI_MACHINE_TYPE_NAME=ia32;;
+ EFI_MACHINE_TYPE_NAME=ia32
+ ;;
*)
dfatal "Architecture '$(uname -m)' not supported to create a UEFI executable"
exit 1
if ! [[ -s $uefi_stub ]]; then
for uefi_stub in \
"$dracutsysrootdir${systemdutildir}/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" \
- "$dracutsysrootdir/usr/lib/gummiboot/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"; do
+ "$dracutsysrootdir/usr/lib/gummiboot/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"; do
[[ -s $uefi_stub ]] || continue
break
done
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"
unset acpi_override
fi
fi
# Do not complain on non-x86 architectures as it makes no sense
case $(uname -m) in
- x86_64|i?86)
+ x86_64 | i?86)
[[ $early_microcode != yes ]] \
&& dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]!=y"
;;
if [[ $hostonly ]]; then
for i in /sys /proc /run /dev; do
- if ! findmnt --target "$i" &>/dev/null; then
+ if ! findmnt --target "$i" &> /dev/null; then
dwarning "Turning off host-only mode: '$i' is not mounted!"
unset hostonly
fi
push_host_devs "$dev"
done
-if (( ${#add_device_l[@]} )); then
+if ((${#add_device_l[@]})); then
add_device+=" ${add_device_l[*]} "
push_host_devs "${add_device_l[@]}"
fi
"/usr/lib64" \
"/boot" \
"/boot/efi" \
- "/boot/zipl" \
- ;
- do
+ "/boot/zipl"; do
mp=$(readlink -f "$dracutsysrootdir$mp")
- mountpoint "$mp" >/dev/null 2>&1 || continue
+ mountpoint "$mp" > /dev/null 2>&1 || continue
_dev=$(find_block_device "$mp")
_bdev=$(readlink -f "/dev/block/$_dev")
[[ -b $_bdev ]] && _dev=$_bdev
done
[[ -d $dracutsysrootdir$dbus ]] \
- || dbus=$(pkg-config dbus --variable=dbus 2>/dev/null)
+ || dbus=$(pkg-config dbus --variable=dbus 2> /dev/null)
[[ -d $dracutsysrootdir$dbus ]] || dbus=/usr/share/dbus-1
[[ -d $dracutsysrootdir$dbusconfdir ]] \
- || dbusconfdir=$(pkg-config dbus --variable=dbusconfdir 2>/dev/null)
+ || dbusconfdir=$(pkg-config dbus --variable=dbusconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$dbusconfdir ]] || dbusconfdir=/etc/dbus-1
[[ -d $dracutsysrootdir$dbusinterfaces ]] \
- || dbusinterfaces=$(pkg-config dbus --variable=dbusinterfaces 2>/dev/null)
+ || dbusinterfaces=$(pkg-config dbus --variable=dbusinterfaces 2> /dev/null)
[[ -d $dracutsysrootdir$dbusinterfaces ]] || dbusinterfaces=${dbus}/interfaces
[[ -d $dracutsysrootdir$dbusinterfacesconfdir ]] \
- || dbusinterfacesconfdir=$(pkg-config dbus --variable=dbusinterfacesconfdir 2>/dev/null)
+ || dbusinterfacesconfdir=$(pkg-config dbus --variable=dbusinterfacesconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$dbusinterfacesconfdir ]] || dbusinterfacesconfdir=${dbusconfdir}/interfaces
[[ -d $dracutsysrootdir$dbusservices ]] \
- || dbusservices=$(pkg-config dbus --variable=dbusservices 2>/dev/null)
+ || dbusservices=$(pkg-config dbus --variable=dbusservices 2> /dev/null)
[[ -d $dracutsysrootdir$dbusservices ]] || dbusservices=${dbus}/services
[[ -d $dracutsysrootdir$dbusservicesconfdir ]] \
- || dbusservicesconfdir=$(pkg-config dbus --variable=dbusservicesconfdir 2>/dev/null)
+ || dbusservicesconfdir=$(pkg-config dbus --variable=dbusservicesconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$dbusservicesconfdir ]] || dbusservicesconfdir=${dbusconfdir}/services
[[ -d $dracutsysrootdir$dbussession ]] \
- || dbussession=$(pkg-config dbus --variable=dbussession 2>/dev/null)
+ || dbussession=$(pkg-config dbus --variable=dbussession 2> /dev/null)
[[ -d $dracutsysrootdir$dbussession ]] || dbussession=${dbus}/session.d
[[ -d $dracutsysrootdir$dbussessionconfdir ]] \
- || dbussessionconfdir=$(pkg-config dbus --variable=dbussessionconfdir 2>/dev/null)
+ || dbussessionconfdir=$(pkg-config dbus --variable=dbussessionconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$dbussessionconfdir ]] || dbussessionconfdir=${dbusconfdir}/session.d
[[ -d $dracutsysrootdir$dbussystem ]] \
- || dbussystem=$(pkg-config dbus --variable=dbussystem 2>/dev/null)
+ || dbussystem=$(pkg-config dbus --variable=dbussystem 2> /dev/null)
[[ -d $dracutsysrootdir$dbussystem ]] || dbussystem=${dbus}/system.d
[[ -d $dracutsysrootdir$dbussystemconfdir ]] \
- || dbussystemconfdir=$(pkg-config dbus --variable=dbussystemconfdir 2>/dev/null)
+ || dbussystemconfdir=$(pkg-config dbus --variable=dbussystemconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$dbussystemconfdir ]] || dbussystemconfdir=${dbusconfdir}/system.d
[[ -d $dracutsysrootdir$dbussystemservices ]] \
- || dbussystemservices=$(pkg-config dbus --variable=dbussystemservices 2>/dev/null)
+ || dbussystemservices=$(pkg-config dbus --variable=dbussystemservices 2> /dev/null)
[[ -d $dracutsysrootdir$dbussystemservices ]] || dbussystemservices=${dbus}/system-services
[[ -d $dracutsysrootdir$dbussystemservicesconfdir ]] \
- || dbussystemservicesconfdir=$(pkg-config dbus --variable=dbussystemservicesconfdir 2>/dev/null)
+ || dbussystemservicesconfdir=$(pkg-config dbus --variable=dbussystemservicesconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$dbussystemservicesconfdir ]] || dbussystemservicesconfdir=${dbusconfdir}/system-services
[[ -d $dracutsysrootdir$udevdir ]] \
- || udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)"
+ || udevdir="$(pkg-config udev --variable=udevdir 2> /dev/null)"
if ! [[ -d $dracutsysrootdir$udevdir ]]; then
[[ -e $dracutsysrootdir/lib/udev/ata_id ]] && udevdir=/lib/udev
[[ -e $dracutsysrootdir/usr/lib/udev/ata_id ]] && udevdir=/usr/lib/udev
fi
[[ -d $dracutsysrootdir$sysctl ]] \
- || sysctl=$(pkg-config systemd --variable=sysctl 2>/dev/null)
+ || sysctl=$(pkg-config systemd --variable=sysctl 2> /dev/null)
[[ -d $dracutsysrootdir$sysctl ]] || sysctl=/usr/lib/sysctl.d
[[ -d $dracutsysrootdir$sysctlconfdir ]] \
- || sysctlconfdir=$(pkg-config systemd --variable=sysctlconfdir 2>/dev/null)
+ || sysctlconfdir=$(pkg-config systemd --variable=sysctlconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$sysctlconfdir ]] || sysctlconfdir=/etc/sysctl.d
[[ -d $dracutsysrootdir$environment ]] \
- || environment=$(pkg-config systemd --variable=environment 2>/dev/null)
+ || environment=$(pkg-config systemd --variable=environment 2> /dev/null)
[[ -d $dracutsysrootdir$environment ]] || environment=/usr/lib/environment.d
[[ -d $dracutsysrootdir$environmentconfdir ]] \
- || environmentconfdir=$(pkg-config systemd --variable=environmentconfdir 2>/dev/null)
+ || environmentconfdir=$(pkg-config systemd --variable=environmentconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$environmentconfdir ]] || environmentconfdir=/etc/environment.d
[[ -d $dracutsysrootdir$systemdcatalog ]] \
- || systemdcatalog=$(pkg-config systemd --variable=systemdcatalog 2>/dev/null)
+ || systemdcatalog=$(pkg-config systemd --variable=systemdcatalog 2> /dev/null)
[[ -d $dracutsysrootdir$systemdcatalog ]] || systemdcatalog=${systemdutildir}/catalog
[[ -d $dracutsysrootdir$systemdnetwork ]] \
- || systemdnetwork=$(pkg-config systemd --variable=systemdnetwork 2>/dev/null)
+ || systemdnetwork=$(pkg-config systemd --variable=systemdnetwork 2> /dev/null)
[[ -d $dracutsysrootdir$systemdnetwork ]] || systemdnetwork=${systemdutildir}/network
[[ -d $dracutsysrootdir$systemdnetworkconfdir ]] \
- || systemdnetworkconfdir=$(pkg-config systemd --variable=systemdnetworkconfdir 2>/dev/null)
+ || systemdnetworkconfdir=$(pkg-config systemd --variable=systemdnetworkconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$systemdnetworkconfdir ]] || systemdnetworkconfdir=${systemdsystemconfdir}/network
[[ -d $dracutsysrootdir$systemdntpunits ]] \
- || systemdntpunits=$(pkg-config systemd --variable=systemdntpunits 2>/dev/null)
+ || systemdntpunits=$(pkg-config systemd --variable=systemdntpunits 2> /dev/null)
[[ -d $dracutsysrootdir$systemdntpunits ]] || systemdntpunits=${systemdutildir}/ntp-units.d
[[ -d $dracutsysrootdir$systemdntpunitsconfdir ]] \
- || systemdntpunitsconfdir=$(pkg-config systemd --variable=systemdntpunitsconfdir 2>/dev/null)
+ || systemdntpunitsconfdir=$(pkg-config systemd --variable=systemdntpunitsconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$systemdntpunitsconfdir ]] || systemdntpunitsconfdir=${systemdsystemconfdir}/ntp-units.d
[[ -d $dracutsysrootdir$systemdportable ]] \
- || systemdportable=$(pkg-config systemd --variable=systemdportable 2>/dev/null)
+ || systemdportable=$(pkg-config systemd --variable=systemdportable 2> /dev/null)
[[ -d $dracutsysrootdir$systemdportable ]] || systemdportable=${systemdutildir}/portable
[[ -d $dracutsysrootdir$systemdportableconfdir ]] \
- || systemdportableconfdir=$(pkg-config systemd --variable=systemdportableconfdir 2>/dev/null)
+ || systemdportableconfdir=$(pkg-config systemd --variable=systemdportableconfdir 2> /dev/null)
[[ -d "$dracutsysrootdir$systemdportableconfdir" ]] || systemdportableconfdir=${systemdsystemconfdir}/portable
[[ -d $dracutsysrootdir$systemdsystemunitdir ]] \
- || systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
+ || systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2> /dev/null)
[[ -d "$dracutsysrootdir$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
[[ -d $dracutsysrootdir$systemduser ]] \
- || systemduser=$(pkg-config systemd --variable=systemduser 2>/dev/null)
+ || systemduser=$(pkg-config systemd --variable=systemduser 2> /dev/null)
[[ -d $dracutsysrootdir$systemduser ]] || systemduser=${systemdutildir}/user
[[ -d $dracutsysrootdir$systemduserconfdir ]] \
- || systemduserconfdir=$(pkg-config systemd --variable=systemduserconfdir 2>/dev/null)
+ || systemduserconfdir=$(pkg-config systemd --variable=systemduserconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$systemduserconfdir ]] || systemduserconfdir=${systemdsystemconfdir}/user
[[ -d $dracutsysrootdir$systemdsystemconfdir ]] \
- || systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2>/dev/null)
+ || systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$systemdsystemconfdir ]] || systemdsystemconfdir=/etc/systemd/system
[[ -d $dracutsysrootdir$sysusers ]] \
- || sysusers=$(pkg-config systemd --variable=sysusers 2>/dev/null)
+ || sysusers=$(pkg-config systemd --variable=sysusers 2> /dev/null)
[[ -d $dracutsysrootdir$sysusers ]] || sysusers=/usr/lib/sysusers.d
[[ -d $dracutsysrootdir$sysusersconfdir ]] \
- || sysusersconfdir=$(pkg-config systemd --variable=sysusersconfdir 2>/dev/null)
+ || sysusersconfdir=$(pkg-config systemd --variable=sysusersconfdir 2> /dev/null)
[[ -d $dracutsysrootdir$sysusersconfdir ]] || sysusersconfdir=/etc/sysusers.d
[[ -d $dracutsysrootdir$tmpfilesdir ]] \
- || tmpfilesdir=$(pkg-config systemd --variable=tmpfilesdir 2>/dev/null)
+ || tmpfilesdir=$(pkg-config systemd --variable=tmpfilesdir 2> /dev/null)
if ! [[ -d $dracutsysrootdir$tmpfilesdir ]]; then
[[ -d $dracutsysrootdir/lib/tmpfiles.d ]] && tmpfilesdir=/lib/tmpfiles.d
dracut_module_included "fips" && export DRACUT_FIPS_MODE=1
-do_print_cmdline()
-{
+do_print_cmdline() {
local -A _mods_to_print
for i in $modules_loaded $mods_to_load; do
_mods_to_print[$i]=1
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
- _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
+ _d_mod=${moddir##*/}
+ _d_mod=${_d_mod#[0-9][0-9]}
[[ ${_mods_to_print[$_d_mod]} ]] || continue
module_cmdline "$_d_mod" "$moddir"
done
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
# shellcheck disable=SC2174
-[[ -h $dracutsysrootdir/lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib"
+[[ -L $dracutsysrootdir/lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib"
[[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
if [[ $prefix ]]; then
modules_loaded=" "
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
- _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
+ _d_mod=${moddir##*/}
+ _d_mod=${_d_mod#[0-9][0-9]}
[[ "$mods_to_load" == *\ $_d_mod\ * ]] || continue
if [[ $show_modules = yes ]]; then
printf "%s\n" "$_d_mod"
#print the module install size
if [ -n "$printsize" ]; then
- _isize_new=$(du -sk "${initdir}" | { read -r a _; echo -n "$a"; })
+ _isize_new=$(du -sk "${initdir}" | {
+ read -r a _
+ echo -n "$a"
+ })
_isize_delta=$((_isize_new - _isize))
printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
_isize=$_isize_new
hostonly='' instmods $drivers
fi
- if [[ -n "${add_drivers// }" ]]; then
+ if [[ -n "${add_drivers// /}" ]]; then
# shellcheck disable=SC2086
hostonly='' instmods -c $add_drivers
fi
hostonly='' instmods -c $force_drivers
rm -f "$initdir"/etc/cmdline.d/20-force_driver.conf
for mod in $force_drivers; do
- echo "rd.driver.pre=$mod" >>"$initdir"/etc/cmdline.d/20-force_drivers.conf
+ echo "rd.driver.pre=$mod" >> "$initdir"/etc/cmdline.d/20-force_drivers.conf
done
fi
if [[ $filesystems ]]; then
dinfo "*** Installing kernel module dependencies done ***"
if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then
- if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \
- [[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
+ if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] \
+ && [[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
for i in "${initdir}"/etc/cmdline.d/*.conf; do
# We need no initramfs image and do not generate one.
[[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0
if [[ $kernel_only != yes ]]; then
# FIXME: handle legacy item split
# shellcheck disable=SC2068
- (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
+ ((${#install_items[@]} > 0)) && inst_multiple ${install_items[@]}
# shellcheck disable=SC2068
- (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
+ ((${#install_optional_items[@]} > 0)) && inst_multiple -o ${install_optional_items[@]}
if [[ $kernel_cmdline ]] && [[ $uefi != yes ]]; then
printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
dinfo "*** Resolving executable dependencies ***"
find "$initdir" -type f -perm /0111 -not -path '*.ko' -print0 \
- | xargs -r -0 "$DRACUT_INSTALL" ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R ${DRACUT_FIPS_MODE:+-f} --
+ | xargs -r -0 "$DRACUT_INSTALL" ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R ${DRACUT_FIPS_MODE:+-f} --
dinfo "*** Resolving executable dependencies done ***"
fi
export DRACUT_RESOLVE_DEPS=1
fi
-for ((i=0; i < ${#include_src[@]}; i++)); do
+for ((i = 0; i < ${#include_src[@]}; i++)); do
src="${include_src[$i]}"
target="${include_target[$i]}"
if [[ $src && $target ]]; then
# symlinks to $prefix
# Objectname is a file or a directory
for objectname in "$src"/*; do
- [[ -e "$objectname" || -h "$objectname" ]] || continue
+ [[ -e "$objectname" || -L "$objectname" ]] || continue
if [[ -d "$objectname" ]]; then
# objectname is a directory, let's compute the final directory name
object_destdir=${destdir}/${objectname#$src/}
fi
done
-if [[ $do_hardlink = yes ]] && command -v hardlink >/dev/null; then
+if [[ $do_hardlink = yes ]] && command -v hardlink > /dev/null; then
dinfo "*** Hardlinking files ***"
hardlink "$initdir" 2>&1
dinfo "*** Hardlinking files done ***"
fi
# strip binaries
-if [[ $do_strip = yes ]] ; then
+if [[ $do_strip = yes ]]; then
# Prefer strip from elfutils for package size
declare strip_cmd
strip_cmd=$(command -v eu-strip)
[ -z "$strip_cmd" ] && strip_cmd="strip"
for p in $strip_cmd xargs find; do
- if ! type -P $p >/dev/null; then
+ if ! type -P $p > /dev/null; then
dinfo "Could not find '$p'. Not stripping the initramfs."
do_strip=no
fi
# cleanup empty ldconfig_paths directories
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
if [[ $early_microcode = yes ]]; then
if cd "$early_cpio_dir/d"; then
for _ucodedir in "${early_microcode_image_dir[@]}"; do
for _ucodename in "${early_microcode_image_name[@]}"; do
- [[ -e "$_ucodedir/$_ucodename" ]] && \
- cpio --extract --file "$_ucodedir/$_ucodename" --quiet \
- "kernel/x86/microcode/${ucode_dest[$idx]}"
+ [[ -e "$_ucodedir/$_ucodename" ]] \
+ && cpio --extract --file "$_ucodedir/$_ucodename" --quiet \
+ "kernel/x86/microcode/${ucode_dest[$idx]}"
if [[ -e "$_dest_dir/${ucode_dest[$idx]}" ]]; then
dinfo "*** Using microcode found in '$_ucodedir/$_ucodename' ***"
create_early_cpio="yes"
fi
dinfo "*** Store current command line parameters ***"
-if ! ( echo "$PARMS_TO_STORE" > "$initdir"/lib/dracut/build-parameter.txt ); then
+if ! (echo "$PARMS_TO_STORE" > "$initdir"/lib/dracut/build-parameter.txt); then
dfatal "Could not store the current command line parameters"
exit 1
fi
-if [[ $hostonly_cmdline == "yes" ]] ; then
+if [[ $hostonly_cmdline == "yes" ]]; then
unset _stored_cmdline
- if [[ -d $initdir/etc/cmdline.d ]];then
+ if [[ -d $initdir/etc/cmdline.d ]]; then
dinfo "Stored kernel commandline:"
- for conf in "$initdir"/etc/cmdline.d/*.conf ; do
+ for conf in "$initdir"/etc/cmdline.d/*.conf; do
[ -e "$conf" ] || continue
dinfo "$(< "$conf")"
_stored_cmdline=1
# FIPS workaround for Fedora/RHEL: libcrypto needs libssl when FIPS is enabled
if [[ $DRACUT_FIPS_MODE ]]; then
- for _dir in $libdirs; do
- for _f in "$dracutsysrootdir$_dir/libcrypto.so"*; do
- [[ -e "$_f" ]] || continue
- inst_libdir_file -o "libssl.so*"
- break 2
- done
- done
+ for _dir in $libdirs; do
+ for _f in "$dracutsysrootdir$_dir/libcrypto.so"*; do
+ [[ -e "$_f" ]] || continue
+ inst_libdir_file -o "libssl.so*"
+ break 2
+ done
+ done
fi
fi
dinfo "*** Stripping files ***"
find "$initdir" -type f \
-executable -not -path '*/lib/modules/*.ko' -print0 \
- | xargs -r -0 $strip_cmd -g -p 2>/dev/null
+ | xargs -r -0 $strip_cmd -g -p 2> /dev/null
# strip kernel modules, but do not touch signed modules
find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
| while read -r -d $'\0' f || [ -n "$f" ]; do
- SIG=$(tail -c 28 "$f" | tr -d '\000')
- [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
- done | xargs -r -0 $strip_cmd -g -p
+ SIG=$(tail -c 28 "$f" | tr -d '\000')
+ [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
+ done | xargs -r -0 $strip_cmd -g -p
dinfo "*** Stripping files done ***"
fi
declare squash_compress_arg
# shellcheck disable=SC2086
if [[ $compress ]]; then
- if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $compress &>/dev/null; then
+ if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $compress &> /dev/null; then
dwarn "mksquashfs doesn't support compressor '$compress', failing back to default compressor."
else
squash_compress_arg="$compress"
if ! mksquashfs "$squash_dir" "$squash_img" \
-no-xattrs -no-exports -noappend -no-recovery -always-use-fragments \
-no-progress ${squash_compress_arg:+-comp $squash_compress_arg} 1> /dev/null; then
- dfatal "dracut: Failed making squash image"
- exit 1
+ dfatal "dracut: Failed making squash image"
+ exit 1
fi
rm -rf "$squash_dir"
# The microcode blob is _before_ the initramfs blob, not after
if ! (
- umask 077; cd "$early_cpio_dir/d"
- find . -print0 | sort -z \
- | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null \
- ${cpio_owner:+-R "$cpio_owner"} -H newc -o --quiet > "${DRACUT_TMPDIR}/initramfs.img"
- ); then
+ umask 077
+ cd "$early_cpio_dir/d"
+ find . -print0 | sort -z \
+ | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null \
+ ${cpio_owner:+-R "$cpio_owner"} -H newc -o --quiet > "${DRACUT_TMPDIR}/initramfs.img"
+ ); then
dfatal "dracut: creation of $outfile failed"
exit 1
fi
if ! [[ $compress ]]; then
# check all known compressors, if none specified
for i in $DRACUT_COMPRESS_PIGZ $DRACUT_COMPRESS_GZIP $DRACUT_COMPRESS_LZ4 $DRACUT_COMPRESS_LZOP $ $DRACUT_COMPRESS_ZSTD $DRACUT_COMPRESS_LZMA $DRACUT_COMPRESS_XZ $DRACUT_COMPRESS_LBZIP2 $OMPRESS_BZIP2 $DRACUT_COMPRESS_CAT; do
- command -v "$i" &>/dev/null || continue
+ command -v "$i" &> /dev/null || continue
compress="$i"
break
done
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
# choose the right arguments for the compressor
case $compress in
- bzip2|lbzip2)
- if [[ "$compress" = lbzip2 ]] || command -v "$DRACUT_COMPRESS_LBZIP2" &>/dev/null; then
+ bzip2 | lbzip2)
+ if [[ "$compress" = lbzip2 ]] || command -v "$DRACUT_COMPRESS_LBZIP2" &> /dev/null; then
compress="$DRACUT_COMPRESS_LBZIP2 -9"
else
compress="$DRACUT_COMPRESS_BZIP2 -9"
xz)
compress="$DRACUT_COMPRESS_XZ --check=crc32 --lzma2=dict=1MiB -T0"
;;
- gzip|pigz)
- if [[ "$compress" = pigz ]] || command -v "$DRACUT_COMPRESS_PIGZ" &>/dev/null; then
+ gzip | pigz)
+ if [[ "$compress" = pigz ]] || command -v "$DRACUT_COMPRESS_PIGZ" &> /dev/null; then
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"
else
compress="$DRACUT_COMPRESS_GZIP -n -9"
fi
;;
- lzo|lzop)
+ lzo | lzop)
compress="$DRACUT_COMPRESS_LZOP -9"
;;
lz4)
compress="$DRACUT_COMPRESS_LZ4 -l -9"
;;
zstd)
- compress="$DRACUT_COMPRESS_ZSTD -15 -q -T0"
- ;;
+ compress="$DRACUT_COMPRESS_ZSTD -15 -q -T0"
+ ;;
esac
if ! (
- umask 077; cd "$initdir"
- find . -print0 | sort -z \
- | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null ${cpio_owner:+-R "$cpio_owner"} -H newc -o --quiet \
- | $compress >> "${DRACUT_TMPDIR}/initramfs.img"
- ); then
+ umask 077
+ cd "$initdir"
+ find . -print0 | sort -z \
+ | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null ${cpio_owner:+-R "$cpio_owner"} -H newc -o --quiet \
+ | $compress >> "${DRACUT_TMPDIR}/initramfs.img"
+); then
dfatal "dracut: creation of $outfile failed"
exit 1
fi
# shellcheck disable=SC2154
-if (( maxloglvl >= 5 )) && (( verbosity_mod_l >= 0 )); then
+if ((maxloglvl >= 5)) && ((verbosity_mod_l >= 0)); then
if [[ $allowlocal ]]; then
- "$dracutbasedir/lsinitrd.sh" "${DRACUT_TMPDIR}/initramfs.img"| ddebug
+ "$dracutbasedir/lsinitrd.sh" "${DRACUT_TMPDIR}/initramfs.img" | ddebug
else
- lsinitrd "${DRACUT_TMPDIR}/initramfs.img"| ddebug
+ lsinitrd "${DRACUT_TMPDIR}/initramfs.img" | ddebug
fi
fi
if [[ $uefi = yes ]]; then
if [[ $kernel_cmdline ]]; then
echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt"
- elif [[ $hostonly_cmdline = yes ]] && [ -d "$initdir/etc/cmdline.d" ];then
- for conf in "$initdir"/etc/cmdline.d/*.conf ; do
+ elif [[ $hostonly_cmdline = yes ]] && [ -d "$initdir/etc/cmdline.d" ]; then
+ for conf in "$initdir"/etc/cmdline.d/*.conf; do
[ -e "$conf" ] || continue
printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt"
done
fi
if objcopy \
- ${uefi_osrelease:+--add-section .osrel="$uefi_osrelease" --change-section-vma .osrel=0x20000} \
- ${uefi_cmdline:+--add-section .cmdline="$uefi_cmdline" --change-section-vma .cmdline=0x30000} \
- ${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=0x40000} \
- --add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \
- --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \
- "$uefi_stub" "${uefi_outdir}/linux.efi"; then
- if [[ -n "${uefi_secureboot_key}" && -n "${uefi_secureboot_cert}" ]]; then \
+ ${uefi_osrelease:+--add-section .osrel="$uefi_osrelease" --change-section-vma .osrel=0x20000} \
+ ${uefi_cmdline:+--add-section .cmdline="$uefi_cmdline" --change-section-vma .cmdline=0x30000} \
+ ${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=0x40000} \
+ --add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \
+ --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \
+ "$uefi_stub" "${uefi_outdir}/linux.efi"; then
+ if [[ -n "${uefi_secureboot_key}" && -n "${uefi_secureboot_cert}" ]]; then
if sbsign \
- --key "${uefi_secureboot_key}" \
- --cert "${uefi_secureboot_cert}" \
- --output "$outfile" "${uefi_outdir}/linux.efi"; then
+ --key "${uefi_secureboot_key}" \
+ --cert "${uefi_secureboot_cert}" \
+ --output "$outfile" "${uefi_outdir}/linux.efi"; then
dinfo "*** Creating signed UEFI image file '$outfile' done ***"
else
dfatal "*** Creating signed UEFI image file '$outfile' failed ***"
fi
fi
-command -v restorecon &>/dev/null && restorecon -- "$outfile"
+command -v restorecon &> /dev/null && restorecon -- "$outfile"
btrfs_uuid() {
btrfs filesystem show "$1" | sed -n '1s/^.*uuid: //p'
fstype=$(stat -f -c %T -- "$outfile")
case $fstype in
msdos)
- return 1;;
+ return 1
+ ;;
btrfs)
- freeze_ok_for_btrfs "$outfile";;
+ freeze_ok_for_btrfs "$outfile"
+ ;;
*)
- return 0;;
+ return 0
+ ;;
esac
}
# use fsfreeze only if we're not writing to /
if [[ "$(stat -c %m -- "$outfile")" != "/" ]] && freeze_ok_for_fstype "$outfile"; then
FSFROZEN="$(dirname "$outfile")"
- if ! (fsfreeze -f "${FSFROZEN}" 2>/dev/null && fsfreeze -u "${FSFROZEN}" 2>/dev/null); then
+ if ! (fsfreeze -f "${FSFROZEN}" 2> /dev/null && fsfreeze -u "${FSFROZEN}" 2> /dev/null); then
dinfo "dracut: warning: could not fsfreeze $(dirname "$outfile")"
fi
unset FSFROZEN
set -e
if [[ -z "$DRACUT_TMPDIR" ]]; then
- echo "DRACUT_TMPDIR is unset, exiting"
- exit 0
+ echo "DRACUT_TMPDIR is unset, exiting"
+ exit 0
fi
# We have to unset "prefix" as dracut uses it to move files around.
export PLYMOUTH_SYSROOT=$D
export \
- systemdutildir systemdsystemunitdir systemdsystemconfdir udevdir \
- DRACUT_ARCH DRACUT_TESTBIN DRACUT_LDD DRACUT_LDCONFIG DRACUT_INSTALL \
- DRACUT_COMPRESS_GZIP DRACUT_COMPRESS_BZIP2 DRACUT_COMPRESS_LZMA \
- PLYMOUTH_LDD PLYMOUTH_LDD_PATH PLYMOUTH_PLUGIN_PATH \
- PLYMOUTH_THEME_NAME PLYMOUTH_THEME
+ systemdutildir systemdsystemunitdir systemdsystemconfdir udevdir \
+ DRACUT_ARCH DRACUT_TESTBIN DRACUT_LDD DRACUT_LDCONFIG DRACUT_INSTALL \
+ DRACUT_COMPRESS_GZIP DRACUT_COMPRESS_BZIP2 DRACUT_COMPRESS_LZMA \
+ PLYMOUTH_LDD PLYMOUTH_LDD_PATH PLYMOUTH_PLUGIN_PATH \
+ PLYMOUTH_THEME_NAME PLYMOUTH_THEME
# List environment for debugging
echo ROOTFS-POSTINST-ENVIRONMENT
cd test
time LOGTEE_TIMEOUT_MS=590000 make \
- enable_documentation=$make_docs \
- KVERSION="$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1)" \
- DRACUT_NO_XATTR=1 \
- TEST_RUN_ID="$RUN_ID" \
- ${TESTS:+TESTS="$TESTS"} \
- -k V=1 \
- check
+ enable_documentation=$make_docs \
+ KVERSION="$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1)" \
+ DRACUT_NO_XATTR=1 \
+ TEST_RUN_ID="$RUN_ID" \
+ ${TESTS:+TESTS="$TESTS"} \
+ -k V=1 \
+ check
fi
cd test
time sudo LOGTEE_TIMEOUT_MS=300000 make \
- enable_documentation=$make_docs \
- KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
- DRACUT_NO_XATTR=1 \
- TEST_RUN_ID=$RUN_ID \
- ${TESTS:+TESTS="$TESTS"} \
- -k V=2 \
- check
+ enable_documentation=$make_docs \
+ KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
+ DRACUT_NO_XATTR=1 \
+ TEST_RUN_ID=$RUN_ID \
+ ${TESTS:+TESTS="$TESTS"} \
+ -k V=2 \
+ check
fi
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-__contains_word () {
- local word="$1"; shift
- for w in "$@"; do [[ $w = "$word" ]] && return 0; done
- return 1
+__contains_word() {
+ local word="$1"
+ shift
+ for w in "$@"; do [[ $w = "$word" ]] && return 0; done
+ return 1
}
_lsinitrd() {
- local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
- local -A OPTS=(
- [STANDALONE]='-s --size -h --help'
- [ARG]='-f --file -k --kver'
- )
+ local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD - 1]}
+ local -A OPTS=(
+ [STANDALONE]='-s --size -h --help'
+ [ARG]='-f --file -k --kver'
+ )
- # shellcheck disable=SC2086
- if __contains_word "$prev" ${OPTS[ARG]}; then
- case $prev in
- --file|-f)
- comps=$(compgen -f -- "$cur")
- compopt -o filenames
- ;;
- --kver|-k)
- comps=$(cd /lib/modules || return 1; echo [0-9]*)
- ;;
- *)
- return 0
- ;;
- esac
- # shellcheck disable=SC2207
- # shellcheck disable=SC2016
- COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
+ # shellcheck disable=SC2086
+ if __contains_word "$prev" ${OPTS[ARG]}; then
+ case $prev in
+ --file | -f)
+ comps=$(compgen -f -- "$cur")
+ compopt -o filenames
+ ;;
+ --kver | -k)
+ comps=$(
+ cd /lib/modules || return 1
+ echo [0-9]*
+ )
+ ;;
+ *)
return 0
- fi
-
- if [[ $cur = -* ]]; then
- # shellcheck disable=SC2207
- # shellcheck disable=SC2016
- COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
- return 0
- fi
+ ;;
+ esac
+ # shellcheck disable=SC2207
+ # shellcheck disable=SC2016
+ COMPREPLY=($(compgen -W '$comps' -- "$cur"))
+ return 0
+ fi
- # shellcheck disable=SC2034
- comps=$(compgen -f -- "$cur")
- compopt -o filenames
+ if [[ $cur = -* ]]; then
# shellcheck disable=SC2207
# shellcheck disable=SC2016
- COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
+ COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur"))
return 0
+ fi
+
+ # shellcheck disable=SC2034
+ comps=$(compgen -f -- "$cur")
+ compopt -o filenames
+ # shellcheck disable=SC2207
+ # shellcheck disable=SC2016
+ COMPREPLY=($(compgen -W '$comps' -- "$cur"))
+ return 0
}
complete -F _lsinitrd lsinitrd
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-usage()
-{
+usage() {
{
echo "Usage: ${0##*/} [options] [<initramfs file> [<filename> [<filename> [...] ]]]"
echo "Usage: ${0##*/} [options] -k <kernel version>"
} >&2
}
-
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
sorted=0
--long verbose \
-- "$@")
-if (( $? != 0 )); then
+if (($? != 0)); then
usage
exit 1
fi
while (($# > 0)); do
case $1 in
- -k|--kver) KERNEL_VERSION="$2"; shift;;
- -f|--file) filenames[${2#/}]=1; shift;;
- -s|--size) sorted=1;;
- -h|--help) usage; exit 0;;
- -m|--mod) modules=1;;
- -v|--verbose) verbose="--verbose";;
- --unpack) unpack=1;;
- --unpackearly) unpackearly=1;;
- --) shift;break;;
- *) usage; exit 1;;
+ -k | --kver)
+ KERNEL_VERSION="$2"
+ shift
+ ;;
+ -f | --file)
+ filenames[${2#/}]=1
+ shift
+ ;;
+ -s | --size) sorted=1 ;;
+ -h | --help)
+ usage
+ exit 0
+ ;;
+ -m | --mod) modules=1 ;;
+ -v | --verbose) verbose="--verbose" ;;
+ --unpack) unpack=1 ;;
+ --unpackearly) unpackearly=1 ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
esac
shift
done
if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
- && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]] ; then
+ && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then
image="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
- && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
+ && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then
image="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
else
image="/boot/initramfs-${KERNEL_VERSION}.img"
shift
while (($# > 0)); do
- filenames[${1#/}]=1;
+ filenames[${1#/}]=1
shift
done
done
}
-extract_files()
-{
- (( ${#filenames[@]} == 1 )) && nofileinfo=1
+extract_files() {
+ ((${#filenames[@]} == 1)) && nofileinfo=1
for f in "${!filenames[@]}"; do
[[ $nofileinfo ]] || echo "initramfs:/$f"
[[ $nofileinfo ]] || echo "========================================================================"
- $CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout "$f" 2>/dev/null
- ((ret+=$?))
+ $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --to-stdout "$f" 2> /dev/null
+ ((ret += $?))
[[ $nofileinfo ]] || echo "========================================================================"
[[ $nofileinfo ]] || echo
done
}
-list_modules()
-{
+list_modules() {
echo "dracut modules:"
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
- $(dracutlibdirs modules.txt) 2>/dev/null
- ((ret+=$?))
+ $(dracutlibdirs modules.txt) 2> /dev/null
+ ((ret += $?))
}
-list_files()
-{
+list_files() {
echo "========================================================================"
if [ "$sorted" -eq 1 ]; then
- $CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --list | sort -n -k5
+ $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list | sort -n -k5
else
- $CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --list | sort -k9
+ $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list | sort -k9
fi
- ((ret+=$?))
+ ((ret += $?))
echo "========================================================================"
}
-list_squash_content()
-{
+list_squash_content() {
SQUASH_IMG="squash-root.img"
SQUASH_TMPFILE="$TMPDIR/initrd.root.sqsh"
- $CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- \
- $SQUASH_IMG > "$SQUASH_TMPFILE" 2>/dev/null
+ $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --to-stdout -- \
+ $SQUASH_IMG > "$SQUASH_TMPFILE" 2> /dev/null
if [[ -s $SQUASH_TMPFILE ]]; then
echo "Squashed content ($SQUASH_IMG):"
echo "========================================================================"
fi
}
-unpack_files()
-{
- if (( ${#filenames[@]} > 0 )); then
+unpack_files() {
+ if ((${#filenames[@]} > 0)); then
for f in "${!filenames[@]}"; do
- $CAT "$image" 2>/dev/null | cpio -id --quiet $verbose $f
- ((ret+=$?))
+ $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose $f
+ ((ret += $?))
done
else
- $CAT "$image" 2>/dev/null | cpio -id --quiet $verbose
- ((ret+=$?))
+ $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose
+ ((ret += $?))
fi
}
read -N 2 bin < "$image"
if [ "$bin" = "MZ" ]; then
- command -v objcopy > /dev/null || { echo "Need 'objcopy' to unpack an UEFI executable."; exit 1; }
+ command -v objcopy > /dev/null || {
+ echo "Need 'objcopy' to unpack an UEFI executable."
+ exit 1
+ }
objcopy \
--dump-section .linux="$TMPDIR/vmlinuz" \
--dump-section .initrd="$TMPDIR/initrd.img" \
[ -f "$image" ] || exit 1
fi
-if (( ${#filenames[@]} <= 0 )) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]]; then
+if ((${#filenames[@]} <= 0)) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]]; then
if [ -n "$uefi" ]; then
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
if [ -f "$TMPDIR/osrel.txt" ]; then
name=$(sed -En '/^PRETTY_NAME/ s/^\w+=["'"'"']?([^"'"'"'$]*)["'"'"']?/\1/p' "$TMPDIR/osrel.txt")
id=$(sed -En '/^ID/ s/^\w+=["'"'"']?([^"'"'"'$]*)["'"'"']?/\1/p' "$TMPDIR/osrel.txt")
fi
else
echo -n "Image: $image: "
- 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
fi
echo "========================================================================"
read -N 6 bin < "$image"
case $bin in
- $'\x71\xc7'*|070701)
+ $'\x71\xc7'* | 070701)
CAT="cat --"
- is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev/null)
+ is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2> /dev/null)
# 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 [[ -n "$unpack" ]]; then
# should use --unpackearly for early CPIO
:
elif [[ -n "$unpackearly" ]]; then
unpack_files
- elif (( ${#filenames[@]} > 0 )); then
+ elif ((${#filenames[@]} > 0)); then
extract_files
else
echo "Early CPIO image"
;;
esac
-if [[ $SKIP ]] ; then
- bin="$($SKIP "$image" | { read -N 6 bin && echo "$bin" ; })"
+if [[ $SKIP ]]; then
+ bin="$($SKIP "$image" | { read -N 6 bin && echo "$bin"; })"
else
read -N 6 bin < "$image"
fi
BZh*)
CAT="bzcat --"
;;
- $'\x71\xc7'*|070701)
+ $'\x71\xc7'* | 070701)
CAT="cat --"
;;
$'\x02\x21'*)
CAT="zstd -d -c"
;;
*)
- if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
+ if echo "test" | xz | xzcat --single-stream > /dev/null 2>&1; then
CAT="xzcat --single-stream --"
else
CAT="xzcat --"
;;
esac
-skipcpio()
-{
+skipcpio() {
$SKIP "$@" | $ORIG_CAT
}
CAT=skipcpio
fi
-if (( ${#filenames[@]} > 1 )); then
+if ((${#filenames[@]} > 1)); then
TMPFILE="$TMPDIR/initrd.cpio"
- $CAT "$image" 2>/dev/null > $TMPFILE
- pre_decompress()
- {
+ $CAT "$image" 2> /dev/null > $TMPFILE
+ pre_decompress() {
cat $TMPFILE
}
CAT=pre_decompress
if [[ -n "$unpack" ]]; then
unpack_files
-elif (( ${#filenames[@]} > 0 )); then
+elif ((${#filenames[@]} > 0)); then
extract_files
else
version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
- $(dracutlibdirs 'dracut-*') 2>/dev/null)
- ((ret+=$?))
+ $(dracutlibdirs 'dracut-*') 2> /dev/null)
+ ((ret += $?))
echo "Version: $version"
echo
if [ "$modules" -eq 1 ]; then
else
echo -n "Arguments: "
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
- $(dracutlibdirs build-parameter.txt) 2>/dev/null
+ $(dracutlibdirs build-parameter.txt) 2> /dev/null
echo
list_modules
list_files
error() { echo "$@" >&2; }
-usage () {
+usage() {
[[ $1 = '-n' ]] && cmd=echo || cmd=error
$cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]"
if [[ $2 =~ $rematch ]]; then
read "$param" <<< "${BASH_REMATCH[1]}"
else
- for ((i=3; $i <= $#; i++)); do
+ for ((i = 3; $i <= $#; i++)); do
# Only read next arg if it not an arg itself.
- if [[ ${*:$i:1} = -* ]];then
- break
+ if [[ ${*:$i:1} = -* ]]; then
+ break
fi
result="$result ${@:$i:1}"
# There is no way to shift our callers args, so
# return "no of args" to indicate they should do it instead.
- done
- read "$1" <<< "$result"
+ done
+ read "$1" <<< "$result"
return $(($i - 3))
fi
}
local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
case "${DRACUT_ARCH:-$(uname -m)}" in
- s390|s390x)
+ s390 | s390x)
regex='image'
;;
ppc*)
regex='vmlinux'
;;
- i?86|x86_64)
+ i?86 | x86_64)
regex='vmlinuz'
;;
arm*)
regex='[uz]Image'
;;
- aarch64|riscv64)
+ aarch64 | riscv64)
regex='Image'
;;
- *) regex='vmlinu.'
+ *)
+ regex='vmlinu.'
;;
esac
# user mode linux
if grep -q UML /proc/cpuinfo; then
- regex='linux'
+ regex='linux'
fi
kernel_images=""
initrd_images=""
for kernel_image in $(ls $boot_dir \
- | sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
- | grep -v kdump$ ) ; do
+ | sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
+ | grep -v kdump$); do
# Note that we cannot check the RPM database here -- this
# script is itself called from within the binary kernel
[ -L "$boot_dir/$kernel_image" ] && continue
[ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
kernel_version=$(/usr/bin/get_kernel_version \
- $boot_dir/$kernel_image 2> /dev/null)
+ $boot_dir/$kernel_image 2> /dev/null)
initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
if [ "$kernel_image" != "$initrd_image" -a \
- -n "$kernel_version" -a \
- -d "/lib/modules/$kernel_version" ]; then
- kernel_images="$kernel_images $boot_dir/$kernel_image"
- initrd_images="$initrd_images $boot_dir/$initrd_image"
+ -n "$kernel_version" -a \
+ -d "/lib/modules/$kernel_version" ]; then
+ kernel_images="$kernel_images $boot_dir/$kernel_image"
+ initrd_images="$initrd_images $boot_dir/$initrd_image"
fi
done
- for kernel_image in $kernel_images;do
- kernels="$kernels ${kernel_image#*-}"
+ for kernel_image in $kernel_images; do
+ kernels="$kernels ${kernel_image#*-}"
done
- for initrd_image in $initrd_images;do
- targets="$targets $initrd_image"
+ for initrd_image in $initrd_images; do
+ targets="$targets $initrd_image"
done
host_only=1
force=1
while (($# > 0)); do
case ${1%%=*} in
- --with-usb) read_arg usbmodule "$@" || shift $?
+ --with-usb)
+ read_arg usbmodule "$@" || shift $?
basicmodules="$basicmodules ${usbmodule:-usb-storage}"
- unset usbmodule;;
- --with-avail) read_arg modname "$@" || shift $?
- basicmodules="$basicmodules $modname";;
- --with) read_arg modname "$@" || shift $?
- basicmodules="$basicmodules $modname";;
+ unset usbmodule
+ ;;
+ --with-avail)
+ read_arg modname "$@" || shift $?
+ basicmodules="$basicmodules $modname"
+ ;;
+ --with)
+ read_arg modname "$@" || shift $?
+ basicmodules="$basicmodules $modname"
+ ;;
--version)
echo "mkinitrd: dracut compatibility wrapper"
- exit 0;;
- -v|--verbose) dracut_args="${dracut_args} -v";;
- -f|--force) force=1;;
- --preload) read_arg modname "$@" || shift $?
- basicmodules="$basicmodules $modname";;
- --image-version) img_vers=yes;;
- --rootfs|-d) read_arg rootfs "$@" || shift $?
- dracut_args="${dracut_args} --filesystems $rootfs";;
- --nocompress) dracut_args="$dracut_args --no-compress";;
- --help) usage -n;;
+ exit 0
+ ;;
+ -v | --verbose) dracut_args="${dracut_args} -v" ;;
+ -f | --force) force=1 ;;
+ --preload)
+ read_arg modname "$@" || shift $?
+ basicmodules="$basicmodules $modname"
+ ;;
+ --image-version) img_vers=yes ;;
+ --rootfs | -d)
+ read_arg rootfs "$@" || shift $?
+ dracut_args="${dracut_args} --filesystems $rootfs"
+ ;;
+ --nocompress) dracut_args="$dracut_args --no-compress" ;;
+ --help) usage -n ;;
--builtin) ;;
--without*) ;;
--without-usb) ;;
--loopopts*) ;;
--looppath*) ;;
--dsdt*) ;;
- -s) ;;
- --quiet|-q) quiet=1;;
- -b) read_arg boot_dir "$@" || shift $?
- if [ ! -d $boot_dir ];then
- error "Boot directory $boot_dir does not exist"
- exit 1
- fi
- ;;
- -k) # Would be nice to get a list of images here
- read_arg kernel_images "$@" || shift $?
- for kernel_image in $kernel_images;do
- kernels="$kernels ${kernel_image#*-}"
- done
- host_only=1
- force=1
- ;;
- -i) read_arg initrd_images "$@" || shift $?
- for initrd_image in $initrd_images;do
- targets="$targets $boot_dir/$initrd_image"
- done
- ;;
- *) if [[ ! $targets ]]; then
+ -s) ;;
+ --quiet | -q) quiet=1 ;;
+ -b)
+ read_arg boot_dir "$@" || shift $?
+ if [ ! -d $boot_dir ]; then
+ error "Boot directory $boot_dir does not exist"
+ exit 1
+ fi
+ ;;
+ -k) # Would be nice to get a list of images here
+ read_arg kernel_images "$@" || shift $?
+ for kernel_image in $kernel_images; do
+ kernels="$kernels ${kernel_image#*-}"
+ done
+ host_only=1
+ force=1
+ ;;
+ -i)
+ read_arg initrd_images "$@" || shift $?
+ for initrd_image in $initrd_images; do
+ targets="$targets $boot_dir/$initrd_image"
+ done
+ ;;
+ *) if [[ ! $targets ]]; then
targets=$1
- elif [[ ! $kernels ]]; then
+ elif [[ ! $kernels ]]; then
kernels=$1
- else
+ else
usage
- fi;;
+ fi ;;
esac
shift
done
[[ $targets && $kernels ]] || (error "No kernel found in $boot_dir" && usage)
# We can have several targets/kernels, transform the list to an array
-targets=( $targets )
-[[ $kernels ]] && kernels=( $kernels )
+targets=($targets)
+[[ $kernels ]] && kernels=($kernels)
[[ $host_only == 1 ]] && dracut_args="${dracut_args} -H"
-[[ $force == 1 ]] && dracut_args="${dracut_args} -f"
+[[ $force == 1 ]] && dracut_args="${dracut_args} -f"
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
- target="${targets[$i]}-${kernels[$i]}"
+ if [[ $img_vers ]]; then
+ target="${targets[$i]}-${kernels[$i]}"
else
- target="${targets[$i]}"
+ target="${targets[$i]}"
fi
kernel="${kernels[$i]}"
# Duplicate code: No way found how to redirect output based on $quiet
- if [[ $quiet == 1 ]];then
- echo "$target|$kernel|$dracut_args|$basicmodules"
- if [[ $basicmodules ]]; then
+ if [[ $quiet == 1 ]]; then
+ echo "$target|$kernel|$dracut_args|$basicmodules"
+ if [[ $basicmodules ]]; then
dracut $dracut_args --add-drivers "$basicmodules" "$target" \
- "$kernel" &>/dev/null
- else
- dracut $dracut_args "$target" "$kernel" &>/dev/null
- fi
+ "$kernel" &> /dev/null
+ else
+ dracut $dracut_args "$target" "$kernel" &> /dev/null
+ fi
else
- if [[ $basicmodules ]]; then
+ if [[ $basicmodules ]]; then
dracut $dracut_args --add-drivers "$basicmodules" "$target" \
- "$kernel"
- else
+ "$kernel"
+ else
dracut $dracut_args "$target" "$kernel"
- fi
+ fi
fi
done
error() { echo "$@" >&2; }
-usage () {
+usage() {
[[ $1 = '-n' ]] && cmd=echo || cmd=error
$cmd "usage: ${0##*/} [options]"
if [[ $2 =~ $rematch ]]; then
read "$param" <<< "${BASH_REMATCH[1]}"
else
- for ((i=3; $i <= $#; i++)); do
+ for ((i = 3; $i <= $#; i++)); do
# Only read next arg if it not an arg itself.
- if [[ ${*:$i:1} = -* ]];then
- break
+ if [[ ${*:$i:1} = -* ]]; then
+ break
fi
result="$result ${@:$i:1}"
# There is no way to shift our callers args, so
# return "no of args" to indicate they should do it instead.
- done
- read "$1" <<< "$result"
+ done
+ read "$1" <<< "$result"
return $(($i - 3))
fi
}
local prefix=$1
[ -z "$prefix" ] && return
- mask=$(( 0xffffffff << (32 - $prefix) ))
- byte1=$(( mask >> 24 ))
- byte2=$(( mask >> 16 ))
- byte3=$(( mask >> 8 ))
- byte4=$(( mask & 0xff ))
- netmask=$(printf "%d.%d.%d.%d" $(( byte1 & 0xff )) $(( byte2 & 0xff )) $(( byte3 & 0xff )) $byte4);
+ mask=$((0xffffffff << (32 - $prefix)))
+ byte1=$((mask >> 24))
+ byte2=$((mask >> 16))
+ byte3=$((mask >> 8))
+ byte4=$((mask & 0xff))
+ netmask=$(printf "%d.%d.%d.%d" $((byte1 & 0xff)) $((byte2 & 0xff)) $((byte3 & 0xff)) $byte4)
echo $netmask
}
local root_dir=$2
local cfg
- 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
grep -q "^CONFIG_XEN=y\$" $cfg
return
local kernel_image="$1" kernel_image_gz="${dir}vmlinux-${1#*-}.gz"
echo kernel_image_gz="'$kernel_image_gz'" >&2
- if get_kernel_version "$kernel_image" 2>/dev/null; then
+ if get_kernel_version "$kernel_image" 2> /dev/null; then
return
fi
# As a last resort, try vmlinux-$version.gz, which might be around
- get_kernel_version "$kernel_image_gz" 2>/dev/null
+ get_kernel_version "$kernel_image_gz" 2> /dev/null
}
# Taken over from SUSE mkinitrd
local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
case "${DRACUT_ARCH:-$(uname -m)}" in
- s390|s390x)
+ s390 | s390x)
regex='image'
;;
- ppc|ppc64)
+ ppc | ppc64)
regex='vmlinux'
;;
- i?86|x86_64)
+ i?86 | x86_64)
regex='vmlinuz'
;;
arm*)
regex='[uz]Image'
;;
- aarch64|riscv64)
+ aarch64 | riscv64)
regex='Image'
;;
- *) regex='vmlinu.'
+ *)
+ regex='vmlinu.'
;;
esac
kernel_images=""
initrd_images=""
for kernel_image in $(ls $boot_dir \
- | sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
- | grep -v kdump$ ) ; do
+ | sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
+ | grep -v kdump$); do
# Note that we cannot check the RPM database here -- this
# script is itself called from within the binary kernel
[ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
kernel_version=$(kernel_version_from_image \
- $boot_dir/$kernel_image 2> /dev/null)
+ $boot_dir/$kernel_image 2> /dev/null)
initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
if [ "$kernel_image" != "$initrd_image" -a \
- -n "$kernel_version" -a \
- -d "/lib/modules/$kernel_version" ]; then
- kernel_images="$kernel_images $boot_dir/$kernel_image"
- initrd_images="$initrd_images $boot_dir/$initrd_image"
+ -n "$kernel_version" -a \
+ -d "/lib/modules/$kernel_version" ]; then
+ kernel_images="$kernel_images $boot_dir/$kernel_image"
+ initrd_images="$initrd_images $boot_dir/$initrd_image"
fi
done
- for kernel_image in $kernel_images;do
- kernels="$kernels ${kernel_image#*-}"
+ for kernel_image in $kernel_images; do
+ kernels="$kernels ${kernel_image#*-}"
done
- for initrd_image in $initrd_images;do
- targets="$targets $initrd_image"
+ for initrd_image in $initrd_images; do
+ targets="$targets $initrd_image"
done
}
while (($# > 0)); do
case ${1%%=*} in
- -f) read_arg feature_list "$@" || shift $?
- # Could be several features
- ;;
- -k) # Would be nice to get a list of images here
- read_arg kernel_images "$@" || shift $?
- for kernel_image in $kernel_images;do
- [ -L "/boot/$kernel_image" ] && kernel_image="$(readlink "/boot/$kernel_image")"
- kernels="$kernels ${kernel_image#*-}"
- done
- ;;
- -i) read_arg initrd_images "$@" || shift $?
- for initrd_image in $initrd_images;do
- [ -L "/boot/$initrd_image" ] && initrd_image="$(readlink "/boot/$initrd_image")"
- # Check if the initrd_image contains a path.
- # if not, then add the default boot_dir
- dname=`dirname $initrd_image`
- if [ "$dname" == "." ]; then
- targets="$targets $boot_dir/$initrd_image";
- else
- targets="$targets $initrd_image";
- fi
- done
- ;;
- -b) read_arg boot_dir "$@" || shift $?
- if [ ! -d $boot_dir ];then
- error "Boot directory $boot_dir does not exist"
- exit 1
- fi
- ;;
- -t) read_arg tmp_dir "$@" || shift $?
- dracut_args="${dracut_args} --tmpdir $tmp_dir"
- ;;
- -M) read_arg map_file "$@" || shift $?
- ;;
- -A) dracut_args="${dracut_args} --no-host-only";;
- -B) skip_update_bootloader=1;;
- -v|--verbose) dracut_args="${dracut_args} -v";;
- -L) logfile=;;
- -h|--help) usage -n;;
- -m) read_arg module_list "$@" || shift $? ;;
- -u) read_arg domu_module_list "$@" || shift $?
- echo "mkinitrd: DomU modules not yet supported" ;;
- -d) read_arg rootfs "$@" || shift $?
- dracut_args="${dracut_args} --filesystems $rootfs" ;;
- -D) read_arg dhcp_if "$@" || shift $?
- dracut_cmdline="${dracut_cmdline} ip=${dhcp_if}:dhcp"
- ;;
- -I) read_arg static_if "$@" || shift $?
- dracut_cmdline="${dracut_cmdline} ip=$(ipconfig $static_if)":
- ;;
- -a) read_arg acpi_dsdt "$@" || shift $?
- echo "Obsolete -a param, use acpi_table_dir= and acpi_override= variables in /etc/dracut.conf.d/"
- exit 1
- ;;
- -s) read_arg boot_splash "$@" || shift $?
- echo "mkinitrd: boot splash not yet supported"
- exit 1
- ;;
- -V) echo "mkinitrd: vendor scipts are no longer supported"
- exit 1;;
- --dracut)
- read_arg dracut_cmd "$@" || shift $? ;;
- --version|-R)
+ -f)
+ read_arg feature_list "$@" || shift $?
+ # Could be several features
+ ;;
+ -k) # Would be nice to get a list of images here
+ read_arg kernel_images "$@" || shift $?
+ for kernel_image in $kernel_images; do
+ [ -L "/boot/$kernel_image" ] && kernel_image="$(readlink "/boot/$kernel_image")"
+ kernels="$kernels ${kernel_image#*-}"
+ done
+ ;;
+ -i)
+ read_arg initrd_images "$@" || shift $?
+ for initrd_image in $initrd_images; do
+ [ -L "/boot/$initrd_image" ] && initrd_image="$(readlink "/boot/$initrd_image")"
+ # Check if the initrd_image contains a path.
+ # if not, then add the default boot_dir
+ dname=$(dirname $initrd_image)
+ if [ "$dname" == "." ]; then
+ targets="$targets $boot_dir/$initrd_image"
+ else
+ targets="$targets $initrd_image"
+ fi
+ done
+ ;;
+ -b)
+ read_arg boot_dir "$@" || shift $?
+ if [ ! -d $boot_dir ]; then
+ error "Boot directory $boot_dir does not exist"
+ exit 1
+ fi
+ ;;
+ -t)
+ read_arg tmp_dir "$@" || shift $?
+ dracut_args="${dracut_args} --tmpdir $tmp_dir"
+ ;;
+ -M)
+ read_arg map_file "$@" || shift $?
+ ;;
+ -A) dracut_args="${dracut_args} --no-host-only" ;;
+ -B) skip_update_bootloader=1 ;;
+ -v | --verbose) dracut_args="${dracut_args} -v" ;;
+ -L) logfile= ;;
+ -h | --help) usage -n ;;
+ -m) read_arg module_list "$@" || shift $? ;;
+ -u)
+ read_arg domu_module_list "$@" || shift $?
+ echo "mkinitrd: DomU modules not yet supported"
+ ;;
+ -d)
+ read_arg rootfs "$@" || shift $?
+ dracut_args="${dracut_args} --filesystems $rootfs"
+ ;;
+ -D)
+ read_arg dhcp_if "$@" || shift $?
+ dracut_cmdline="${dracut_cmdline} ip=${dhcp_if}:dhcp"
+ ;;
+ -I)
+ read_arg static_if "$@" || shift $?
+ dracut_cmdline="${dracut_cmdline} ip=$(ipconfig $static_if)":
+ ;;
+ -a)
+ read_arg acpi_dsdt "$@" || shift $?
+ echo "Obsolete -a param, use acpi_table_dir= and acpi_override= variables in /etc/dracut.conf.d/"
+ exit 1
+ ;;
+ -s)
+ read_arg boot_splash "$@" || shift $?
+ echo "mkinitrd: boot splash not yet supported"
+ exit 1
+ ;;
+ -V)
+ echo "mkinitrd: vendor scipts are no longer supported"
+ exit 1
+ ;;
+ --dracut)
+ read_arg dracut_cmd "$@" || shift $?
+ ;;
+ --version | -R)
echo "mkinitrd: dracut compatibility wrapper"
- exit 0;;
- --quiet|-q) quiet=1;;
- *) if [[ ! $targets ]]; then
+ exit 0
+ ;;
+ --quiet | -q) quiet=1 ;;
+ *) if [[ ! $targets ]]; then
targets=$1
- elif [[ ! $kernels ]]; then
+ elif [[ ! $kernels ]]; then
kernels=$1
- else
+ else
usage
- fi;;
+ fi ;;
esac
shift
done
[[ $targets && $kernels ]] || default_kernel_images
-if [[ ! $targets || ! $kernels ]];then
+if [[ ! $targets || ! $kernels ]]; then
error "No kernel found in $boot_dir or bad modules dir in /lib/modules"
exit 1
fi
# We can have several targets/kernels, transform the list to an array
-targets=( $targets )
-[[ $kernels ]] && kernels=( $kernels )
+targets=($targets)
+[[ $kernels ]] && kernels=($kernels)
-[[ $logfile ]] && dracut_args="${dracut_args} --logfile $logfile"
+[[ $logfile ]] && dracut_args="${dracut_args} --logfile $logfile"
dracut_args="${dracut_args} --force"
[[ $dracut_cmdline ]] && dracut_args="${dracut_args} --kernel-cmdline ${dracut_cmdline}"
[ -z "$(type -p update-bootloader)" ] && skip_update_bootloader=1
# Update defaults from /etc/sysconfig/kernel
-if [ -f /etc/sysconfig/kernel ] ; then
+if [ -f /etc/sysconfig/kernel ]; then
. /etc/sysconfig/kernel
fi
[[ $module_list ]] || module_list="${INITRD_MODULES}"
failed=""
-for ((i=0 ; $i<${#targets[@]} ; i++)); do
+for ((i = 0; $i < ${#targets[@]}; i++)); do
- if [[ $img_vers ]];then
- target="${targets[$i]}-${kernels[$i]}"
+ if [[ $img_vers ]]; then
+ target="${targets[$i]}-${kernels[$i]}"
else
- target="${targets[$i]}"
+ target="${targets[$i]}"
fi
kernel="${kernels[$i]}"
- if is_xen_kernel $kernel $rootfs ; then
- modules_all="${module_list} ${domu_module_list}"
+ if is_xen_kernel $kernel $rootfs; then
+ modules_all="${module_list} ${domu_module_list}"
else
modules_all="${module_list}"
fi
echo "Creating initrd: $target"
# Duplicate code: No way found how to redirect output based on $quiet
- if [[ $quiet == 1 ]];then
+ if [[ $quiet == 1 ]]; then
# Duplicate code: --force-drivers must not be called with empty string
# -> dracut bug workarounded ugly, because of complex whitespace
# expansion magics
- if [ -n "${modules_all}" ];then
- $dracut_cmd $dracut_args --force-drivers "${modules_all}" "$target" "$kernel" &>/dev/null
+ if [ -n "${modules_all}" ]; then
+ $dracut_cmd $dracut_args --force-drivers "${modules_all}" "$target" "$kernel" &> /dev/null
[ $? -ne 0 ] && failed="$failed $target"
else
- $dracut_cmd $dracut_args "$target" "$kernel" &>/dev/null
+ $dracut_cmd $dracut_args "$target" "$kernel" &> /dev/null
[ $? -ne 0 ] && failed="$failed $target"
fi
else
- if [ -n "${modules_all}" ];then
+ if [ -n "${modules_all}" ]; then
$dracut_cmd $dracut_args --force-drivers "${modules_all}" "$target" "$kernel"
[ $? -ne 0 ] && failed="$failed $target"
else
fi
done
-if [ "$skip_update_bootloader" ] ; then
+if [ "$skip_update_bootloader" ]; then
echo 2>&1 "Did not refresh the bootloader. You might need to refresh it manually."
else
update-bootloader --refresh
# Prefer bash as /bin/sh if it is available.
inst /bin/bash && ln -sf bash "${initdir}/bin/sh"
}
-
# Prefer dash as /bin/sh if it is available.
inst /bin/dash && ln -sf dash "${initdir}/bin/sh"
}
-
# Prefer mksh as /bin/sh if it is available.
inst /bin/mksh && ln -sf mksh "${initdir}/bin/sh"
}
-
#!/bin/bash
getSystemdVersion() {
- [ -z "$SYSTEMD_VERSION" ] && SYSTEMD_VERSION=$("$systemdutildir"/systemd --version | { read -r _ b _; echo "$b"; })
+ [ -z "$SYSTEMD_VERSION" ] && SYSTEMD_VERSION=$("$systemdutildir"/systemd --version | {
+ read -r _ b _
+ echo "$b"
+ })
# Check if the systemd version is a valid number
if ! [[ $SYSTEMD_VERSION =~ ^[0-9]+$ ]]; then
dfatal "systemd version is not a number ($SYSTEMD_VERSION)"
[[ $mount_needs ]] && return 1
if require_binaries "$systemdutildir"/systemd; then
SYSTEMD_VERSION=$(getSystemdVersion)
- (( SYSTEMD_VERSION >= 198 )) && return 0
- return 255
+ ((SYSTEMD_VERSION >= 198)) && return 0
+ return 255
fi
return 1
fi
if [[ $(getSystemdVersion) -ge 240 ]]; then
- inst_multiple -o \
- "$systemdutildir"/system-generators/systemd-debug-generator \
- "$systemdsystemunitdir"/debug-shell.service
+ inst_multiple -o \
+ "$systemdutildir"/system-generators/systemd-debug-generator \
+ "$systemdsystemunitdir"/debug-shell.service
fi
inst_multiple -o \
[[ -f $i ]] || continue
while read -r _line || [ -n "$_line" ]; do
case $_line in
- \#*)
- ;;
- \;*)
- ;;
+ \#*) ;;
+
+ \;*) ;;
+
*)
echo "$_line"
+ ;;
esac
done < "$i"
done
# install adm user/group for journald
inst_multiple nologin
- grep '^systemd-journal:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
- grep '^adm:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
+ grep '^systemd-journal:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
+ grep '^adm:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
grep '^systemd-journal:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^wheel:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^adm:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^root:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
# we don't use systemd-networkd, but the user is in systemd.conf tmpfiles snippet
- grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
+ grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
ln_r "$systemdutildir"/systemd "/init"
#!/bin/sh
-if test -e /etc/adjtime ; then
- while read line ; do
- if test "$line" = LOCAL ; then
- hwclock --systz
- fi
+if test -e /etc/adjtime; then
+ while read line; do
+ if test "$line" = LOCAL; then
+ hwclock --systz
+ fi
done < /etc/adjtime
fi
#!/bin/sh
if ! fipsmode=$(getarg fips) || [ "$fipsmode" = "0" ]; then
- rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
+ rm -f -- /etc/modprobe.d/fips.conf > /dev/null 2>&1
elif [ -z "$fipsmode" ]; then
die "FIPS mode have to be enabled by 'fips=1' not just 'fips'"
-elif getarg boot= >/dev/null; then
+elif getarg boot= > /dev/null; then
. /sbin/fips.sh
if mount_boot; then
do_fips || die "FIPS integrity test failed"
#!/bin/sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
- rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
+ rm -f -- /etc/modprobe.d/fips.conf > /dev/null 2>&1
else
. /sbin/fips.sh
fips_load_crypto || die "FIPS integrity test failed"
#!/bin/sh
if ! fipsmode=$(getarg fips) || [ "$fipsmode" = "0" ]; then
- rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
+ rm -f -- /etc/modprobe.d/fips.conf > /dev/null 2>&1
elif [ -z "$fipsmode" ]; then
die "FIPS mode have to be enabled by 'fips=1' not just 'fips'"
elif ! [ -f /tmp/fipsdone ]; then
}
fi
-mount_boot()
-{
+mount_boot() {
boot=$(getarg boot=)
if [ -n "$boot" ]; then
case "$boot" in
- LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
- boot="$(label_uuid_to_dev "$boot")"
- ;;
- /dev/*)
- ;;
- *)
- die "You have to specify boot=<boot device> as a boot option for fips=1" ;;
+ LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
+ boot="$(label_uuid_to_dev "$boot")"
+ ;;
+ /dev/*) ;;
+
+ *)
+ die "You have to specify boot=<boot device> as a boot option for fips=1"
+ ;;
esac
if ! [ -e "$boot" ]; then
- udevadm trigger --action=add >/dev/null 2>&1
+ udevadm trigger --action=add > /dev/null 2>&1
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
i=0
while ! [ -e $boot ]; do
fi
[ -e $boot ] && break
sleep 0.5
- i=$(($i+1))
+ i=$(($i + 1))
[ $i -gt 40 ] && break
done
fi
fi
}
-do_rhevh_check()
-{
+do_rhevh_check() {
KERNEL=$(uname -r)
kpath=${1}
return 0
}
-nonfatal_modprobe()
-{
- modprobe $1 2>&1 > /dev/stdout |
- while read -r line || [ -n "$line" ]; do
+nonfatal_modprobe() {
+ modprobe $1 2>&1 > /dev/stdout \
+ | while read -r line || [ -n "$line" ]; do
echo "${line#modprobe: FATAL: }" >&2
done
}
-fips_load_crypto()
-{
+fips_load_crypto() {
FIPSMODULES=$(cat /etc/fipsmodules)
fips_info "Loading and integrity checking all crypto modules"
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
for _module in $FIPSMODULES; do
if [ "$_module" != "tcrypt" ]; then
- if ! nonfatal_modprobe "${_module}" 2>/tmp/fips.modprobe_err; then
+ if ! nonfatal_modprobe "${_module}" 2> /tmp/fips.modprobe_err; then
# check if kernel provides generic algo
_found=0
while read _k _s _v || [ -n "$_k" ]; do
[ "$_v" != "$_module" ] && continue
_found=1
break
- done </proc/crypto
+ done < /proc/crypto
[ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1
fi
fi
rmmod tcrypt
}
-do_fips()
-{
+do_fips() {
local _v
local _s
local _v
> /tmp/fipsdone
- umount /boot >/dev/null 2>&1
+ umount /boot > /dev/null 2>&1
return 0
}
$systemdsystemunitdir/sysinit.target.wants/systemd-ask-password-console.path \
systemd-ask-password systemd-tty-ask-password-agent
- # Enable the systemd type service unit for systemd-ask-password.
- $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-console.service
-
- # Install systemd-ask-password plymouth units if plymouth is enabled.
- if dracut_module_included "plymouth"; then
- inst_multiple -o \
- $systemdsystemunitdir/systemd-ask-password-plymouth.path \
- $systemdsystemunitdir/systemd-ask-password-plymouth.service
-
- $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-plymouth.service
- fi
-
- # Uncomment this section if the usecase for wall module in the initramfs arises.
- # Install systemd-ask-password wall units if <wall module> is enabled.
- #if dracut_module_included "<wall module>"; then
- # inst_multiple -o \
- # $systemdsystemunitdir/systemd-ask-password-wall.path \
- # $systemdsystemunitdir/systemd-ask-password-wall.service \
- # $systemdsystemunitdir/multi-user.target.wants/systemd-ask-password-wall.path
- #
- # $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-wall.service
- #fi
+ # Enable the systemd type service unit for systemd-ask-password.
+ $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-console.service
+
+ # Install systemd-ask-password plymouth units if plymouth is enabled.
+ if dracut_module_included "plymouth"; then
+ inst_multiple -o \
+ $systemdsystemunitdir/systemd-ask-password-plymouth.path \
+ $systemdsystemunitdir/systemd-ask-password-plymouth.service
+
+ $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-plymouth.service
+ fi
+
+ # Uncomment this section if the usecase for wall module in the initramfs arises.
+ # Install systemd-ask-password wall units if <wall module> is enabled.
+ #if dracut_module_included "<wall module>"; then
+ # inst_multiple -o \
+ # $systemdsystemunitdir/systemd-ask-password-wall.path \
+ # $systemdsystemunitdir/systemd-ask-password-wall.service \
+ # $systemdsystemunitdir/multi-user.target.wants/systemd-ask-password-wall.path
+ #
+ # $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-wall.service
+ #fi
}
# Install the required file(s) and directories for the module in the initramfs.
install() {
- inst_dir /var/lib/systemd/coredump
+ inst_dir /var/lib/systemd/coredump
inst_multiple -o \
$sysctld/50-coredump.conf \
$systemdutildir/coredump.conf \
$systemdsystemunitdir/systemd-coredump \
$systemdsystemunitdir/systemd-coredump.socket \
- $systemdsystemunitdir/systemd-coredump@.service\
- $systemdsystemunitdir/sockets.target.wants/systemd-coredump.socket \
+ $systemdsystemunitdir/systemd-coredump@.service $systemdsystemunitdir/sockets.target.wants/systemd-coredump.socket \
coredumpctl
# Install the hosts local user configurations if enabled.
# Install the required file(s) for the module in the initramfs.
install() {
- # Create systemd-modules-load related directories.
- inst_dir $modulesload
- inst_dir $modulesloadconfdir
-
- # Install related files for systemd-modules-load
- inst_multiple -o \
- $systemdsystemunitdir/systemd-modules-load.service \
- $systemdutildir/systemd-modules-load
-
- # Install local user configurations if host only is enabled..
- if [[ $hostonly ]]; then
- inst_multiple -H -o \
+ # Create systemd-modules-load related directories.
+ inst_dir $modulesload
+ inst_dir $modulesloadconfdir
+
+ # Install related files for systemd-modules-load
+ inst_multiple -o \
+ $systemdsystemunitdir/systemd-modules-load.service \
+ $systemdutildir/systemd-modules-load
+
+ # Install local user configurations if host only is enabled..
+ if [[ $hostonly ]]; then
+ inst_multiple -H -o \
$systemdsystemconfdir/systemd-modules-load.service \
$systemdsystemconfdir/systemd-systemd-modules-load.d/*.conf \
${NULL}
- fi
+ fi
- # Enable the systemd type service unit for systemd-modules-load.
- $SYSTEMCTL -q --root "$initdir" enable systemd-modules-load.service
+ # Enable the systemd type service unit for systemd-modules-load.
+ $SYSTEMCTL -q --root "$initdir" enable systemd-modules-load.service
}
$systemdsystemunitdir/systemd-sysusers.service \
systemd-sysusers
- # Install the hosts local user configurations if enabled.
- if [[ $hostonly ]]; then
- inst_multiple -H -o \
+ # Install the hosts local user configurations if enabled.
+ if [[ $hostonly ]]; then
+ inst_multiple -H -o \
$sysusersconfdir/basic.conf \
$sysusersconfdir/systemd.conf \
$systemdsystemconfdir/systemd-sysusers.service \
$systemdsystemconfdir/systemd-sysusers.service.d/*.conf \
${NULL}
- fi
+ fi
- # Enable the systemd type service unit for sysusers.
- $SYSTEMCTL -q --root "$initdir" enable systemd-sysusers.service
+ # Enable the systemd type service unit for sysusers.
+ $SYSTEMCTL -q --root "$initdir" enable systemd-sysusers.service
}
CAPS_KEXEC_DISABLED=$(getarg rd.caps.disablekexec=)
info "Loading CAPS_MODULES $CAPS_MODULES"
- for i in $CAPS_MODULES;do modprobe "$i" 2>&1 >/dev/null | vinfo; done
+ for i in $CAPS_MODULES; do modprobe "$i" 2>&1 > /dev/null | vinfo; done
if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then
info "Disabling module loading."
echo "CAPS_INIT_DROP=\"$CAPS_INIT_DROP\"" > /etc/capsdrop
info "Will drop capabilities $CAPS_INIT_DROP from init."
fi
-
install() {
if ! dracut_module_included "systemd"; then
inst_hook pre-pivot 00 "$moddir/caps.sh"
- inst $(find_binary capsh 2>/dev/null) /usr/sbin/capsh
+ inst $(find_binary capsh 2> /dev/null) /usr/sbin/capsh
# capsh wants bash and we need bash also
inst /bin/bash
else
dwarning "caps: does not work with systemd in the initramfs"
fi
}
-
$systemdutildir/network/99-default.link \
networkctl ip
- #hostnamectl timedatectl
- # $systemdutildir/systemd-timesyncd \
- # $systemdutildir/systemd-timedated \
- # $systemdutildir/systemd-hostnamed \
- # $systemdutildir/systemd-resolvd \
- # $systemdutildir/systemd-resolve-host \
- # $systemdsystemunitdir/systemd-resolved.service \
- # $systemdsystemunitdir/systemd-hostnamed.service \
- # $systemdsystemunitdir/systemd-timesyncd.service \
- # $systemdsystemunitdir/systemd-timedated.service \
- # $systemdsystemunitdir/time-sync.target \
- # /etc/systemd/resolved.conf \
-
+ #hostnamectl timedatectl
+ # $systemdutildir/systemd-timesyncd \
+ # $systemdutildir/systemd-timedated \
+ # $systemdutildir/systemd-hostnamed \
+ # $systemdutildir/systemd-resolvd \
+ # $systemdutildir/systemd-resolve-host \
+ # $systemdsystemunitdir/systemd-resolved.service \
+ # $systemdsystemunitdir/systemd-hostnamed.service \
+ # $systemdsystemunitdir/systemd-timesyncd.service \
+ # $systemdsystemunitdir/systemd-timedated.service \
+ # $systemdsystemunitdir/time-sync.target \
+ # /etc/systemd/resolved.conf \
# inst_dir /var/lib/systemd/clock
- grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
+ grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
_arch=${DRACUT_ARCH:-$(uname -m)}
inst_libdir_file \
- {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
- {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
- {"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
- {"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"
# systemd-timesyncd.service
for i in \
$SYSTEMCTL -q --root "$initdir" enable "$i"
done
}
-
# Copyright 2013 Red Hat, Inc.
# Peter Jones <pjones@redhat.com>
-for x in /lib/modules/keys/* ; do
+for x in /lib/modules/keys/*; do
[ "${x}" = "/lib/modules/keys/*" ] && break
keyctl padd asymmetric "" @s < ${x}
done
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
inst_simple "${x#$dracutsysrootdir}"
done
ping netstat rpcinfo vi scp ping6 ssh \
fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck
}
-
# Do not add watchdog hooks if systemd module is included
# In that case, systemd will manage watchdog kick
if ! dracut_module_included "systemd"; then
- inst_hook cmdline 00 "$moddir/watchdog.sh"
- inst_hook cmdline 50 "$moddir/watchdog.sh"
+ inst_hook cmdline 00 "$moddir/watchdog.sh"
+ inst_hook cmdline 50 "$moddir/watchdog.sh"
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
inst_hook initqueue 00 "$moddir/watchdog.sh"
- inst_hook mount 00 "$moddir/watchdog.sh"
- inst_hook mount 50 "$moddir/watchdog.sh"
- inst_hook mount 99 "$moddir/watchdog.sh"
+ inst_hook mount 00 "$moddir/watchdog.sh"
+ inst_hook mount 50 "$moddir/watchdog.sh"
+ inst_hook mount 99 "$moddir/watchdog.sh"
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
- inst_hook cleanup 00 "$moddir/watchdog.sh"
- inst_hook cleanup 99 "$moddir/watchdog.sh"
+ inst_hook cleanup 00 "$moddir/watchdog.sh"
+ inst_hook cleanup 99 "$moddir/watchdog.sh"
fi
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
#!/bin/sh
if [ -e /dev/watchdog ]; then
- if [ ! -e /tmp/watchdog_timeout ]; then
- wdctl -s 60 /dev/watchdog >/dev/null 2>&1
- > /tmp/watchdog_timeout
- fi
- info "Triggering watchdog"
- >/dev/watchdog
+ if [ ! -e /tmp/watchdog_timeout ]; then
+ wdctl -s 60 /dev/watchdog > /dev/null 2>&1
+ > /tmp/watchdog_timeout
+ fi
+ info "Triggering watchdog"
+ > /dev/watchdog
else
- modprobe ib700wdt
- modprobe i6300esb
+ modprobe ib700wdt
+ modprobe i6300esb
fi
ln_r /usr/bin/busybox $_path
done
}
-
/^\[Socket\]/aRemoveOnStop=yes' \
"$initdir$systemdsystemunitdir/dbus.socket"
-
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
# Adjusting dependencies for initramfs in the dbus socket unit.
sed -i -e \
- '/^\[Unit\]/aDefaultDependencies=no\
+ '/^\[Unit\]/aDefaultDependencies=no\
Conflicts=shutdown.target\
Before=shutdown.target
/^\[Socket\]/aRemoveOnStop=yes' \
$systemdsystemconfdir/dbus.service \
$systemdsystemconfdir/dbus.service.d/*.conf \
${NULL}
- fi
+ fi
# We need to make sure that systemd-tmpfiles-setup.service->dbus.socket
# will not wait for local-fs.target to start if swap is encrypted,
local _module
# Add a dbus meta dependency based on the module in use.
for _module in dbus-daemon dbus-broker; do
- if dracut_module_included "$_module" ; then
+ if dracut_module_included "$_module"; then
echo "$_module"
return 0
fi
- done;
+ done
- if find_binary dbus-broker &> /dev/null ; then
+ if find_binary dbus-broker &> /dev/null; then
echo "dbus-broker"
return 0
else
}
set_font() {
- local dev=$1; local trans=''; local uni=''
+ local dev=$1
+ local trans=''
+ local uni=''
[ -z "${FONT}" ] && FONT=${DEFAULT_FONT}
[ -n "${FONT_MAP}" ] && trans="-m ${FONT_MAP}"
dev_open() {
local dev=$1
- exec 6<${dev} && \
- exec 7>>${dev}
+ exec 6< ${dev} \
+ && exec 7>> ${dev}
}
dev=/dev/${1#/dev/}
set_keymap
dev_close
-
VCONFIG_CONF="/etc/vconsole.conf"
# This is from 10redhat-i18n.
- findkeymap () {
+ findkeymap() {
local MAPS=$1
local MAPNAME=${1%.map*}
local map
- [[ ! -f $dracutsysrootdir$MAPS ]] && \
- MAPS=$(find $dracutsysrootdir${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
+ [[ ! -f $dracutsysrootdir$MAPS ]] \
+ && MAPS=$(find $dracutsysrootdir${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
for map in $MAPS; do
KEYMAPS="$KEYMAPS $map "
case $map in
- *.gz) cmd="zgrep";;
- *.bz2) cmd="bzgrep";;
- *) cmd="grep";;
+ *.gz) cmd="zgrep" ;;
+ *.bz2) cmd="bzgrep" ;;
+ *) cmd="grep" ;;
esac
for INCL in $($cmd "^include " $map | while read _ a _ || [ -n "$a" ]; do echo ${a//\"/}; done); do
done
}
-# Function gathers variables from distributed files among the tree, maps to
-# specified names and prints the result in format "new-name=value".
-#
-# $@ = list in format specified below (BNF notation)
-#
-# <list> ::= <element> | <element> " " <list>
-# <element> ::= <conf-file-name> ":" <map-list>
-# <map-list> ::= <mapping> | <mapping> "," <map-list>
-# <mapping> ::= <src-var> "-" <dst-var> | <src-var>
-#
-# We assume no whitespace are allowed between symbols.
-# <conf-file-name> is a file holding <src-var> in your system.
-# <src-var> is a variable holding value of meaning the same as <dst-var>.
-# <dst-var> is a variable which will be set up inside initramfs.
-# If <dst-var> has the same name as <src-var> we can omit <dst-var>.
-#
-# Example:
-# /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
-# <list> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
-# <element> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
-# <conf-file-name> = /etc/conf.d/keymaps
-# <map-list> = KEYMAP,extended_keymaps-EXT_KEYMAPS
-# <mapping> = KEYMAP
-# <src-var> = KEYMAP
-# <mapping> = extended_keymaps-EXT_KEYMAPS
-# <src-var> = extended_keymaps
-# <dst-var> = EXT_KEYMAPS
+ # Function gathers variables from distributed files among the tree, maps to
+ # specified names and prints the result in format "new-name=value".
+ #
+ # $@ = list in format specified below (BNF notation)
+ #
+ # <list> ::= <element> | <element> " " <list>
+ # <element> ::= <conf-file-name> ":" <map-list>
+ # <map-list> ::= <mapping> | <mapping> "," <map-list>
+ # <mapping> ::= <src-var> "-" <dst-var> | <src-var>
+ #
+ # We assume no whitespace are allowed between symbols.
+ # <conf-file-name> is a file holding <src-var> in your system.
+ # <src-var> is a variable holding value of meaning the same as <dst-var>.
+ # <dst-var> is a variable which will be set up inside initramfs.
+ # If <dst-var> has the same name as <src-var> we can omit <dst-var>.
+ #
+ # Example:
+ # /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
+ # <list> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
+ # <element> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
+ # <conf-file-name> = /etc/conf.d/keymaps
+ # <map-list> = KEYMAP,extended_keymaps-EXT_KEYMAPS
+ # <mapping> = KEYMAP
+ # <src-var> = KEYMAP
+ # <mapping> = extended_keymaps-EXT_KEYMAPS
+ # <src-var> = extended_keymaps
+ # <dst-var> = EXT_KEYMAPS
gather_vars() {
local item map value
# FIXME: double check
# shellcheck disable=SC2068
- for item in $@
- do
+ for item in $@; do
item=(${item/:/ })
- for map in ${item[1]//,/ }
- do
+ for map in ${item[1]//,/ }; do
map=(${map//-/ })
if [[ -f "$dracutsysrootdir${item[0]}" ]]; then
value=$(grep "^${map[0]}=" "$dracutsysrootdir${item[0]}")
find "${initdir}${kbddir}/" -name README\* -delete
find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
| while read line || [ -n "$line" ]; do
- inst_multiple gzip
+ inst_multiple gzip
done
find "${initdir}${kbddir}/" -name '*.bz2' -print -quit \
| while read line || [ -n "$line" ]; do
- inst_multiple bzip2
+ inst_multiple bzip2
done
}
[ -f $dracutsysrootdir$VCONFIG_CONF ] && . $dracutsysrootdir$VCONFIG_CONF
shopt -q -s nocasematch
- if [[ ${UNICODE} ]]
- then
- if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
- then
+ if [[ ${UNICODE} ]]; then
+ if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]; then
UNICODE=1
- elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
- then
+ elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]; then
UNICODE=0
else
UNICODE=''
fi
fi
- if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
- then
+ if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]; then
UNICODE=1
fi
shopt -q -u nocasematch
# determines whether non-UNICODE or UNICODE version is used
if [[ ${KEYTABLE} ]]; then
- if [[ ${UNICODE} == 1 ]]; then
- [[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
- fi
- KEYMAP=${KEYTABLE}
+ if [[ ${UNICODE} == 1 ]]; then
+ [[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
+ fi
+ KEYMAP=${KEYTABLE}
fi
# I'm not sure of the purpose of UNIKEYMAP and GRP_TOGGLE. They were in
findkeymap ${KEYMAP}
- for map in ${EXT_KEYMAPS}
- do
+ for map in ${EXT_KEYMAPS}; do
ddebug "Adding extra map: ${map}"
findkeymap ${map}
done
inst_opt_decompress ${kbddir}/consolefonts/${DEFAULT_FONT}.*
- if [[ ${FONT} ]] && [[ ${FONT} != ${DEFAULT_FONT} ]]
- then
+ if [[ ${FONT} ]] && [[ ${FONT} != ${DEFAULT_FONT} ]]; then
FONT=${FONT%.psf*}
inst_opt_decompress ${kbddir}/consolefonts/${FONT}.*
fi
- if [[ ${FONT_MAP} ]]
- then
+ if [[ ${FONT_MAP} ]]; then
FONT_MAP=${FONT_MAP%.trans}
# There are three different formats that setfont supports
inst_simple ${kbddir}/consoletrans/${FONT_MAP} \
- || inst_simple ${kbddir}/consoletrans/${FONT_MAP}.trans \
- || inst_simple ${kbddir}/consoletrans/${FONT_MAP}_to_uni.trans \
- || dwarn "Could not find FONT_MAP ${FONT_MAP}!"
+ || inst_simple ${kbddir}/consoletrans/${FONT_MAP}.trans \
+ || inst_simple ${kbddir}/consoletrans/${FONT_MAP}_to_uni.trans \
+ || dwarn "Could not find FONT_MAP ${FONT_MAP}!"
fi
- if [[ ${FONT_UNIMAP} ]]
- then
+ if [[ ${FONT_UNIMAP} ]]; then
FONT_UNIMAP=${FONT_UNIMAP%.uni}
inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
fi
kbddir=''
done
- [[ -f $dracutsysrootdir$I18N_CONF && -f $dracutsysrootdir$VCONFIG_CONF ]] || \
- [[ ! ${hostonly} || ${i18n_vars} ]] || {
+ [[ -f $dracutsysrootdir$I18N_CONF && -f $dracutsysrootdir$VCONFIG_CONF ]] \
+ || [[ ! ${hostonly} || ${i18n_vars} ]] || {
derror 'i18n_vars not set! Please set up i18n_vars in ' \
'configuration file.'
}
local _value
local _file
local _default
- _file="$1"; shift
- _key="$1"; shift
- _default="$1"; shift
+ _file="$1"
+ shift
+ _key="$1"
+ shift
+ _default="$1"
+ shift
_value="$(getarg "$@")"
[ -z "${_value}" ] && _value=$_default
if [ -n "${_value}" ]; then
unset _value
}
-inst_key_val /etc/vconsole.conf KEYMAP '' rd.vconsole.keymap KEYMAP -d KEYTABLE
-inst_key_val /etc/vconsole.conf FONT '' rd.vconsole.font FONT -d SYSFONT
-inst_key_val /etc/vconsole.conf FONT_MAP '' rd.vconsole.font.map FONT_MAP -d CONTRANS
-inst_key_val /etc/vconsole.conf FONT_UNIMAP '' rd.vconsole.font.unimap FONT_UNIMAP -d UNIMAP
-inst_key_val /etc/vconsole.conf UNICODE 1 rd.vconsole.font.unicode UNICODE vconsole.unicode
-inst_key_val /etc/vconsole.conf EXT_KEYMAP '' rd.vconsole.keymap.ext EXT_KEYMAP
+inst_key_val /etc/vconsole.conf KEYMAP '' rd.vconsole.keymap KEYMAP -d KEYTABLE
+inst_key_val /etc/vconsole.conf FONT '' rd.vconsole.font FONT -d SYSFONT
+inst_key_val /etc/vconsole.conf FONT_MAP '' rd.vconsole.font.map FONT_MAP -d CONTRANS
+inst_key_val /etc/vconsole.conf FONT_UNIMAP '' rd.vconsole.font.unimap FONT_UNIMAP -d UNIMAP
+inst_key_val /etc/vconsole.conf UNICODE 1 rd.vconsole.font.unicode UNICODE vconsole.unicode
+inst_key_val /etc/vconsole.conf EXT_KEYMAP '' rd.vconsole.keymap.ext EXT_KEYMAP
-inst_key_val /etc/locale.conf LANG '' rd.locale.LANG LANG
-inst_key_val /etc/locale.conf LC_ALL '' rd.locale.LC_ALL LC_ALL
+inst_key_val /etc/locale.conf LANG '' rd.locale.LANG LANG
+inst_key_val /etc/locale.conf LC_ALL '' rd.locale.LC_ALL LC_ALL
if [ -f /etc/locale.conf ]; then
. /etc/locale.conf
exit 1
fi
-
if ! needconvert; then
echo "Your system is already converted."
exit 0
# usage: ismounted <mountpoint>
# usage: ismounted /dev/<device>
-if command -v findmnt >/dev/null; then
+if command -v findmnt > /dev/null; then
ismounted() {
findmnt "$1" > /dev/null 2>&1
}
cleanup() {
echo "Something failed. Move back to the original state"
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \
- "$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
+ "$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
"$ROOT/usr/lib64"; do
[[ -d "${dir}.usrmove-new" ]] && rm -fr -- "${dir}.usrmove-new"
if [[ -d "${dir}.usrmove-old" ]]; then
echo "Clean up backup files."
# everything seems to work; cleanup
for dir in bin sbin lib lib64; do
- # if we get killed in the middle of "rm -rf", ensure not to leave
- # an incomplete directory, which is moved back by cleanup()
+ # if we get killed in the middle of "rm -rf", ensure not to leave
+ # an incomplete directory, which is moved back by cleanup()
[[ -d "$ROOT/usr/${dir}.usrmove-old" ]] \
&& mv "$ROOT/usr/${dir}.usrmove-old" "$ROOT/usr/${dir}.usrmove-old~"
[[ -d "$ROOT/${dir}.usrmove-old" ]] \
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
inst_script "$moddir/convertfs.sh" /usr/bin/convertfs
}
-
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh
# We already need a set netif here
netif=$interface
# problems with UDP traffic, among other things. As such,
# disallow MTUs from 576 and below by default, so that broken
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
- if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then
- if ! ip link set $netif mtu $mtu ; then
+ if [ -n "$mtu" ] && [ $mtu -gt 576 ]; then
+ if ! ip link set $netif mtu $mtu; then
ip link set $netif down
ip link set $netif mtu $mtu
linkup $netif
${lease_time:+valid_lft $lease_time} \
${preferred_lft:+preferred_lft ${preferred_lft}}
- if [ -n "$gw" ] ; then
- if [ "$mask" = "255.255.255.255" ] ; then
+ if [ -n "$gw" ]; then
+ if [ "$mask" = "255.255.255.255" ]; then
# point-to-point connection => set explicit route to gateway
echo ip route add $gw dev $netif > /tmp/net.$netif.gw
fi
echo "$gw" | {
IFS=' ' read -r main_gw other_gw
echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw
- if [ -n "$other_gw" ] ; then
+ if [ -n "$other_gw" ]; then
for g in $other_gw; do
echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw
done
if getargbool 1 rd.peerdns; then
[ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
- if [ -n "$namesrv" ] ; then
+ if [ -n "$namesrv" ]; then
for s in $namesrv; do
echo nameserver $s
done
if getargbool 1 rd.peerdns; then
[ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
- if [ -n "$namesrv" ] ; then
+ if [ -n "$namesrv" ]; then
for s in $namesrv; do
echo nameserver $s
done
# Parse the arguments into a CIDR net/mask string
if [ $mask -gt 24 ]; then
destination="$1.$2.$3.$4/$mask"
- shift; shift; shift; shift
+ shift
+ shift
+ shift
+ shift
elif [ $mask -gt 16 ]; then
destination="$1.$2.$3.0/$mask"
- shift; shift; shift
+ shift
+ shift
+ shift
elif [ $mask -gt 8 ]; then
destination="$1.$2.0.0/$mask"
- shift; shift
+ shift
+ shift
elif [ $mask -gt 0 ]; then
destination="$1.0.0.0/$mask"
shift
# Read the gateway
gateway="$1.$2.$3.$4"
- shift; shift; shift; shift
+ shift
+ shift
+ shift
+ shift
# Multicast routing on Linux
# - If you set a next-hop address for a multicast group, this breaks with Cisco switches
done
}
-
case $reason in
PREINIT)
echo "dhcp: PREINIT $netif up"
read layer2 < /sys/class/net/$netif/device/layer2
fi
if [ "$layer2" != "0" ]; then
- if command -v arping2 >/dev/null; then
- if arping2 -q -C 1 -c 2 -I $netif -0 $new_ip_address ; then
+ if command -v arping2 > /dev/null; then
+ if arping2 -q -C 1 -c 2 -I $netif -0 $new_ip_address; then
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
exit 1
fi
else
- if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; then
+ if ! arping -f -q -D -c 2 -I $netif $new_ip_address; then
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
exit 1
fi
set | while read line || [ -n "$line" ]; do
[ "${line#new_}" = "$line" ] && continue
echo "$line"
- done >/tmp/dhclient.$netif.dhcpopts
+ done > /tmp/dhclient.$netif.dhcpopts
{
echo '. /lib/net-lib.sh'
} > $hookdir/initqueue/setup_net_$netif.sh
echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
- >/tmp/net.$netif.up
+ > /tmp/net.$netif.up
if [ -e /sys/class/net/${netif}/address ]; then
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi
;;
- RENEW|REBIND)
+ RENEW | REBIND)
unset lease_time
[ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
[ -n "$new_max_life" ] && lease_time=$new_max_life
preferred_lft=$lease_time
[ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
ip -4 addr change ${new_ip_address}/${new_subnet_mask} broadcast ${new_broadcast_address} dev ${interface} \
- ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
- >/dev/null 2>&1
+ ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
+ > /dev/null 2>&1
;;
BOUND6)
set | while read line || [ -n "$line" ]; do
[ "${line#new_}" = "$line" ] && continue
echo "$line"
- done >/tmp/dhclient.$netif.dhcpopts
+ done > /tmp/dhclient.$netif.dhcpopts
{
echo '. /lib/net-lib.sh'
} > $hookdir/initqueue/setup_net_$netif.sh
echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
- >/tmp/net.$netif.up
+ > /tmp/net.$netif.up
if [ -e /sys/class/net/${netif}/address ]; then
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi
;;
- RENEW6|REBIND6)
+ RENEW6 | REBIND6)
unset lease_time
[ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
[ -n "$new_max_life" ] && lease_time=$new_max_life
preferred_lft=$lease_time
[ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface} scope global \
- ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
- >/dev/null 2>&1
+ ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
+ > /dev/null 2>&1
;;
- *) echo "dhcp: $reason";;
+ *) echo "dhcp: $reason" ;;
esac
exit 0
while [ $_COUNT -lt $_DHCPRETRY ]; do
info "Starting dhcp for interface $netif"
dhclient $arg \
- ${_timeout:+--timeout $_timeout} \
- -q \
- -1 \
- -cf /etc/dhclient.conf \
- -pf /tmp/dhclient.$netif.pid \
- -lf /tmp/dhclient.$netif.lease \
- $netif &
- wait $! 2>/dev/null
+ ${_timeout:+--timeout $_timeout} \
+ -q \
+ -1 \
+ -cf /etc/dhclient.conf \
+ -pf /tmp/dhclient.$netif.pid \
+ -lf /tmp/dhclient.$netif.lease \
+ $netif &
+ wait $! 2> /dev/null
# wait will return the return value of dhclient
retv=$?
# find the process with that pid and return error code 127. In that
# case we need to check if /tmp/dhclient.$netif.lease exists. If it
# does, it means dhclient finished executing before wait was called,
- # and it was successful (return 0). If /tmp/dhclient.$netif.lease
+ # and it was successful (return 0). If /tmp/dhclient.$netif.lease
# does not exist, then it means dhclient was killed by another thread
# or it finished execution but failed dhcp on that interface.
info "PID $pid not found but DHCP successful on $netif"
return 0
fi
- fi
+ fi
- _COUNT=$(($_COUNT+1))
+ _COUNT=$(($_COUNT + 1))
[ $_COUNT -lt $_DHCPRETRY ] && sleep 1
done
warn "dhcp for interface $netif failed"
# nuke those files since we failed; we might retry dhcp again if it's e.g.
- # `ip=dhcp,dhcp6` and we check for the PID file earlier
+ # `ip=dhcp,dhcp6` and we check for the PID file earlier
rm -f /tmp/dhclient.$netif.{pid,lease}
return 1
}
fi
# Check if DHCP also suceeded on another interface before this one.
- # We will always use the first one on which DHCP succeeded, by using
+ # We will always use the first one on which DHCP succeeded, by using
# a commom file $IFNETFILE, to synchronize between threads.
- # Consider the race condition in which multiple threads
+ # Consider the race condition in which multiple threads
# corresponding to different interfaces may try to read $IFNETFILE
# and find it does not exist; they may all end up thinking they are the
# first to succeed (hence more than one thread may end up writing to
- # $IFNETFILE). To take care of this, instead of checking if $IFNETFILE
+ # $IFNETFILE). To take care of this, instead of checking if $IFNETFILE
# exists to determine if we are the first, we create a symbolic link
- # in $IFNETFILE, pointing to the interface name ($netif), thus storing
+ # in $IFNETFILE, pointing to the interface name ($netif), thus storing
# the interface name in the link pointer.
# Creating a link will fail, if the link already exists, hence kernel
# will take care of allowing only first thread to create link, which
# Also, the link points to the interface name, which will tell us which
# interface succeeded.
- if ln -s $netif $IFNETFILE 2>/dev/null; then
+ if ln -s $netif $IFNETFILE 2> /dev/null; then
intf=$(readlink $IFNETFILE)
if [ -e /tmp/dhclient.$intf.lease ]; then
info "DHCP successful on interface $intf"
- # Kill all existing dhclient calls for other interfaces, since we
+ # Kill all existing dhclient calls for other interfaces, since we
# already got one successful interface
npid=$(cat /tmp/dhclient.$netif.pid)
pidlist=$(pgrep dhclient)
for pid in $pidlist; do
[ "$pid" -eq "$npid" ] && continue
- kill -9 $pid >/dev/null 2>&1
+ kill -9 $pid > /dev/null 2>&1
done
else
echo "ERROR! $IFNETFILE exists but /tmp/dhclient.$intf.lease does not exist!!!"
- fi
+ fi
else
info "DHCP success on $netif, and also on $intf"
exit 0
# or it is for manually bring up network ie. for kdump scp vmcore
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh
# Huh? No $1?
[ -z "$1" ] && exit 1
netif=$1
# loopback is always handled the same way
-if [ "$netif" = "lo" ] ; then
+if [ "$netif" = "lo" ]; then
ip link set lo up
ip addr add 127.0.0.1/8 dev lo
exit 0
fi
bootintf=$(readlink $IFNETFILE)
- if [ ! -z $bootintf ] && [ -e /tmp/dhclient.$bootintf.lease ]; then
+ if [ ! -z $bootintf ] && [ -e /tmp/dhclient.$bootintf.lease ]; then
info "DHCP already succeeded for $bootintf, exiting for $netif"
- return 1;
+ return 1
fi
if [ ! -e /run/NetworkManager/conf.d/10-dracut-dhclient.conf ]; then
mkdir -p /run/NetworkManager/conf.d
echo '[main]' > /run/NetworkManager/conf.d/10-dracut-dhclient.conf
- echo 'dhcp=dhclient' >>/run/NetworkManager/conf.d/10-dracut-dhclient.conf
+ echo 'dhcp=dhclient' >> /run/NetworkManager/conf.d/10-dracut-dhclient.conf
fi
chmod +x /sbin/dhcp-multi.sh
if [ ! -e /run/NetworkManager/conf.d/10-dracut-dhclient.conf ]; then
mkdir -p /run/NetworkManager/conf.d
echo '[main]' > /run/NetworkManager/conf.d/10-dracut-dhclient.conf
- echo 'dhcp=dhclient' >>/run/NetworkManager/conf.d/10-dracut-dhclient.conf
+ echo 'dhcp=dhclient' >> /run/NetworkManager/conf.d/10-dracut-dhclient.conf
fi
while [ $_COUNT -lt $_DHCPRETRY ]; do
info "Starting dhcp for interface $netif"
dhclient "$@" \
- ${_timeout:+--timeout $_timeout} \
- -q \
- -1 \
- -cf /etc/dhclient.conf \
- -pf /tmp/dhclient.$netif.pid \
- -lf /tmp/dhclient.$netif.lease \
- $netif \
+ ${_timeout:+--timeout $_timeout} \
+ -q \
+ -1 \
+ -cf /etc/dhclient.conf \
+ -pf /tmp/dhclient.$netif.pid \
+ -lf /tmp/dhclient.$netif.lease \
+ $netif \
&& return 0
- _COUNT=$(($_COUNT+1))
+ _COUNT=$(($_COUNT + 1))
[ $_COUNT -lt $_DHCPRETRY ] && sleep 1
done
warn "dhcp for interface $netif failed"
modprobe ipv6
i=0
while [ ! -d /proc/sys/net/ipv6 ]; do
- i=$(($i+1))
+ i=$(($i + 1))
[ $i -gt 10 ] && break
sleep 0.1
done
return 1
fi
- ip route get "$ip" 2>/dev/null | {
+ ip route get "$ip" 2> /dev/null | {
read a rest
if [ "$a" = "local" ]; then
warn "Not assigning $ip to interface $netif, cause it is already assigned!"
wait_for_ipv6_dad $netif
else
if [ -z "$srv" ]; then
- if command -v arping2 >/dev/null; then
- if arping2 -q -C 1 -c 2 -I $netif -0 $ip ; then
+ if command -v arping2 > /dev/null; then
+ if arping2 -q -C 1 -c 2 -I $netif -0 $ip; then
warn "Duplicate address detected for $ip for interface $netif."
return 1
fi
else
- if ! arping -f -q -D -c 2 -I $netif $ip ; then
+ if ! arping -f -q -D -c 2 -I $netif $ip; then
warn "Duplicate address detected for $ip for interface $netif."
return 1
fi
get_vid() {
case "$1" in
- vlan*)
- echo ${1#vlan}
- ;;
- *.*)
- echo ${1##*.}
- ;;
+ vlan*)
+ echo ${1#vlan}
+ ;;
+ *.*)
+ echo ${1##*.}
+ ;;
esac
}
done
fi
-
# bridge this interface?
if [ -z "$NO_BRIDGE_MASTER" ]; then
for i in /tmp/bridge.*.info; do
unset bridgeslaves
unset bridgename
. "$i"
- for ethname in $bridgeslaves ; do
+ for ethname in $bridgeslaves; do
[ "$netif" != "$ethname" ] && continue
NO_BRIDGE_MASTER=yes NO_AUTO_DHCP=yes ifup $ethname
unset bondslaves
unset bondname
. "$i"
- for slave in $bondslaves ; do
+ for slave in $bondslaves; do
[ "$netif" != "$slave" ] && continue
# already setup
[ -e /tmp/bond.$bondname.up ] && exit 0
# wait for all slaves to show up
- for slave in $bondslaves ; do
+ for slave in $bondslaves; do
# try to create the slave (maybe vlan or bridge)
NO_BOND_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
- if ! ip link show dev $slave >/dev/null 2>&1; then
+ if ! ip link show dev $slave > /dev/null 2>&1; then
# wait for the last slave to show up
exit 0
fi
done
modprobe -q -b bonding
- echo "+$bondname" > /sys/class/net/bonding_masters 2>/dev/null
+ echo "+$bondname" > /sys/class/net/bonding_masters 2> /dev/null
ip link set $bondname down
# Stolen from ifup-eth
# add the bits to setup driver parameters here
- for arg in $bondoptions ; do
- key=${arg%%=*};
- value=${arg##*=};
+ for arg in $bondoptions; do
+ key=${arg%%=*}
+ value=${arg##*=}
# %{value:0:1} is replaced with non-bash specific construct
if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then
- OLDIFS=$IFS;
- IFS=',';
+ OLDIFS=$IFS
+ IFS=','
for arp_ip in $value; do
echo +$arp_ip > /sys/class/net/${bondname}/bonding/$key
done
- IFS=$OLDIFS;
+ IFS=$OLDIFS
else
echo $value > /sys/class/net/${bondname}/bonding/$key
fi
linkup $bondname
- for slave in $bondslaves ; do
+ for slave in $bondslaves; do
cat /sys/class/net/$slave/address > /tmp/net.${bondname}.${slave}.hwaddr
ip link set $slave down
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
[ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $bondname
# add the bits to setup the needed post enslavement parameters
- for arg in $bondoptions ; do
- key=${arg%%=*};
- value=${arg##*=};
+ for arg in $bondoptions; do
+ key=${arg%%=*}
+ value=${arg##*=}
if [ "${key}" = "primary" ]; then
echo $value > /sys/class/net/${bondname}/bonding/$key
fi
unset teammaster
unset teamslaves
. "$i"
- for slave in $teamslaves ; do
+ for slave in $teamslaves; do
[ "$netif" != "$slave" ] && continue
[ -e /tmp/team.$teammaster.up ] && exit 0
# wait for all slaves to show up
- for slave in $teamslaves ; do
+ for slave in $teamslaves; do
# try to create the slave (maybe vlan or bridge)
NO_TEAM_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
- if ! ip link show dev $slave >/dev/null 2>&1; then
+ if ! ip link show dev $slave > /dev/null 2>&1; then
# wait for the last slave to show up
exit 0
fi
done
- if [ ! -e /tmp/team.$teammaster.up ] ; then
+ if [ ! -e /tmp/team.$teammaster.up ]; then
# We shall only bring up those _can_ come up
# in case of some slave is gone in active-backup mode
working_slaves=""
- for slave in $teamslaves ; do
- teamdctl ${teammaster} port present ${slave} 2>/dev/null \
+ for slave in $teamslaves; do
+ teamdctl ${teammaster} port present ${slave} 2> /dev/null \
&& continue
- ip link set dev $slave up 2>/dev/null
+ ip link set dev $slave up 2> /dev/null
if wait_for_if_up $slave; then
working_slaves="$working_slaves$slave "
fi
fi
# all synthetic interfaces done.. now check if the interface is available
-if ! ip link show dev $netif >/dev/null 2>&1; then
+if ! ip link show dev $netif > /dev/null 2>&1; then
exit 1
fi
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
if [ -n "$manualup" ]; then
- >/tmp/net.$netif.manualup
+ > /tmp/net.$netif.manualup
rm -f /tmp/net.${netif}.did-setup
else
[ -e /tmp/net.${netif}.did-setup ] && exit 0
- [ -z "$DO_VLAN" ] && \
- [ -e /sys/class/net/$netif/address ] && \
- [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
+ [ -z "$DO_VLAN" ] \
+ && [ -e /sys/class/net/$netif/address ] \
+ && [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
fi
-
# Specific configuration, spin through the kernel command line
# looking for ip= lines
for p in $(getargs ip=); do
[ "$autoconf" = "ibft" ] && continue
case "$dev" in
- ??:??:??:??:??:??) # MAC address
+ ??:??:??:??:??:??) # MAC address
_dev=$(iface_for_mac $dev)
[ -n "$_dev" ] && dev="$_dev"
;;
- ??-??-??-??-??-??) # MAC address in BOOTIF form
+ ??-??-??-??-??-??) # MAC address in BOOTIF form
_dev=$(iface_for_mac $(fix_bootif $dev))
[ -n "$_dev" ] && dev="$_dev"
;;
for autoopt in $(str_replace "$autoconf" "," " "); do
case $autoopt in
- dhcp|on|any)
- do_dhcp -4 ;;
+ dhcp | on | any)
+ do_dhcp -4
+ ;;
single-dhcp)
do_dhcp_parallel -4
- exit 0 ;;
+ exit 0
+ ;;
dhcp6)
load_ipv6
- do_dhcp -6 ;;
+ do_dhcp -6
+ ;;
auto6)
- do_ipv6auto ;;
+ do_ipv6auto
+ ;;
either6)
- do_ipv6auto || do_dhcp -6 ;;
+ do_ipv6auto || do_dhcp -6
+ ;;
link6)
- do_ipv6link ;;
+ do_ipv6link
+ ;;
*)
- do_static ;;
+ do_static
+ ;;
esac
done
ret=$?
if [ $ret -eq 0 ]; then
> /tmp/net.${netif}.up
- if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
+ if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi
fi
fi
- if command -v wicked >/dev/null && [ -z "$manualup" ]; then
+ if command -v wicked > /dev/null && [ -z "$manualup" ]; then
/sbin/netroot $netif
fi
# No ip lines, no bootdev -> default to dhcp
ip=$(getarg ip)
- if getargs 'ip=dhcp6' >/dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then
+ if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then
load_ipv6
do_dhcp -6
ret=$?
fi
- if getargs 'ip=dhcp' >/dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then
+ if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then
do_dhcp -4
ret=$?
fi
echo nameserver $s >> /tmp/net.$netif.resolv.conf
done
- if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}* 2>/dev/null)" ]; then
- > /tmp/net.${netif}.did-setup
- if [ -e /sys/class/net/${netif}/address ]; then
- > /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup
- fi
+ if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}* 2> /dev/null)" ]; then
+ > /tmp/net.${netif}.did-setup
+ if [ -e /sys/class/net/${netif}/address ]; then
+ > /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup
+ fi
fi
fi
for f in /tmp/dhclient.*.pid; do
[ -e $f ] || continue
- read PID < $f;
- kill $PID >/dev/null 2>&1
+ read PID < $f
+ kill $PID > /dev/null 2>&1
done
sleep 0.1
for f in /tmp/dhclient.*.pid; do
[ -e $f ] || continue
- read PID < $f;
- kill -9 $PID >/dev/null 2>&1
+ read PID < $f
+ kill -9 $PID > /dev/null 2>&1
done
(
. "$i"
if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \
- && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
+ && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then
mkdir -p $initdir/etc/teamd
printf -- "%s" "$TEAM_CONFIG" > "$initdir/etc/teamd/${DEVICE}.conf"
dracut_need_initqueue
}
-
return
fi
-command -v fix_bootif >/dev/null || . /lib/net-lib.sh
+command -v fix_bootif > /dev/null || . /lib/net-lib.sh
# Write udev rules
{
echo 'ACTION!="add|change|move", GOTO="net_end"'
for iface in $IFACES $RAW_IFACES; do
case "$iface" in
- ??:??:??:??:??:??) # MAC address
+ ??:??:??:??:??:??) # MAC address
cond="ATTR{address}==\"$iface\""
echo "$cond, $runcmd, GOTO=\"net_end\""
;;
- ??-??-??-??-??-??) # MAC address in BOOTIF form
+ ??-??-??-??-??-??) # MAC address in BOOTIF form
cond="ATTR{address}==\"$(fix_bootif $iface)\""
echo "$cond, $runcmd, GOTO=\"net_end\""
;;
- *) # an interface name
+ *) # an interface name
cond="ENV{INTERFACE}==\"$iface\""
echo "$cond, $runcmd, GOTO=\"net_end\""
cond="NAME==\"$iface\""
for iface in $IFACES; do
if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
- if [ -n "$netroot" ] && [ -n "$DRACUT_SYSTEMD" ]; then
+ if [ -n "$netroot" ] && [ -n "$DRACUT_SYSTEMD" ]; then
echo "systemctl is-active initrd-root-device.target || [ -f /tmp/net.${iface}.did-setup ]"
- else
+ else
echo "[ -f /tmp/net.${iface}.did-setup ]"
- fi >$hookdir/initqueue/finished/wait-$iface.sh
+ fi > $hookdir/initqueue/finished/wait-$iface.sh
fi
done
# Default: We don't know the interface to use, handle all
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
if [ "$NEEDNET" = "1" ]; then
- echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ] && exit 0; done; exit 1' >$hookdir/initqueue/finished/wait-network.sh
+ echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ] && exit 0; done; exit 1' > $hookdir/initqueue/finished/wait-network.sh
fi
fi
-# if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
+ # if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
} > /etc/udev/rules.d/90-net.rules
done
case $# in
- 0) bondname=bond0; bondslaves="eth0 eth1" ;;
- 1) bondname=$1; bondslaves="eth0 eth1" ;;
- 2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
- 3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
- 4) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;;
- *) die "bond= requires zero to four parameters" ;;
+ 0)
+ bondname=bond0
+ bondslaves="eth0 eth1"
+ ;;
+ 1)
+ bondname=$1
+ bondslaves="eth0 eth1"
+ ;;
+ 2)
+ bondname=$1
+ bondslaves=$(str_replace "$2" "," " ")
+ ;;
+ 3)
+ bondname=$1
+ bondslaves=$(str_replace "$2" "," " ")
+ bondoptions=$(str_replace "$3" "," " ")
+ ;;
+ 4)
+ bondname=$1
+ bondslaves=$(str_replace "$2" "," " ")
+ bondoptions=$(str_replace "$3" "," " ")
+ bondmtu=$4
+ ;;
+ *) die "bond= requires zero to four parameters" ;;
esac
}
v=${v#*:}
done
case $# in
- 0) bridgename=br0; bridgeslaves=$iface ;;
- 1) die "bridge= requires two parameters" ;;
- 2) bridgename=$1; bridgeslaves=$(str_replace "$2" "," " ") ;;
- *) die "bridge= requires two parameters" ;;
+ 0)
+ bridgename=br0
+ bridgeslaves=$iface
+ ;;
+ 1) die "bridge= requires two parameters" ;;
+ 2)
+ bridgename=$1
+ bridgeslaves=$(str_replace "$2" "," " ")
+ ;;
+ *) die "bridge= requires two parameters" ;;
esac
}
#!/bin/sh
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
-command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
+command -v ibft_to_cmdline > /dev/null || . /lib/net-lib.sh
if getargbool 0 rd.iscsi.ibft -d "ip=ibft"; then
- modprobe -b -q iscsi_boot_sysfs 2>/dev/null
+ modprobe -b -q iscsi_boot_sysfs 2> /dev/null
modprobe -b -q iscsi_ibft
ibft_to_cmdline
fi
# an ifname= argument for each interface used in an ip= or fcoe= argument
# check if there are any ifname parameters
-if ! getarg ifname= >/dev/null ; then
+if ! getarg ifname= > /dev/null; then
return
fi
-command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
+command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh
# Check ifname= lines
for p in $(getargs ifname=); do
# routing,dns,dhcp-options,etc.
#
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] && [ -z "$(getarg BOOTIF=)" ]; then
# No ip= argument(s) for netroot provided, defaulting to DHCP
- return;
+ return
fi
# Count ip= lines to decide whether we need bootdev= or not
-if [ -z "$NEEDBOOTDEV" ] ; then
+if [ -z "$NEEDBOOTDEV" ]; then
count=0
for p in $(getargs ip=); do
case "$p" in
ibft)
- continue;;
+ continue
+ ;;
esac
- count=$(( $count + 1 ))
+ count=$(($count + 1))
done
[ $count -gt 1 ] && NEEDBOOTDEV=1
fi
[ "$autoconf" = "ibft" ] && continue
# Empty autoconf defaults to 'dhcp'
- if [ -z "$autoconf" ] ; then
+ if [ -z "$autoconf" ]; then
warn "Empty autoconf values default to dhcp"
autoconf="dhcp"
fi
# Error checking for autoconf in combination with other values
for autoopt in $(str_replace "$autoconf" "," " "); do
case $autoopt in
- error) die "Error parsing option 'ip=$p'";;
- bootp|rarp|both) die "Sorry, ip=$autoopt is currenty unsupported";;
- none|off)
- [ -z "$ip" ] && \
- die "For argument 'ip=$p'\nValue '$autoopt' without static configuration does not make sense"
- [ -z "$mask" ] && \
- die "Sorry, automatic calculation of netmask is not yet supported"
+ error) die "Error parsing option 'ip=$p'" ;;
+ bootp | rarp | both) die "Sorry, ip=$autoopt is currenty unsupported" ;;
+ none | off)
+ [ -z "$ip" ] \
+ && die "For argument 'ip=$p'\nValue '$autoopt' without static configuration does not make sense"
+ [ -z "$mask" ] \
+ && die "Sorry, automatic calculation of netmask is not yet supported"
;;
- auto6|link6);;
- either6);;
- dhcp|dhcp6|on|any|single-dhcp) \
- [ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
- die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
- [ -n "$ip" ] && \
- die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
+ auto6 | link6) ;;
+ either6) ;;
+ dhcp | dhcp6 | on | any | single-dhcp)
+ [ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] \
+ && die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
+ [ -n "$ip" ] \
+ && die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
;;
- *) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'";;
+ *) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'" ;;
esac
done
- if [ -n "$dev" ] ; then
+ if [ -n "$dev" ]; then
# We don't like duplicate device configs
- if [ -n "$IFACES" ] ; then
- for i in $IFACES ; do
+ if [ -n "$IFACES" ]; then
+ for i in $IFACES; do
[ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'"
done
fi
fi
# Do we need to check for specific options?
- if [ -n "$NEEDDHCP" ] || [ -n "$DHCPORSERVER" ] ; then
+ if [ -n "$NEEDDHCP" ] || [ -n "$DHCPORSERVER" ]; then
# Correct device? (Empty is ok as well)
[ "$dev" = "$BOOTDEV" ] || continue
# Server-ip is there?
if str_starts "$dev" "enx" && [ ${#dev} -eq 15 ]; then
printf -- "ifname=%s:%s:%s:%s:%s:%s:%s\n" \
- "$dev" \
- "${dev:3:2}" \
- "${dev:5:2}" \
- "${dev:7:2}" \
- "${dev:9:2}" \
- "${dev:11:2}" \
- "${dev:13:2}" >> /etc/cmdline.d/80-enx.conf
+ "$dev" \
+ "${dev:3:2}" \
+ "${dev:5:2}" \
+ "${dev:7:2}" \
+ "${dev:9:2}" \
+ "${dev:11:2}" \
+ "${dev:13:2}" >> /etc/cmdline.d/80-enx.conf
fi
done
fi
# This ensures that BOOTDEV is always first in IFACES
-if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then
+if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ]; then
IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
IFACES="$BOOTDEV $IFACES"
fi
# Store BOOTDEV and IFACES for later use
[ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev
-[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
+[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
done
case $# in
- 0) teammaster=team0; teamslaves="eth0 eth1"; teamrunner="activebackup" ;;
- 1) teammaster=$1; teamslaves="eth0 eth1"; teamrunner="activebackup" ;;
- 2) teammaster=$1; teamslaves=$(str_replace "$2" "," " "); teamrunner="activebackup" ;;
- 3) teammaster=$1; teamslaves=$(str_replace "$2" "," " "); teamrunner=$3 ;;
- *) die "team= requires zero to three parameters" ;;
+ 0)
+ teammaster=team0
+ teamslaves="eth0 eth1"
+ teamrunner="activebackup"
+ ;;
+ 1)
+ teammaster=$1
+ teamslaves="eth0 eth1"
+ teamrunner="activebackup"
+ ;;
+ 2)
+ teammaster=$1
+ teamslaves=$(str_replace "$2" "," " ")
+ teamrunner="activebackup"
+ ;;
+ 3)
+ teammaster=$1
+ teamslaves=$(str_replace "$2" "," " ")
+ teamrunner=$3
+ ;;
+ *) die "team= requires zero to three parameters" ;;
esac
return 0
}
printf -- "%s" "{\"runner\": {\"name\": \"$teamrunner\"}, \"link_watch\": {\"name\": \"ethtool\"}}" > "/tmp/${teammaster}.conf"
fi
done
-
unset vlanname phydevice
case $# in
- 2) vlanname=$1; phydevice=$2 ;;
- *) die "vlan= requires two parameters" ;;
+ 2)
+ vlanname=$1
+ phydevice=$2
+ ;;
+ *) die "vlan= requires two parameters" ;;
esac
}
#!/bin/sh
-type nm_generate_connections >/dev/null 2>&1 || . /lib/nm-lib.sh
+type nm_generate_connections > /dev/null 2>&1 || . /lib/nm-lib.sh
if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then
echo rd.neednet >> /etc/cmdline.d/35-neednet.conf
#!/bin/bash
-type getcmdline >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh
-nm_generate_connections()
-{
+nm_generate_connections() {
rm -f /run/NetworkManager/system-connections/*
/usr/libexec/nm-initrd-generator -- $(getcmdline)
if getargbool 0 rd.neednet; then
for i in /usr/lib/NetworkManager/system-connections/* \
- /run/NetworkManager/system-connections/* \
- /etc/NetworkManager/system-connections/* \
- /etc/sysconfig/network-scripts/ifcfg-*; do
+ /run/NetworkManager/system-connections/* \
+ /etc/NetworkManager/system-connections/* \
+ /etc/sysconfig/network-scripts/ifcfg-*; do
[ -f "$i" ] || continue
- echo '[ -f /tmp/nm.done ]' >$hookdir/initqueue/finished/nm.sh
+ echo '[ -f /tmp/nm.done ]' > $hookdir/initqueue/finished/nm.sh
break
done
fi
#!/bin/sh
-type source_hook >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh
if [ -e /tmp/nm.done ]; then
return
fi
-[ -z "$DRACUT_SYSTEMD" ] && \
-for i in /usr/lib/NetworkManager/system-connections/* \
- /run/NetworkManager/system-connections/* \
- /etc/NetworkManager/system-connections/* \
- /etc/sysconfig/network-scripts/ifcfg-*; do
- [ -f "$i" ] || continue
- /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
- break
-done
+[ -z "$DRACUT_SYSTEMD" ] \
+ && for i in /usr/lib/NetworkManager/system-connections/* \
+ /run/NetworkManager/system-connections/* \
+ /etc/NetworkManager/system-connections/* \
+ /etc/sysconfig/network-scripts/ifcfg-*; do
+ [ -f "$i" ] || continue
+ /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
+ break
+ done
if [ -s /run/NetworkManager/initrd/hostname ]; then
cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname
fi
-for _i in /sys/class/net/*
-do
+for _i in /sys/class/net/*; do
state=/run/NetworkManager/devices/$(cat $_i/ifindex)
- grep -q connection-uuid= $state 2>/dev/null || continue
+ grep -q connection-uuid= $state 2> /dev/null || continue
ifname=${_i##*/}
- sed -n 's/root-path/new_root_path/p;s/next-server/new_next_server/p' <$state >/tmp/dhclient.$ifname.dhcpopts
+ sed -n 's/root-path/new_root_path/p;s/next-server/new_next_server/p' < $state > /tmp/dhclient.$ifname.dhcpopts
source_hook initqueue/online $ifname
/sbin/netroot $ifname
done
'/^\[Unit\]/aDefaultDependencies=no\
Conflicts=shutdown.target\
Before=shutdown.target' \
- "$initdir"$unit
+ "$initdir"$unit
done
}
#!/bin/sh
# if there are no ifname parameters, just use NAME=KERNEL
-if ! getarg ifname= >/dev/null ; then
+if ! getarg ifname= > /dev/null; then
return
fi
-command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
+command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh
{
for p in $(getargs ifname=); do
depends() {
is_qemu_virtualized && echo -n "qemu-net "
- for module in network-wicked network-manager network-legacy ; do
- if dracut_module_included "$module" ; then
- network_handler="$module"
- break
- fi
- done;
-
- if [ -z "$network_handler" ]; then
- if find_binary wicked &>/dev/null ; then
- network_handler="network-wicked"
- elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
- network_handler="network-manager"
- else
- network_handler="network-legacy"
- fi
+ for module in network-wicked network-manager network-legacy; do
+ if dracut_module_included "$module"; then
+ network_handler="$module"
+ break
fi
+ done
+
+ if [ -z "$network_handler" ]; then
+ if find_binary wicked &> /dev/null; then
+ network_handler="network-wicked"
+ elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
+ network_handler="network-manager"
+ else
+ network_handler="network-legacy"
+ fi
+ fi
echo "kernel-network-modules $network_handler"
return 0
}
echo "$1" | {
IFS=. read a b c d
test "$a" -ge 0 -a "$a" -le 255 \
- -a "$b" -ge 0 -a "$b" -le 255 \
- -a "$c" -ge 0 -a "$c" -le 255 \
- -a "$d" -ge 0 -a "$d" -le 255 \
- 2> /dev/null
+ -a "$b" -ge 0 -a "$b" -le 255 \
+ -a "$c" -ge 0 -a "$c" -le 255 \
+ -a "$d" -ge 0 -a "$d" -le 255 \
+ 2> /dev/null
} && return 0
return 1
}
}
iface_for_remote_addr() {
- set -- $(ip route get to $1 | sed 's/.*\bdev\b//p;q')
+ set -- $(ip route get to $1 | sed 's/.*\bdev\b//p;q')
echo $1
}
# get the iface name for the given identifier - either a MAC, IP, or iface name
iface_name() {
case $1 in
- ??:??:??:??:??:??|??-??-??-??-??-??) iface_for_mac $1 ;;
- *:*:*|*.*.*.*) iface_for_ip $1 ;;
+ ??:??:??:??:??:?? | ??-??-??-??-??-??) iface_for_mac $1 ;;
+ *:*:* | *.*.*.*) iface_for_ip $1 ;;
*) echo $1 ;;
esac
}
local prefix="" server="" rest=""
splitsep "$1" ":" prefix server rest
case $server in
- [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) echo "$server"; return 0 ;;
+ [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)
+ echo "$server"
+ return 0
+ ;;
esac
return 1
}
ip_is_local() {
- strstr "$(ip route get $1 2>/dev/null)" " via "
+ strstr "$(ip route get $1 2> /dev/null)" " via "
}
ifdown() {
ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf
rm -f -- /tmp/net.$netif.did-setup
- [ -z "$DO_VLAN" ] && \
- [ -e /sys/class/net/$netif/address ] && \
- rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
+ [ -z "$DO_VLAN" ] \
+ && [ -e /sys/class/net/$netif/address ] \
+ && rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
# TODO: send "offline" uevent?
}
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
local _p
[ -e /tmp/net.$netif.did-setup ] && return
- [ -z "$DO_VLAN" ] && \
- [ -e /sys/class/net/$netif/address ] && \
- [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
+ [ -z "$DO_VLAN" ] \
+ && [ -e /sys/class/net/$netif/address ] \
+ && [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
[ -z "$IFACES" ] && IFACES="$netif"
# run the scripts written by ifup
- [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
- [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+ [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
+ [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# set up resolv.conf
- [ -e /tmp/net.$netif.resolv.conf ] && \
- awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
- [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
+ [ -e /tmp/net.$netif.resolv.conf ] \
+ && awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
+ [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
# add static route
for _p in $(getargs rd.route); do
# RTNETLINK answers: Network is unreachable
# Replace the default route again after static routes to cover
# this scenario.
- [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
+ [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
# Handle STP Timeout: arping the default gateway.
# (or the root server, if a) it's local or b) there's no gateway.)
fi
if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! strstr "$dest" ":"; then
- if command -v arping2 >/dev/null; then
+ if command -v arping2 > /dev/null; then
arping2 -q -C 1 -c 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
else
arping -q -f -w 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
unset layer2
> /tmp/net.$netif.did-setup
- [ -z "$DO_VLAN" ] && \
- [ -e /sys/class/net/$netif/address ] && \
- > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
+ [ -z "$DO_VLAN" ] \
+ && [ -e /sys/class/net/$netif/address ] \
+ && > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
}
save_netinfo() {
done
# otherwise, pick a new name and use that
while :; do
- num=$(($num+1));
+ num=$(($num + 1))
[ -e /sys/class/net/$name$num ] && continue
for n in $(getargs ifname=); do
[ "$name$num" = "${n%%:*}" ] && continue 2
local dns1 dns2
[ -e ${iface}/mac ] || continue
- mac=$(read a < ${iface}/mac; echo $a)
+ mac=$(
+ read a < ${iface}/mac
+ echo $a
+ )
[ -z "$mac" ] && continue
dev=$(set_ifname ibft $mac)
[ -e /tmp/net.${dev}.has_ibft_config ] && continue
- [ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
+ [ -e ${iface}/flags ] && flags=$(
+ read a < ${iface}/flags
+ echo $a
+ )
# Skip invalid interfaces
- (( $flags & 1 )) || continue
+ (($flags & 1)) || continue
# Skip interfaces not used for booting unless using multipath
- if ! getargbool 0 rd.iscsi.mp ; then
- (( $flags & 2 )) || continue
+ if ! getargbool 0 rd.iscsi.mp; then
+ (($flags & 2)) || continue
fi
- [ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
- [ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
- [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
-
- if [ -n "$ip" ] ; then
+ [ -e ${iface}/dhcp ] && dhcp=$(
+ read a < ${iface}/dhcp
+ echo $a
+ )
+ [ -e ${iface}/origin ] && origin=$(
+ read a < ${iface}/origin
+ echo $a
+ )
+ [ -e ${iface}/ip-addr ] && ip=$(
+ read a < ${iface}/ip-addr
+ echo $a
+ )
+
+ if [ -n "$ip" ]; then
case "$ip" in
*.*.*.*)
family=ipv4
esac
fi
if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
- if [ "$family" = "ipv6" ] ; then
+ if [ "$family" = "ipv6" ]; then
echo "ip=$dev:dhcp6"
else
echo "ip=$dev:dhcp"
elif [ -e ${iface}/ip-addr ]; then
# skip not assigned ip adresses
[ "$ip" = "0.0.0.0" ] && continue
- [ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a)
+ [ -e ${iface}/gateway ] && gw=$(
+ read a < ${iface}/gateway
+ echo $a
+ )
[ "$gateway" = "0.0.0.0" ] && unset $gateway
- [ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a)
- [ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a)
- [ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a)
+ [ -e ${iface}/subnet-mask ] && mask=$(
+ read a < ${iface}/subnet-mask
+ echo $a
+ )
+ [ -e ${iface}/prefix-len ] && prefix=$(
+ read a < ${iface}/prefix-len
+ echo $a
+ )
+ [ -e ${iface}/primary-dns ] && dns1=$(
+ read a < ${iface}/primary-dns
+ echo $a
+ )
[ "$dns1" = "0.0.0.0" ] && unset $dns1
- [ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a)
+ [ -e ${iface}/secondary-dns ] && dns2=$(
+ read a < ${iface}/secondary-dns
+ echo $a
+ )
[ "$dns2" = "0.0.0.0" ] && unset $dns2
- [ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)
- if [ "$family" = "ipv6" ] ; then
- if [ -n "$ip" ] ; then
+ [ -e ${iface}/hostname ] && hostname=$(
+ read a < ${iface}/hostname
+ echo $a
+ )
+ if [ "$family" = "ipv6" ]; then
+ if [ -n "$ip" ]; then
ip="[$ip]"
[ -n "$prefix" ] || prefix=64
ip="[${ip}/${prefix}]"
mask=
fi
- if [ -n "$gw" ] ; then
+ if [ -n "$gw" ]; then
gw="[${gw}]"
fi
fi
fi
if [ -e ${iface}/vlan ]; then
- vlan=$(read a < ${iface}/vlan; echo $a)
+ vlan=$(
+ read a < ${iface}/vlan
+ echo $a
+ )
if [ "$vlan" -ne "0" ]; then
case "$vlan" in
[0-9]*)
) >> /etc/cmdline.d/40-ibft.conf
}
-parse_iscsi_root()
-{
+parse_iscsi_root() {
local v
v=${1#iscsi:}
set $v
IFS="$OLDIFS"
- iscsi_protocol=$1; shift # ignored
- iscsi_target_port=$1; shift
+ iscsi_protocol=$1
+ shift # ignored
+ iscsi_target_port=$1
+ shift
if [ -n "$iscsi_target_name" ]; then
if [ $# -eq 3 ]; then
- iscsi_iface_name=$1; shift
+ iscsi_iface_name=$1
+ shift
fi
if [ $# -eq 2 ]; then
- iscsi_netdev_name=$1; shift
+ iscsi_netdev_name=$1
+ shift
fi
- iscsi_lun=$1; shift
+ iscsi_lun=$1
+ shift
if [ $# -ne 0 ]; then
warn "Invalid parameter in iscsi: parameter!"
return 1
return 0
fi
-
if [ $# -gt 3 ] && [ -n "$1$2" ]; then
- if [ -z "$3" ] || [ "$3" -ge 0 ] 2>/dev/null ; then
- iscsi_iface_name=$1; shift
- iscsi_netdev_name=$1; shift
+ if [ -z "$3" ] || [ "$3" -ge 0 ] 2> /dev/null; then
+ iscsi_iface_name=$1
+ shift
+ iscsi_netdev_name=$1
+ shift
fi
fi
- iscsi_lun=$1; shift
+ iscsi_lun=$1
+ shift
iscsi_target_name=$(printf "%s:" "$@")
iscsi_target_name=${iscsi_target_name%:}
# handle special values for ksdevice
case "$dev" in
- bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
+ bootif | BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
link) dev="" ;; # FIXME: do something useful with this
ibft) dev="" ;; # ignore - ibft is handled elsewhere
esac
[ -n "$6" ] && dev=$6
[ -n "$7" ] && autoconf=$7
case "$8" in
- [0-9a-fA-F]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
+ [0-9a-fA-F]*:* | [0-9]*.[0-9]*.[0-9]*.[0-9]*)
dns1="$8"
[ -n "$9" ] && dns2="$9"
;;
elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
fi
- ;;
+ ;;
esac
return 0
}
unset route_mask route_gw route_dev
case $# in
- 2) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"
- return 0;;
- 3) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"; [ -n "$3" ] && route_dev="$3"
- return 0;;
- *) return 1;;
+ 2)
+ [ -n "$1" ] && route_mask="$1"
+ [ -n "$2" ] && route_gw="$2"
+ return 0
+ ;;
+ 3)
+ [ -n "$1" ] && route_mask="$1"
+ [ -n "$2" ] && route_gw="$2"
+ [ -n "$3" ] && route_dev="$3"
+ return 0
+ ;;
+ *) return 1 ;;
esac
}
esac
case $ifname_if in
- 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 "This can fail for multiple network interfaces and is discouraged!"
warn "Please use a custom name like \"netboot\" or \"bluesocket\""
local li
local timeout="$(getargs rd.net.timeout.iflink=)"
timeout=${timeout:-60}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
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
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
local li
local timeout="$(getargs rd.net.timeout.ifup=)"
timeout=${timeout:-20}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
while [ $cnt -lt $timeout ]; do
li=$(ip link show up dev $1)
if [ -n "$li" ]; then
case "$li" in
*\<UP*)
- return 0;;
+ return 0
+ ;;
*\<*,UP\>*)
- return 0;;
+ return 0
+ ;;
*\<*,UP,*\>*)
- return 0;;
+ return 0
+ ;;
esac
fi
if strstr "$li" "LOWER_UP" \
- && strstr "$li" "state UNKNOWN" \
- && ! strstr "$li" "DORMANT"; then
+ && strstr "$li" "state UNKNOWN" \
+ && ! strstr "$li" "DORMANT"; then
return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
local cnt=0
local timeout="$(getargs rd.net.timeout.route=)"
timeout=${timeout:-20}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
while [ $cnt -lt $timeout ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6dad=)"
timeout=${timeout:-50}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
while [ $cnt -lt $timeout ]; do
[ -n "$(ip -6 addr show dev "$1" scope link)" ] \
[ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \
&& return 1
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6dad=)"
timeout=${timeout:-50}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
while [ $cnt -lt $timeout ]; do
[ -n "$(ip -6 addr show dev "$1")" ] \
[ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \
&& return 1
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6auto=)"
timeout=${timeout:-40}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
while [ $cnt -lt $timeout ]; do
[ -z "$(ip -6 addr show dev "$1" tentative)" ] \
&& [ -n "$(ip -6 route list proto ra dev "$1" | grep ^default)" ] \
&& return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
linkup() {
- wait_for_if_link $1 2>/dev/null\
- && ip link set $1 up 2>/dev/null\
- && wait_for_if_up $1 2>/dev/null
+ wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
}
-type hostname >/dev/null 2>&1 || \
- hostname() {
- cat /proc/sys/kernel/hostname
-}
+type hostname > /dev/null 2>&1 \
+ || hostname() {
+ cat /proc/sys/kernel/hostname
+ }
iface_has_carrier() {
local cnt=0
[ -d "$interface" ] || return 2
local timeout="$(getargs rd.net.timeout.carrier=)"
timeout=${timeout:-10}
- timeout=$(($timeout*10))
+ timeout=$(($timeout * 10))
linkup "$1"
# double check the syscfs carrier flag
[ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
case "$_netif" in
# udev persistent interface names
- eno[0-9]|eno[0-9][0-9]|eno[0-9][0-9][0-9]*)
- ;;
- ens[0-9]|ens[0-9][0-9]|ens[0-9][0-9][0-9]*)
- ;;
- enp[0-9]s[0-9]*|enp[0-9][0-9]s[0-9]*|enp[0-9][0-9][0-9]*s[0-9]*)
- ;;
- enP*p[0-9]s[0-9]*|enP*p[0-9][0-9]s[0-9]*|enP*p[0-9][0-9][0-9]*s[0-9]*)
- ;;
- # biosdevname
- em[0-9]|em[0-9][0-9]|em[0-9][0-9][0-9]*)
- ;;
- p[0-9]p[0-9]*|p[0-9][0-9]p[0-9]*|p[0-9][0-9][0-9]*p[0-9]*)
- ;;
+ eno[0-9] | eno[0-9][0-9] | eno[0-9][0-9][0-9]*) ;;
+
+ ens[0-9] | ens[0-9][0-9] | ens[0-9][0-9][0-9]*) ;;
+
+ enp[0-9]s[0-9]* | enp[0-9][0-9]s[0-9]* | enp[0-9][0-9][0-9]*s[0-9]*) ;;
+
+ enP*p[0-9]s[0-9]* | enP*p[0-9][0-9]s[0-9]* | enP*p[0-9][0-9][0-9]*s[0-9]*) ;;
+
+ # biosdevname
+ em[0-9] | em[0-9][0-9] | em[0-9][0-9][0-9]*) ;;
+
+ p[0-9]p[0-9]* | p[0-9][0-9]p[0-9]* | p[0-9][0-9][0-9]*p[0-9]*) ;;
+
*)
return 1
+ ;;
esac
return 0
}
_name_assign_type=$(cat "/sys/class/net/$_netif/name_assign_type")
case "$_name_assign_type" in
- 2|3|4)
+ 2 | 3 | 4)
# NET_NAME_PREDICTABLE 2
# NET_NAME_USER 3
# NET_NAME_RENAMED 4
return 1
;;
- 1|*)
+ 1 | *)
# NET_NAME_ENUM 1
return 0
;;
# fallback to error prone manual name check
case "$_netif" in
- eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]*)
+ eth[0-9] | eth[0-9][0-9] | eth[0-9][0-9][0-9]*)
return 0
;;
*)
return 1
+ ;;
esac
}
_netif="$1"
_subchannels=$({
- for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
- [ -e $i ] || continue
- channel=$(readlink -f $i)
- printf -- "%s" "${channel##*/},"
- done
- })
+ for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
+ [ -e $i ] || continue
+ channel=$(readlink -f $i)
+ printf -- "%s" "${channel##*/},"
+ done
+ })
[ -n "$_subchannels" ] || return 1
printf -- "%s" ${_subchannels%,}
#!/bin/sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
-command -v setup_net >/dev/null || . /lib/net-lib.sh
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
+command -v setup_net > /dev/null || . /lib/net-lib.sh
# Huh? Empty $1?
[ -z "$1" ] && exit 1
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
case "$netif" in
- ??:??:??:??:??:??) # MAC address
+ ??:??:??:??:??:??) # MAC address
for i in /sys/class/net/*/address; do
mac=$(cat $i)
if [ "$mac" = "$netif" ]; then
netif=${i##*/}
break
fi
- done
+ done ;;
esac
# Figure out the handler for root=dhcp by recalling all netroot cmdline
# If we have a specific bootdev with no dhcpoptions or empty root-path,
# we die. Otherwise we just warn
- if [ -z "$new_root_path" ] ; then
+ if [ -z "$new_root_path" ]; then
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
warn "No dhcp root-path received for '$netif' trying other interfaces if available"
exit 1
# FIXME!
unset rootok
for f in $hookdir/cmdline/90*.sh; do
- [ -f "$f" ] && . "$f";
+ [ -f "$f" ] && . "$f"
done
else
rootok="1"
handler=${netroot%%:*}
handler=${handler%%4}
handler=$(command -v ${handler}root)
- if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
+ if [ -z "$netroot" ] || [ ! -e "$handler" ]; then
die "No handler for netroot type '$netroot'"
fi
fi
inst_binary awk
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"
}
-
#!/bin/sh
# NFS root might have reached here before /tmp/net.ifaces was written
-type is_persistent_ethernet_name >/dev/null 2>&1 || . /lib/net-lib.sh
+type is_persistent_ethernet_name > /dev/null 2>&1 || . /lib/net-lib.sh
udevadm settle --timeout=30
mkdir -m 0755 -p /tmp/ifcfg/
mkdir -m 0755 -p /tmp/ifcfg-leases/
-get_config_line_by_subchannel()
-{
+get_config_line_by_subchannel() {
local CHANNEL
local line
shift
while [ $# -gt 0 ]; do
case $1 in
- *=*) OPTIONS="$OPTIONS $1";;
+ *=*) OPTIONS="$OPTIONS $1" ;;
esac
shift
done
echo "DEVICE=\"$_netif\""
}
-for netup in /tmp/net.*.did-setup ; do
+for netup in /tmp/net.*.did-setup; do
[ -f $netup ] || continue
netif=${netup%%.did-setup}
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
fi
- if [ -n "$vlan" ] ; then
+ if [ -n "$vlan" ]; then
{
echo "TYPE=Vlan"
echo "DEVICE=\"$netif\""
} >> /tmp/ifcfg/ifcfg-$netif
fi
- if [ -n "$bond" ] ; then
+ if [ -n "$bond" ]; then
# bond interface
{
# This variable is an indicator of a bond interface for initscripts
echo "TYPE=Bond"
} >> /tmp/ifcfg/ifcfg-$netif
- for slave in $bondslaves ; do
+ for slave in $bondslaves; do
# write separate ifcfg file for the raw eth interface
(
echo "# Generated by dracut initrd"
done
fi
- if [ -n "$bridge" ] ; then
+ if [ -n "$bridge" ]; then
# bridge
{
echo "TYPE=Bridge"
echo "NAME=\"$netif\""
} >> /tmp/ifcfg/ifcfg-$netif
- for slave in $bridgeslaves ; do
+ for slave in $bridgeslaves; do
# write separate ifcfg file for the raw eth interface
(
echo "# Generated by dracut initrd"
i=1
for ns in $(getargs nameserver) $dns1 $dns2; do
echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
- i=$((i+1))
+ i=$((i + 1))
done
[ -f /tmp/net.route6."$netif" ] && cp /tmp/net.route6."$netif" /tmp/ifcfg/route6-"$netif"
{
cp /tmp/net.* /run/initramfs/
for i in /tmp/net.*.resolv.conf; do
- [ -f "$i" ] && cat "$i"
+ [ -f "$i" ] && cat "$i"
done | awk '!($0 in a) { a[$0]; print }' > /run/initramfs/state/etc/resolv.conf
[ -s /run/initramfs/state/etc/resolv.conf ] || rm -f /run/initramfs/state/etc/resolv.conf
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
fi
for _dir in $libdirs; do
- [[ -d $dracutsysrootdir$_dir ]] || continue
+ [[ -d $dracutsysrootdir$_dir ]] || continue
for _lib in $dracutsysrootdir$_dir/libcurl.so.*; do
- [[ -e $_lib ]] || continue
+ [[ -e $_lib ]] || continue
[[ $_nssckbi ]] || _nssckbi=$(grep -F --binary-files=text -z libnssckbi $_lib)
_crt=$(grep -F --binary-files=text -z .crt $_lib)
[[ $_crt ]] || continue
# If its truly NSS libnssckbi, it includes its own trust bundle,
# but if it's really p11-kit-trust.so, we need to find the dirs
# where it will look for a trust bundle and install them too.
- if ! [[ $_found ]] && [[ $_nssckbi ]] ; then
+ if ! [[ $_found ]] && [[ $_nssckbi ]]; then
_found=1
inst_libdir_file "libnssckbi.so*" || _found=
for _dir in $libdirs; do
[[ -e $dracutsysrootdir$_dir/libnssckbi.so ]] || continue
# this looks for directory-ish strings in the file
- for _p11roots in $(grep -o --binary-files=text "/[[:alpha:]][[:print:]]*" $dracutsysrootdir$_dir/libnssckbi.so) ; do
+ for _p11roots in $(grep -o --binary-files=text "/[[:alpha:]][[:print:]]*" $dracutsysrootdir$_dir/libnssckbi.so); do
# the string can be a :-separated list of dirs
- for _p11root in $(echo "$_p11roots" | tr ':' '\n') ; do
+ for _p11root in $(echo "$_p11roots" | tr ':' '\n'); do
# check if it's actually a directory (there are
# several false positives in the results)
[[ -d "$dracutsysrootdir$_p11root" ]] || continue
[[ -d "$dracutsysrootdir${_p11root}/blacklist" ]] || continue
# so now we know it's really a p11-kit trust dir;
# install everything in it
- for _p11item in $(find "$dracutsysrootdir$_p11root") ; do
- if ! inst "${_p11item#$dracutsysrootdir}" ; then
+ for _p11item in $(find "$dracutsysrootdir$_p11root"); do
+ if ! inst "${_p11item#$dracutsysrootdir}"; then
dwarn "Couldn't install '${_p11item#$dracutsysrootdir}' from p11-kit trust dir '${_p11root#$dracutsysrootdir}'; HTTPS might not work."
continue
fi
fi
[[ $_found ]] || dwarn "Couldn't find SSL CA cert bundle or libnssckbi.so; HTTPS won't work."
}
-
# Authors:
# Will Woods <wwoods@redhat.com>
-type mkuniqdir >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type mkuniqdir > /dev/null 2>&1 || . /lib/dracut-lib.sh
# fetch_url URL [OUTFILE]
# fetch the given URL to a locally-visible location.
# add_url_handler HANDLERNAME SCHEME [SCHEME...]
# associate the named handler with the named scheme(s).
add_url_handler() {
- local handler="$1"; shift
+ local handler="$1"
+ shift
local schemes="$@" scheme=""
set --
for scheme in $schemes; do
curl $curl_args --output - -- "$url" > "$outloc" || return $?
else
local outdir="$(mkuniqdir /tmp curl_fetch_url)"
- ( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
+ (
+ cd "$outdir"
+ curl $curl_args --remote-name "$url" || return $?
+ )
outloc="$outdir/$(ls -A $outdir)"
fi
if ! [ -f "$outloc" ]; then
- warn "Downloading '$url' failed!"
- return 253
+ warn "Downloading '$url' failed!"
+ return 253
fi
- if [ -z "$2" ]; then echo "$outloc" ; fi
+ if [ -z "$2" ]; then echo "$outloc"; fi
}
add_url_handler curl_fetch_url http https ftp tftp
curl $curl_args --output - -- "$url" > "$torrent_outloc" || return $?
else
local outdir="$(mkuniqdir /tmp torrent_fetch_url)"
- ( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
+ (
+ cd "$outdir"
+ curl $curl_args --remote-name "$url" || return $?
+ )
torrent_outloc="$outdir/$(ls -A $outdir)"
outloc=${torrent_outloc%.*}
fi
warn "Torrent download of '$url' failed!"
return 253
fi
- if [ -z "$2" ]; then echo "$outloc" ; fi
+ if [ -z "$2" ]; then echo "$outloc"; fi
}
-command -v ctorrent >/dev/null \
+command -v ctorrent > /dev/null \
&& add_url_handler ctorrent_fetch_url torrent
### NFS ##############################################################
cp -f -- "$mntdir/$filename" "$outloc" || return $?
fi
[ -f "$outloc" ] || return 253
- if [ -z "$2" ]; then echo "$outloc" ; fi
+ if [ -z "$2" ]; then echo "$outloc"; fi
}
-command -v nfs_to_var >/dev/null && add_url_handler nfs_fetch_url nfs nfs4
+command -v nfs_to_var > /dev/null && add_url_handler nfs_fetch_url nfs nfs4
if [[ $hostonly ]]; then
for i in /sys/bus/{pci/devices,platform/devices,virtio/devices,soc/devices/soc?}/*/modalias; do
[[ -e $i ]] || continue
- [[ -n $(<"$i") ]] || continue
- if hostonly="" dracut_instmods --silent -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" $(<"$i"); then
- if strstr "$(modinfo -F filename $(<"$i") 2>/dev/null)" radeon.ko; then
+ [[ -n $(< "$i") ]] || continue
+ if hostonly="" dracut_instmods --silent -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" $(< "$i"); then
+ if strstr "$(modinfo -F filename $(< "$i") 2> /dev/null)" radeon.ko; then
hostonly='' instmods amdkfd
fi
fi
dwarn "${line}"
else
derror "${line}"
- (( $_ret == 0 )) && _ret=1
+ (($_ret == 0)) && _ret=1
fi
done
fi
return ${_ret}
}
- find_binary splash_geninitramfs >/dev/null || return 1
+ find_binary splash_geninitramfs > /dev/null || return 1
_opts=''
if [[ ${DRACUT_GENSPLASH_THEME} ]]; then
dinfo "Installing Gentoo Splash (using the ${_splash_theme} theme)"
- pushd "${initdir}" >/dev/null
+ pushd "${initdir}" > /dev/null
mv dev dev.old
call_splash_geninitramfs "${initdir}" ${_opts} ${_splash_theme} || {
derror "Could not build splash"
}
rm -rf dev
mv dev.old dev
- popd >/dev/null
+ popd > /dev/null
inst_multiple chvt
inst /usr/share/splashutils/initrd.splash /lib/gensplash-lib.sh
pkglib_dir() {
local _dirs="/usr/lib/plymouth /usr/libexec/plymouth/"
- if find_binary dpkg-architecture &>/dev/null; then
+ if find_binary dpkg-architecture &> /dev/null; then
_dirs+=" /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/plymouth"
fi
for _dir in $_dirs; do
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
fi
}
-
#!/bin/sh
-plymouth --hide-splash 2>/dev/null || :
+plymouth --hide-splash 2> /dev/null || :
#!/bin/sh
-if type plymouth >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
+if type plymouth > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
plymouth --newroot=$NEWROOT
fi
if [[ $hostonly ]]; then
inst_multiple \
"/usr/share/plymouth/themes/details/details.plymouth" \
- "/usr/share/plymouth/themes/text/text.plymouth" \
+ "/usr/share/plymouth/themes/text/text.plymouth"
if [[ -d $dracutsysrootdir/usr/share/plymouth/themes/${PLYMOUTH_THEME} ]]; then
- for x in "/usr/share/plymouth/themes/${PLYMOUTH_THEME}"/* ; do
+ for x in "/usr/share/plymouth/themes/${PLYMOUTH_THEME}"/*; do
[[ -f "$dracutsysrootdir$x" ]] || break
inst $x
done
if [[ -L $dracutsysrootdir/usr/share/plymouth/themes/default.plymouth ]]; then
inst /usr/share/plymouth/themes/default.plymouth
# Install plugin for this theme
- PLYMOUTH_PLUGIN=$(grep "^ModuleName=" "$dracutsysrootdir"/usr/share/plymouth/themes/default.plymouth | while read a b c || [ -n "$b" ]; do echo $b; done;)
+ PLYMOUTH_PLUGIN=$(grep "^ModuleName=" "$dracutsysrootdir"/usr/share/plymouth/themes/default.plymouth | while read a b c || [ -n "$b" ]; do echo $b; done)
inst_libdir_file "plymouth/${PLYMOUTH_PLUGIN}.so"
fi
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
THEME_DIR=$(dirname "${x#$dracutsysrootdir}")
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
inst_multiple "${x#$dracutsysrootdir}"
done
(
- cd ${initdir}/usr/share/plymouth/themes;
- ln -s text/text.plymouth default.plymouth 2>&1;
+ cd ${initdir}/usr/share/plymouth/themes
+ ln -s text/text.plymouth default.plymouth 2>&1
)
fi
#!/bin/sh
-if type plymouthd >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
+if type plymouthd > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -d -n rd_NO_PLYMOUTH; then
# first trigger graphics subsystem
- udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
+ udevadm trigger --action=add --attr-match=class=0x030000 > /dev/null 2>&1
# first trigger graphics and tty subsystem
udevadm trigger --action=add \
--subsystem-match=graphics \
--subsystem-match=drm \
--subsystem-match=tty \
--subsystem-match=acpi \
- >/dev/null 2>&1
+ > /dev/null 2>&1
udevadm settle --timeout=180 2>&1 | vinfo
#!/bin/bash
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
-function cms_write_config()
-{
+function cms_write_config() {
. /tmp/cms.conf
SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"
OLDIFS=$IFS
IFS=$OLDIFS
devbusid=${subch_array[1]}
if [ "$NETTYPE" = "ctc" ]; then
- driver="ctcm"
+ driver="ctcm"
else
- driver=$NETTYPE
+ driver=$NETTYPE
fi
DEVICE=$(cd /sys/devices/${driver}/$devbusid/net/ && set -- * && [ "$1" != "*" ] && echo $1)
strglobin "$IPADDR" '*:*:*' && ipv6=1
-# to please NetworkManager on startup in loader before loader reconfigures net
+ # to please NetworkManager on startup in loader before loader reconfigures net
cat > /etc/sysconfig/network << EOF
HOSTNAME=$HOSTNAME
EOF
echo "$HOSTNAME" > /etc/hostname
if [ "$ipv6" ]; then
- echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
+ echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
else
- echo "NETWORKING=yes" >> /etc/sysconfig/network
+ echo "NETWORKING=yes" >> /etc/sysconfig/network
fi
cat > $IFCFGFILE << EOF
SUBCHANNELS=$SUBCHANNELS
EOF
if [ "$ipv6" ]; then
- cat >> $IFCFGFILE << EOF
+ cat >> $IFCFGFILE << EOF
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=$IPADDR/$NETMASK
IPV6_DEFAULTGW=$GATEWAY
EOF
else
- cat >> $IFCFGFILE << EOF
+ cat >> $IFCFGFILE << EOF
IPADDR=$IPADDR
NETMASK=$NETMASK
BROADCAST=$BROADCAST
EOF
fi
if [ "$ipv6" ]; then
- DNS1=$(set -- ${DNS/,/ }; echo $1)
- DNS2=$(set -- ${DNS/,/ }; echo $2)
+ DNS1=$(
+ set -- ${DNS/,/ }
+ echo $1
+ )
+ DNS2=$(
+ set -- ${DNS/,/ }
+ echo $2
+ )
else
- DNS1=$(set -- ${DNS/:/ }; echo $1)
- DNS2=$(set -- ${DNS/:/ }; echo $2)
+ DNS1=$(
+ set -- ${DNS/:/ }
+ echo $1
+ )
+ DNS2=$(
+ set -- ${DNS/:/ }
+ echo $2
+ )
fi
-# real DNS config for NetworkManager to generate /etc/resolv.conf
+ # real DNS config for NetworkManager to generate /etc/resolv.conf
[ "$DNS1" != "" ] && echo "DNS1=$DNS1" >> $IFCFGFILE
[ "$DNS2" != "" ] && echo "DNS2=$DNS2" >> $IFCFGFILE
-# just to please loader's readNetInfo && writeEnabledNetInfo
-# which eats DNS1,DNS2,... and generates it themselves based on DNS
+ # just to please loader's readNetInfo && writeEnabledNetInfo
+ # which eats DNS1,DNS2,... and generates it themselves based on DNS
if [ "$ipv6" ]; then
- [ "$DNS" != "" ] && echo "DNS=\"$DNS\"" >> $IFCFGFILE
+ [ "$DNS" != "" ] && echo "DNS=\"$DNS\"" >> $IFCFGFILE
else
- [ "$DNS" != "" ] && echo "DNS=\"${DNS/:/,}\"" >> $IFCFGFILE
+ [ "$DNS" != "" ] && echo "DNS=\"${DNS/:/,}\"" >> $IFCFGFILE
fi
-# colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf
+ # colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf
[ "$SEARCHDNS" != "" ] && echo "DOMAIN=\"$SEARCHDNS\"" >> $IFCFGFILE
[ "$NETTYPE" != "" ] && echo "NETTYPE=$NETTYPE" >> $IFCFGFILE
[ "$PEERID" != "" ] && echo "PEERID=$PEERID" >> $IFCFGFILE
[ "$MACADDR" != "" ] && echo "MACADDR=$MACADDR" >> $IFCFGFILE
optstr=""
for option in LAYER2 PORTNO; do
- [ -z "${!option}" ] && continue
- [ -n "$optstr" ] && optstr=${optstr}" "
- optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
+ [ -z "${!option}" ] && continue
+ [ -n "$optstr" ] && optstr=${optstr}" "
+ optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
done
-# write single quotes since network.py removes double quotes but we need quotes
+ # write single quotes since network.py removes double quotes but we need quotes
echo "OPTIONS='$optstr'" >> $IFCFGFILE
unset option
unset optstr
#!/bin/bash
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
DEVICE=$1
fi
if [ "$ipv6" ]; then
- DNS1=$(set -- ${DNS/,/ }; echo $1)
- DNS2=$(set -- ${DNS/,/ }; echo $2)
+ DNS1=$(
+ set -- ${DNS/,/ }
+ echo $1
+ )
+ DNS2=$(
+ set -- ${DNS/,/ }
+ echo $2
+ )
else
- DNS1=$(set -- ${DNS/:/ }; echo $1)
- DNS2=$(set -- ${DNS/:/ }; echo $2)
+ DNS1=$(
+ set -- ${DNS/:/ }
+ echo $1
+ )
+ DNS2=$(
+ set -- ${DNS/:/ }
+ echo $2
+ )
fi
{
echo "ip=$IPADDR::$GATEWAY:$NETMASK:$HOSTNAME:$DEVICE:none:$MTU:$MACADDR"
for i in $DNS1 $DNS2; do
- echo "nameserver=$i"
+ echo "nameserver=$i"
done
} > /etc/cmdline.d/80-cms.conf
echo "$IFACES" >> /tmp/net.ifaces
if [ -x /usr/libexec/nm-initrd-generator ]; then
- type nm_generate_connections >/dev/null 2>&1 || . /lib/nm-lib.sh
+ type nm_generate_connections > /dev/null 2>&1 || . /lib/nm-lib.sh
nm_generate_connections
else
exec ifup "$DEVICE"
#!/bin/bash
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
-function sysecho () {
+function sysecho() {
file="$1"
shift
local i=1
- while [ $i -le 10 ] ; do
+ while [ $i -le 10 ]; do
if [ ! -f "$file" ]; then
sleep 1
- i=$((i+1))
+ i=$((i + 1))
else
break
fi
return 1
fi
local i=1
- while [ $i -le 60 ] ; do
+ while [ $i -le 60 ]; do
local status
read status < $dasd_status
case $status in
- online|unformatted)
- return 0 ;;
+ online | unformatted)
+ return 0
+ ;;
*)
sleep 0.1
- i=$((i+1)) ;;
+ i=$((i + 1))
+ ;;
esac
done
return 1
}
function dasd_settle_all() {
- for dasdccw in $(while read line || [ -n "$line" ]; do echo "${line%%(*}"; done < /proc/dasd/devices) ; do
- if ! dasd_settle $dasdccw ; then
+ for dasdccw in $(while read line || [ -n "$line" ]; do echo "${line%%(*}"; done < /proc/dasd/devices); do
+ if ! dasd_settle $dasdccw; then
echo $"Could not access DASD $dasdccw in time"
return 1
fi
}
# prints a canonocalized device bus ID for a given devno of any format
-function canonicalize_devno()
-{
+function canonicalize_devno() {
case ${#1} in
3) echo "0.0.0${1}" ;;
4) echo "0.0.${1}" ;;
}
# read file from CMS and write it to /tmp
-function readcmsfile() # $1=dasdport $2=filename
-{
+function readcmsfile() { # $1=dasdport $2=filename
local dev
local numcpus
local devname
local ret=0
if [ $# -ne 2 ]; then return; fi
# precondition: udevd created dasda block device node
- if ! dasd_cio_free -d $1 ; then
+ if ! dasd_cio_free -d $1; then
echo $"DASD $1 could not be cleared from device blacklist"
return 1
fi
numcpus=$(
while read line || [ -n "$line" ]; do
if strstr "$line" "# processors"; then
- echo ${line##*:};
- break;
- fi;
+ echo ${line##*:}
+ break
+ fi
done < /proc/cpuinfo
)
return 1
fi
udevadm settle
- if ! dasd_settle $dev ; then
+ if ! dasd_settle $dev; then
echo $"Could not access DASD $dev in time"
return 1
fi
udevadm settle
- devname=$(cd /sys/bus/ccw/devices/$dev/block; set -- *; [ -b /dev/$1 ] && echo $1)
+ devname=$(
+ cd /sys/bus/ccw/devices/$dev/block
+ set -- *
+ [ -b /dev/$1 ] && echo $1
+ )
devname=${devname:-dasda}
[[ -d /mnt ]] || mkdir -p /mnt
udevadm settle
# unbind all dasds to unload the dasd modules for a clean start
- ( cd /sys/bus/ccw/drivers/dasd-eckd; for i in *.*; do echo $i > unbind;done)
+ (
+ cd /sys/bus/ccw/drivers/dasd-eckd
+ for i in *.*; do echo $i > unbind; done
+ )
udevadm settle
modprobe -r dasd_eckd_mod
udevadm settle
return $ret
}
-processcmsfile()
-{
+processcmsfile() {
source /tmp/cms.conf
SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"
for i in ${!FCP_*}; do
echo "${!i}" | while read port rest || [ -n "$port" ]; do
case $port in
- *.*.*)
- ;;
+ *.*.*) ;;
+
*.*)
port="0.$port"
;;
#!/bin/bash
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
do_merge() {
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 1/' \
umount -R /sysroot
for tag in $(getargs rd.lvm.mergetags); do
- lvm vgs --noheadings -o vg_name | \
- while read -r vg || [[ -n $vg ]]; do
+ lvm vgs --noheadings -o vg_name \
+ | while read -r vg || [[ -n $vg ]]; do
unset LVS
declare -a LVS
lvs=$(lvm lvs --noheadings -o lv_name "$vg")
tags=$(trim "$(lvm lvs --noheadings -o lv_tags "$vg/$lv")")
strstr ",${tags}," ",${tag}," || continue
- if ! lvm lvs --noheadings -o lv_name "${vg}/${lv}_dracutsnap" &>/dev/null; then
+ if ! lvm lvs --noheadings -o lv_name "${vg}/${lv}_dracutsnap" &> /dev/null; then
info "Creating backup ${lv}_dracutsnap of ${vg}/${lv}"
lvm lvcreate -pr -s "${vg}/${lv}" --name "${lv}_dracutsnap"
fi
systemctl --no-block stop sysroot.mount
udevadm settle
- for ((i=0; i < 100; i++)); do
+ for ((i = 0; i < 100; i++)); do
lvm vgchange -an "$vg" && break
sleep 0.5
done
systemctl --no-block reset-failed sysroot.mount
systemctl --no-block start sysroot.mount
- for ((i=0; i < 100; i++)); do
+ for ((i = 0; i < 100; i++)); do
[[ -d /sysroot/dev ]] && break
sleep 0.5
systemctl --no-block start sysroot.mount
if getarg rd.lvm.mergetags; then
do_merge
fi
-
# called by dracut
check() {
-# do not add this module by default
+ # do not add this module by default
local arch=${DRACUT_ARCH:-$(uname -m)}
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
return 0
cmdline() {
local cio_accept
- if [ -e /boot/zipl/active_devices.txt ] ; then
- while read dev etc ; do
- [ "$dev" = "#" -o "$dev" = "" ] && continue;
- if [ -z "$cio_accept" ] ; then
+ if [ -e /boot/zipl/active_devices.txt ]; then
+ while read dev etc; do
+ [ "$dev" = "#" -o "$dev" = "" ] && continue
+ if [ -z "$cio_accept" ]; then
cio_accept="$dev"
else
cio_accept="${cio_accept},${dev}"
fi
done < /boot/zipl/active_devices.txt
fi
- if [ -n "$cio_accept" ] ; then
- echo "rd.cio_accept=${cio_accept}"
+ if [ -n "$cio_accept" ]; then
+ echo "rd.cio_accept=${cio_accept}"
fi
}
# called by dracut
install() {
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _cio_accept=$(cmdline)
[[ $_cio_accept ]] && printf "%s\n" "$_cio_accept" >> "${initdir}/etc/cmdline.d/01cio_accept.conf"
fi
CIO_IGNORE=$(getarg cio_ignore)
CIO_ACCEPT=$(getarg rd.cio_accept)
-if [ -z $CIO_IGNORE ] ; then
+if [ -z $CIO_IGNORE ]; then
info "cio_ignored disabled on commandline"
return
fi
-if [ -n "$CIO_ACCEPT" ] ; then
+if [ -n "$CIO_ACCEPT" ]; then
OLDIFS="$IFS"
IFS=,
set -- $CIO_ACCEPT
- while (($# > 0)) ; do
+ while (($# > 0)); do
info "Enabling device $1"
cio_ignore --remove $1
shift
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
btrfs_check_complete() {
local _rootinfo _dev
_dev="${1:-/dev/root}"
[ -e "$_dev" ] || return 0
- _rootinfo=$(udevadm info --query=env "--name=$_dev" 2>/dev/null)
+ _rootinfo=$(udevadm info --query=env "--name=$_dev" 2> /dev/null)
if strstr "$_rootinfo" "ID_FS_TYPE=btrfs"; then
info "Checking, if btrfs device complete"
- btrfs device ready "$_dev" >/dev/null 2>&1
+ btrfs device ready "$_dev" > /dev/null 2>&1
return $?
fi
return 0
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
btrfs_check_complete() {
local _rootinfo _dev
_dev="${1:-/dev/root}"
[ -e "$_dev" ] || return 0
- _rootinfo=$(udevadm info --query=env "--name=$_dev" 2>/dev/null)
+ _rootinfo=$(udevadm info --query=env "--name=$_dev" 2> /dev/null)
if strstr "$_rootinfo" "ID_FS_TYPE=btrfs"; then
info "Checking, if btrfs device complete"
unset __btrfs_mount
- mount -o ro "$_dev" /tmp >/dev/null 2>&1
+ mount -o ro "$_dev" /tmp > /dev/null 2>&1
__btrfs_mount=$?
- [ $__btrfs_mount -eq 0 ] && umount "$_dev" >/dev/null 2>&1
+ [ $__btrfs_mount -eq 0 ] && umount "$_dev" > /dev/null 2>&1
return $__btrfs_mount
fi
return 0
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
info "Scanning for all btrfs devices"
-/sbin/btrfs device scan >/dev/null 2>&1
+/sbin/btrfs device scan > /dev/null 2>&1
inst_rules "$moddir/80-btrfs.rules"
case "$(btrfs --help)" in
*device\ ready*)
- inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished ;;
+ inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished
+ ;;
*)
- inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished ;;
+ inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
+ ;;
esac
fi
#!/bin/sh
# close everything which is not busy
-rm -f -- /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
+rm -f -- /etc/udev/rules.d/70-luks.rules > /dev/null 2>&1
-if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then
+if ! getarg rd.luks.uuid -d rd_LUKS_UUID > /dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS > /dev/null 2>&1; then
while true; do
local do_break="y"
for i in /dev/mapper/luks-*; do
- cryptsetup luksClose $i >/dev/null 2>&1 && do_break=n
+ cryptsetup luksClose $i > /dev/null 2>&1 && do_break=n
done
[ "$do_break" = "y" ] && break
done
#!/bin/sh
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
# check if the crypttab contains an entry for a LUKS UUID
crypttab_contains() {
# Turn off input echo before tty command is executed and turn on after.
# It's useful when password is read from stdin.
ask_for_password() {
- local cmd; local prompt; local tries=3
- local ply_cmd; local ply_prompt; local ply_tries=3
- local tty_cmd; local tty_prompt; local tty_tries=3
+ local cmd
+ local prompt
+ local tries=3
+ local ply_cmd
+ local ply_prompt
+ local ply_tries=3
+ local tty_cmd
+ local tty_prompt
+ local tty_tries=3
local ret
while [ $# -gt 0 ]; do
case "$1" in
- --cmd) ply_cmd="$2"; tty_cmd="$2"; shift;;
- --ply-cmd) ply_cmd="$2"; shift;;
- --tty-cmd) tty_cmd="$2"; shift;;
- --prompt) ply_prompt="$2"; tty_prompt="$2"; shift;;
- --ply-prompt) ply_prompt="$2"; shift;;
- --tty-prompt) tty_prompt="$2"; shift;;
- --tries) ply_tries="$2"; tty_tries="$2"; shift;;
- --ply-tries) ply_tries="$2"; shift;;
- --tty-tries) tty_tries="$2"; shift;;
- --tty-echo-off) tty_echo_off=yes;;
+ --cmd)
+ ply_cmd="$2"
+ tty_cmd="$2"
+ shift
+ ;;
+ --ply-cmd)
+ ply_cmd="$2"
+ shift
+ ;;
+ --tty-cmd)
+ tty_cmd="$2"
+ shift
+ ;;
+ --prompt)
+ ply_prompt="$2"
+ tty_prompt="$2"
+ shift
+ ;;
+ --ply-prompt)
+ ply_prompt="$2"
+ shift
+ ;;
+ --tty-prompt)
+ tty_prompt="$2"
+ shift
+ ;;
+ --tries)
+ ply_tries="$2"
+ tty_tries="$2"
+ shift
+ ;;
+ --ply-tries)
+ ply_tries="$2"
+ shift
+ ;;
+ --tty-tries)
+ tty_tries="$2"
+ shift
+ ;;
+ --tty-echo-off) tty_echo_off=yes ;;
esac
shift
done
- { flock -s 9;
+ {
+ flock -s 9
# Prompt for password with plymouth, if installed and running.
- if type plymouth >/dev/null 2>&1 && plymouth --ping 2>/dev/null; then
+ if type plymouth > /dev/null 2>&1 && plymouth --ping 2> /dev/null; then
plymouth ask-for-password \
--prompt "$ply_prompt" --number-of-tries=$ply_tries \
--command="$ply_cmd"
local i=1
while [ $i -le $tty_tries ]; do
- [ -n "$tty_prompt" ] && \
- printf "$tty_prompt [$i/$tty_tries]:" >&2
+ [ -n "$tty_prompt" ] \
+ && printf "$tty_prompt [$i/$tty_tries]:" >&2
eval "$tty_cmd" && ret=0 && break
ret=$?
- i=$(($i+1))
+ i=$(($i + 1))
[ -n "$tty_prompt" ] && printf '\n' >&2
done
[ "$tty_echo_off" = yes ] && stty $stty_orig
fi
- } 9>/.console_lock
+ } 9> /.console_lock
[ $ret -ne 0 ] && echo "Wrong password" >&2
return $ret
# example:
# test_dev -f LABEL="nice label" /some/file1
test_dev() {
- local test_op=$1; local dev="$2"; local f="$3"
- local ret=1; local mount_point=$(mkuniqdir /mnt testdev)
+ local test_op=$1
+ local dev="$2"
+ local f="$3"
+ local ret=1
+ local mount_point=$(mkuniqdir /mnt testdev)
local path
[ -n "$dev" -a -n "$*" ] || return 1
[ -d "$mount_point" ] || die 'Mount point does not exist!'
- if mount -r "$dev" "$mount_point" >/dev/null 2>&1; then
+ if mount -r "$dev" "$mount_point" > /dev/null 2>&1; then
test $test_op "${mount_point}/${f}"
ret=$?
umount "$mount_point"
# Returns true if /dev/dm-1 UUID starts with "123".
match_dev() {
[ -z "$1" -o "$1" = '*' ] && return 0
- local devlist; local dev
+ local devlist
+ local dev
devlist="$(devnames "$1")" || return 255
dev="$(devnames "$2")" || return 255
# May print:
# /dev/sdc1:/keys/some.key
getkey() {
- local keys_file="$1"; local for_dev="$2"
- local luks_dev; local key_dev; local key_path
+ local keys_file="$1"
+ local for_dev="$2"
+ local luks_dev
+ local key_dev
+ local key_path
[ -z "$keys_file" -o -z "$for_dev" ] && die 'getkey: wrong usage!'
[ -f "$keys_file" ] || return 1
#!/bin/sh
. /lib/dracut-lib.sh
-type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
+type crypttab_contains > /dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
dev=$1
luks=$2
echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab
-if command -v systemctl >/dev/null; then
+if command -v systemctl > /dev/null; then
systemctl daemon-reload
systemctl start cryptsetup.target
fi
info "No key found for $device. Will try $numtries time(s) more later."
initqueue --unique --onetime --settled \
--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
fi
unset tmp
IFS=$_OLD_IFS
# try to load the cipher part with "crypto-" prepended
# in non-hostonly mode
- hostonly= instmods $(for k in "$@"; do echo "crypto-$k";done)
+ hostonly= instmods $(for k in "$@"; do echo "crypto-$k"; done)
fi
done
}
UUID=$(
blkid -u crypto -o export $dev \
| while read line || [ -n "$line" ]; do
- [[ ${line#UUID} = $line ]] && continue
- printf "%s" "${line#UUID=}"
- break
- done
+ [[ ${line#UUID} = $line ]] && continue
+ printf "%s" "${line#UUID=}"
+ break
+ done
)
[[ ${UUID} ]] || continue
printf "%s" " rd.luks.uuid=luks-${UUID}"
[[ $_mapper = \#* ]] && continue
[[ $_dev ]] || continue
- [[ $_dev == PARTUUID=* ]] && \
- _dev="/dev/disk/by-partuuid/${_dev#PARTUUID=}"
+ [[ $_dev == PARTUUID=* ]] \
+ && _dev="/dev/disk/by-partuuid/${_dev#PARTUUID=}"
- [[ $_dev == UUID=* ]] && \
- _dev="/dev/disk/by-uuid/${_dev#UUID=}"
+ [[ $_dev == UUID=* ]] \
+ && _dev="/dev/disk/by-uuid/${_dev#UUID=}"
- [[ $_dev == ID=* ]] && \
- _dev="/dev/disk/by-id/${_dev#ID=}"
+ [[ $_dev == ID=* ]] \
+ && _dev="/dev/disk/by-id/${_dev#ID=}"
echo "$_dev $(blkid $_dev -s UUID -o value)" >> "${initdir}/etc/block_uuid.map"
# the cryptsetup targets are already pulled in by 00systemd, but not
# the enablement symlinks
inst_multiple -o \
- $systemdutildir/system-generators/systemd-cryptsetup-generator \
- $systemdutildir/systemd-cryptsetup \
- $systemdsystemunitdir/systemd-ask-password-console.path \
- $systemdsystemunitdir/systemd-ask-password-console.service \
- $systemdsystemunitdir/cryptsetup.target \
- $systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
- $systemdsystemunitdir/remote-cryptsetup.target \
- $systemdsystemunitdir/initrd-root-device.target.wants/remote-cryptsetup.target \
- systemd-ask-password systemd-tty-ask-password-agent
+ $systemdutildir/system-generators/systemd-cryptsetup-generator \
+ $systemdutildir/systemd-cryptsetup \
+ $systemdsystemunitdir/systemd-ask-password-console.path \
+ $systemdsystemunitdir/systemd-ask-password-console.service \
+ $systemdsystemunitdir/cryptsetup.target \
+ $systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
+ $systemdsystemunitdir/remote-cryptsetup.target \
+ $systemdsystemunitdir/initrd-root-device.target.wants/remote-cryptsetup.target \
+ systemd-ask-password systemd-tty-ask-password-agent
fi
dracut_need_initqueue
#!/bin/sh
-type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
-
+type crypttab_contains > /dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
_cryptgetargsname() {
debug_off
set --
for _o in $(getargs rd.luks.name); do
if [ "${_o%=*}" = "${_key%=}" ]; then
- [ -n "${_o%=*}" ] && set -- "$@" "${_o#*=}";
- _found=1;
+ [ -n "${_o%=*}" ] && set -- "$@" "${_o#*=}"
+ _found=1
fi
done
if [ -n "$_found" ]; then
[ $# -gt 0 ] && printf '%s' "$*"
return 0
fi
- return 1;
+ return 1
}
if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then
#!/bin/sh
-if getargbool 1 rd.luks -n rd_NO_LUKS && \
- [ -n "$(getarg rd.luks.key)" ]; then
- exec 7>/etc/udev/rules.d/65-luks-keydev.rules
+if getargbool 1 rd.luks -n rd_NO_LUKS \
+ && [ -n "$(getarg rd.luks.key)" ]; then
+ exec 7> /etc/udev/rules.d/65-luks-keydev.rules
echo 'SUBSYSTEM!="block", GOTO="luks_keydev_end"' >&7
echo 'ACTION!="add|change", GOTO="luks_keydev_end"' >&7
. /lib/dracut-crypt-lib.sh
-
-real_keydev="$1"; keypath="$2"; luksdev="$3"
+real_keydev="$1"
+keypath="$2"
+luksdev="$3"
[ -z "$real_keydev" -o -z "$keypath" ] && die 'probe-keydev: wrong usage!'
[ -z "$luksdev" ] && luksdev='*'
#!/bin/sh
strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod
-modprobe dm_mirror 2>/dev/null
+modprobe dm_mirror 2> /dev/null
local s
local devname
- for s in /sys/block/${dev}/holders/dm-* ; do
+ for s in /sys/block/${dev}/holders/dm-*; do
[ -e ${s} ] || continue
_remove_dm ${s##*/}
done
local dev
info "Disassembling device-mapper devices"
- for dev in /sys/block/dm-* ; do
+ for dev in /sys/block/dm-*; do
[ -e ${dev} ] || continue
if [ "x$final" != "x" ]; then
_remove_dm ${dev##*/} || ret=$?
else
- _remove_dm ${dev##*/} >/dev/null 2>&1 || ret=$?
+ _remove_dm ${dev##*/} > /dev/null 2>&1 || ret=$?
fi
done
if [ "x$final" != "x" ]; then
return $ret
}
-if command -v dmsetup >/dev/null &&
- [ "x$(dmsetup status)" != "xNo devices found" ]; then
+if command -v dmsetup > /dev/null \
+ && [ "x$(dmsetup status)" != "xNo devices found" ]; then
_do_dm_shutdown $1
else
:
# called by dracut
install() {
- modinfo -k "$kernel" dm_mod >/dev/null 2>&1 && \
- inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"
+ modinfo -k "$kernel" dm_mod > /dev/null 2>&1 \
+ && inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"
inst_multiple dmsetup
inst_multiple -o dmeventd
inst_hook shutdown 25 "$moddir/dm-shutdown.sh"
}
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
dev="$1"
devenc=$(str_replace "$1" '/' '\2f')
[ -e /tmp/dmraid.$devenc ] && exit 0
->/tmp/dmraid.$devenc
+> /tmp/dmraid.$devenc
DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=)
fi
info "Found dmraid sets:"
- echo $SETS|vinfo
+ echo $SETS | vinfo
if [ -n "$DM_RAIDS" ]; then
- # only activate specified DM RAIDS
+ # only activate specified DM RAIDS
for r in $DM_RAIDS; do
for s in $SETS; do
if [ "${s##$r}" != "$s" ]; then
done
done
else
- # scan and activate all DM RAIDS
+ # scan and activate all DM RAIDS
for s in $SETS; do
info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
for holder in "$DEVPATH"/holders/*; do
[[ -e "$holder" ]] || continue
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
done
udevproperty rd_NO_DM=1
fi
-if ! command -v mdadm >/dev/null \
+if ! command -v mdadm > /dev/null \
|| ! getargbool 1 rd.md.imsm -d -n rd_NO_MDIMSM -n noiswmd \
|| ! getargbool 1 rd.md -d -n rd_NO_MD; then
info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
udevproperty rd_NO_MDIMSM=1
fi
-if ! command -v mdadm >/dev/null \
+if ! command -v mdadm > /dev/null \
|| ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF -n noddfmd \
|| ! getargbool 1 rd.md -d -n rd_NO_MD; then
info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
umount "$NEWROOT"/run
fi
# release resources on iso-scan boots with rd.live.ram
-if [ -d /run/initramfs/isoscan ] &&
- [ -f /run/initramfs/squashed.img -o -f /run/initramfs/rootfs.img ]; then
+if [ -d /run/initramfs/isoscan ] \
+ && [ -f /run/initramfs/squashed.img -o -f /run/initramfs/rootfs.img ]; then
umount --detach-loop /run/initramfs/live
umount /run/initramfs/isoscan
fi
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
[ -z "$root" ] && root=$(getarg root=)
liveroot="live:$root"
fi
-if [ "${root%%:*}" = "live" ] ; then
+if [ "${root%%:*}" = "live" ]; then
liveroot=$root
fi
[ "${liveroot%%:*}" = "live" ] || exit 0
case "$liveroot" in
- live:LABEL=*|LABEL=* | live:UUID=*|UUID=* | live:PARTUUID=*|PARTUUID=* | live:PARTLABEL=*|PARTLABEL=*)
+ live:LABEL=* | LABEL=* | live:UUID=* | UUID=* | live:PARTUUID=* | PARTUUID=* | live:PARTLABEL=* | PARTLABEL=*)
root="live:$(label_uuid_to_dev "${root#live:}")"
- rootok=1 ;;
- live:CDLABEL=*|CDLABEL=*)
+ rootok=1
+ ;;
+ live:CDLABEL=* | CDLABEL=*)
root="${root#live:}"
root="$(echo "$root" | sed 's,/,\\x2f,g;s, ,\\x20,g')"
root="live:/dev/disk/by-label/${root#CDLABEL=}"
- rootok=1 ;;
- live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
+ rootok=1
+ ;;
+ live:/*.[Ii][Ss][Oo] | /*.[Ii][Ss][Oo])
root="${root#live:}"
root="liveiso:${root}"
- rootok=1 ;;
+ rootok=1
+ ;;
live:/dev/*)
- rootok=1 ;;
- live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
- [ -f "${root#live:}" ] && rootok=1 ;;
+ rootok=1
+ ;;
+ live:/*.[Ii][Mm][Gg] | /*.[Ii][Mm][Gg])
+ [ -f "${root#live:}" ] && rootok=1
+ ;;
esac
[ "$rootok" != "1" ] && exit 0
#!/bin/sh
case "$root" in
- live:/dev/*)
- {
- printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root %s"\n' \
- "${root#live:/dev/}" "${root#live:}"
- printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root %s"\n' \
- "${root#live:/dev/}" "${root#live:}"
- } >> /etc/udev/rules.d/99-live-squash.rules
- wait_for_dev -n "${root#live:}"
- ;;
- live:*)
- if [ -f "${root#live:}" ]; then
- /sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
- fi
- ;;
+ live:/dev/*)
+ {
+ printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root %s"\n' \
+ "${root#live:/dev/}" "${root#live:}"
+ printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root %s"\n' \
+ "${root#live:/dev/}" "${root#live:}"
+ } >> /etc/udev/rules.d/99-live-squash.rules
+ wait_for_dev -n "${root#live:}"
+ ;;
+ live:*)
+ if [ -f "${root#live:}" ]; then
+ /sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
+ fi
+ ;;
esac
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
-command -v unpack_archive >/dev/null || . /lib/img-lib.sh
+command -v unpack_archive > /dev/null || . /lib/img-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
fi
getarg rd.live.check -d check || check=""
if [ -n "$check" ]; then
- type plymouth >/dev/null 2>&1 && plymouth --hide-splash
+ type plymouth > /dev/null 2>&1 && plymouth --hide-splash
if [ -n "$DRACUT_SYSTEMD" ]; then
p=$(dev_unit_name "$livedev")
systemctl start checkisomd5@${p}.service
die "CD check failed!"
exit 1
fi
- type plymouth >/dev/null 2>&1 && plymouth --show-splash
+ type plymouth > /dev/null 2>&1 && plymouth --show-splash
fi
ln -s $livedev /run/initramfs/livedev
# check filesystem type and handle accordingly
fstype=$(det_img_fs $livedev)
case $fstype in
- squashfs) SQUASHED=$livedev;;
+ squashfs) SQUASHED=$livedev ;;
auto) die "cannot mount live image (unknown filesystem type)" ;;
*) FSIMG=$livedev ;;
esac
else
livedev_fstype=$(blkid -o value -s TYPE $livedev)
if [ "$livedev_fstype" = "squashfs" ]; then
- # no mount needed - we've already got the LiveOS image in $livedev
- SQUASHED=$livedev
+ # no mount needed - we've already got the LiveOS image in $livedev
+ SQUASHED=$livedev
elif [ "$livedev_fstype" != "ntfs" ]; then
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
else
# at the first glance, but ends with lots and lots of squashfs
# errors, because systemd attempts to kill the ntfs-3g process?!
if [ -x "/usr/bin/ntfs-3g" ]; then
- ( exec -a @ntfs-3g ntfs-3g -o ${liverw:-ro} $livedev /run/initramfs/live ) | vwarn
+ (exec -a @ntfs-3g ntfs-3g -o ${liverw:-ro} $livedev /run/initramfs/live) | vwarn
else
die "Failed to mount block device of live image: Missing NTFS support"
exit 1
if [ -z "$oltype" ] || [ "$oltype" = DM_snapshot_cow ]; then
if [ -n "$reset_overlay" ]; then
info "Resetting the Device-mapper overlay."
- dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 conv=fsync 2>/dev/null
+ dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 conv=fsync 2> /dev/null
fi
if [ -n "$overlayfs" ]; then
unset -v overlayfs
setup="yes"
else
mount -n -t $oltype $opt $OVERLAY_LOOPDEV /run/initramfs/overlayfs
- if [ -d /run/initramfs/overlayfs/overlayfs ] &&
- [ -d /run/initramfs/overlayfs/ovlwork ]; then
+ if [ -d /run/initramfs/overlayfs/overlayfs ] \
+ && [ -d /run/initramfs/overlayfs/ovlwork ]; then
ln -s /run/initramfs/overlayfs/overlayfs /run/overlayfs$opt
ln -s /run/initramfs/overlayfs/ovlwork /run/ovlwork$opt
if [ -z "$overlayfs" ] && [ -n "$DRACUT_SYSTEMD" ]; then
setup="yes"
fi
fi
- elif [ -d /run/initramfs/overlayfs$pathspec ] &&
- [ -d /run/initramfs/overlayfs$pathspec/../ovlwork ]; then
+ elif [ -d /run/initramfs/overlayfs$pathspec ] \
+ && [ -d /run/initramfs/overlayfs$pathspec/../ovlwork ]; then
ln -s /run/initramfs/overlayfs$pathspec /run/overlayfs$opt
ln -s /run/initramfs/overlayfs$pathspec/../ovlwork /run/ovlwork$opt
if [ -z "$overlayfs" ] && [ -n "$DRACUT_SYSTEMD" ]; then
if [ -n "$setup" ]; then
warn "Using temporary overlay."
elif [ -n "$devspec" -a -n "$pathspec" ]; then
- [ -z "$m" ] &&
- m=' Unable to find a persistent overlay; using a temporary one.'
+ [ -z "$m" ] \
+ && m=' Unable to find a persistent overlay; using a temporary one.'
m="$m"$'\n All root filesystem changes will be lost on shutdown.'
m="$m"$'\n Press [Enter] to continue.'
printf "\n\n\n\n${m}\n\n\n" > /dev/kmsg
if [ -n "$DRACUT_SYSTEMD" ]; then
- if type plymouth >/dev/null 2>&1 && plymouth --ping ; then
- if getargbool 0 rhgb || getargbool 0 splash ; then
+ if type plymouth > /dev/null 2>&1 && plymouth --ping; then
+ if getargbool 0 rhgb || getargbool 0 splash; then
m='>>>'$'\n''>>>'$'\n''>>>'$'\n\n\n'"$m"
m="${m%n.*}"$'n.\n\n\n''<<<'$'\n''<<<'$'\n''<<<'
plymouth display-message --text="${m}"
systemd-ask-password --timeout=0 "${m}"
fi
else
- type plymouth >/dev/null 2>&1 && plymouth --ping && plymouth --quit
+ type plymouth > /dev/null 2>&1 && plymouth --ping && plymouth --quit
read -s -r -p $'\n\n'"${m}" -n 1 reply
fi
fi
[ -n "$DRACUT_SYSTEMD" ] && reloadsysrootmountunit="${reloadsysrootmountunit}:>/xor_readonly;"
fi
else
- dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((overlay_size*1024)) 2> /dev/null
+ dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((overlay_size * 1024)) 2> /dev/null
if [ -n "$setup" -a -n "$readonly_overlay" ]; then
RO_OVERLAY_LOOPDEV=$(losetup -f --show /overlay)
over=$RO_OVERLAY_LOOPDEV
mkdir -m 0755 -p /run/initramfs/thin-overlay
# In block units (512b)
- thin_data_sz=$(( $overlay_size * 1024 * 1024 / 512 ))
- thin_meta_sz=$(( $thin_data_sz / 10 ))
+ thin_data_sz=$(($overlay_size * 1024 * 1024 / 512))
+ thin_meta_sz=$(($thin_data_sz / 10))
# It is important to have the backing file on a tmpfs
# this is needed to let the loopdevice support TRIM
dd if=/dev/null of=/run/initramfs/thin-overlay/meta bs=1b count=1 seek=$((thin_meta_sz)) 2> /dev/null
dd if=/dev/null of=/run/initramfs/thin-overlay/data bs=1b count=1 seek=$((thin_data_sz)) 2> /dev/null
- THIN_META_LOOPDEV=$( losetup --show -f /run/initramfs/thin-overlay/meta )
- THIN_DATA_LOOPDEV=$( losetup --show -f /run/initramfs/thin-overlay/data )
+ THIN_META_LOOPDEV=$(losetup --show -f /run/initramfs/thin-overlay/meta)
+ THIN_DATA_LOOPDEV=$(losetup --show -f /run/initramfs/thin-overlay/data)
echo 0 $thin_data_sz thin-pool $THIN_META_LOOPDEV $THIN_DATA_LOOPDEV 1024 1024 | dmsetup create live-overlay-pool
dmsetup message /dev/mapper/live-overlay-pool 0 "create_thin 0"
SQUASHED="/run/initramfs/squashed.img"
fi
- SQUASHED_LOOPDEV=$( losetup -f )
+ SQUASHED_LOOPDEV=$(losetup -f)
losetup -r $SQUASHED_LOOPDEV $SQUASHED
mkdir -m 0755 -p /run/initramfs/squashfs
mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs
FSIMG=/run/initramfs/fsimg/rootfs.img
fi
opt=-r
- # For writable DM images...
- if [ -z "$SQUASHED" -a -n "$live_ram" -a -z "$overlayfs" ] ||
- [ -n "$writable_fsimg" ] ||
- [ "$overlay" = none -o "$overlay" = None -o "$overlay" = NONE ]; then
+ # For writable DM images...
+ if [ -z "$SQUASHED" -a -n "$live_ram" -a -z "$overlayfs" ] \
+ || [ -n "$writable_fsimg" ] \
+ || [ "$overlay" = none -o "$overlay" = None -o "$overlay" = NONE ]; then
if [ -z "$readonly_overlay" ]; then
opt=''
setup=rw
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
ovlfs=$(readlink /run/overlayfs)
info "Resetting the OverlayFS overlay directory."
- rm -r -- ${ovlfs}/* ${ovlfs}/.* >/dev/null 2>&1
+ rm -r -- ${ovlfs}/* ${ovlfs}/.* > /dev/null 2>&1
fi
if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then
ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase
mount -r $FSIMG /run/rootfsbase
if [ -z "$DRACUT_SYSTEMD" ]; then
printf 'mount -t overlay LiveOS_rootfs -o%s,%s %s\n' "$ROOTFLAGS" \
- "$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork \
- "$NEWROOT" > $hookdir/mount/01-$$-live.sh
+ "$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork \
+ "$NEWROOT" > $hookdir/mount/01-$$-live.sh
fi
else
if [ -z "$DRACUT_SYSTEMD" ]; then
need_shutdown
exit 0
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
liveroot="live:$root"
fi
-if [ "${root%%:*}" = "live" ] ; then
+if [ "${root%%:*}" = "live" ]; then
liveroot=$root
fi
modprobe -q loop
case "$liveroot" in
- live:LABEL=*|LABEL=* | live:UUID=*|UUID=* | live:PARTUUID=*|PARTUUID=* | live:PARTLABEL=*|PARTLABEL=*)
+ live:LABEL=* | LABEL=* | live:UUID=* | UUID=* | live:PARTUUID=* | PARTUUID=* | live:PARTLABEL=* | PARTLABEL=*)
root="live:$(label_uuid_to_dev "${root#live:}")"
- rootok=1 ;;
- live:CDLABEL=*|CDLABEL=*)
+ rootok=1
+ ;;
+ live:CDLABEL=* | CDLABEL=*)
root="${root#live:}"
root="$(echo "$root" | sed 's,/,\\x2f,g;s, ,\\x20,g')"
root="live:/dev/disk/by-label/${root#CDLABEL=}"
- rootok=1 ;;
- live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
+ rootok=1
+ ;;
+ live:/*.[Ii][Ss][Oo] | /*.[Ii][Ss][Oo])
root="${root#live:}"
root="liveiso:${root}"
- rootok=1 ;;
+ rootok=1
+ ;;
live:/dev/*)
- rootok=1 ;;
- live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
- [ -f "${root#live:}" ] && rootok=1 ;;
+ rootok=1
+ ;;
+ live:/*.[Ii][Mm][Gg] | /*.[Ii][Mm][Gg])
+ [ -f "${root#live:}" ] && rootok=1
+ ;;
esac
[ "$rootok" = "1" ] || return 1
# - "depmod_configs" - array of depmod configuration paths to parse
# (as supplied to depmod -C, ("/run/depmod.d/"
# "/etc/depmod.d/" "/lib/depmod.d/") by default).
-installkernel()
-{
- : "${depmod_modules_dep:=$srcmods/modules.dep}"
- : "${depmod_module_dir:=$srcmods}"
-
- [[ -f "${depmod_modules_dep}" ]] || return 0
-
- # Message printers with custom prefix
- local mod_name="kernel-modules-extra"
- prinfo() { dinfo " ${mod_name}: $*"; }
- prdebug() { ddebug " ${mod_name}: $*"; }
-
- # Escape a string for usage as a part of extended regular expression.
- # $1 - string to escape
- re_escape() {
- printf "%s" "$1" | sed 's/\([.+?^$\/\\|()\[]\|\]\)/\\\0/'
- }
-
- local OLDIFS
- local cfg
- local cfgs=()
- local search_list=""
- local overrides=()
- local external_dirs=()
- local e f
-
-
- ## Gathering and sorting configuration file list
-
- [ -n "${depmod_configs[*]-}" ] \
- || depmod_configs=(/run/depmod.d/ /etc/depmod.d/ /lib/depmod.d/)
-
- for cfg in "${depmod_configs[@]}"; do
- [ -e "$cfg" ] || {
- prdebug "configuration source \"$cfg\" does not exist"
- continue
- }
-
- # '/' is used as a separator between configuration name and
- # configuration path
- if [ -d "$cfg" ]; then
- for f in "$cfg/"*; do
- [[ -e "$f" && ! -d "$f" ]] || {
- prdebug "configuration source" \
- "\"$cfg\" is ignored" \
- "(directory or doesn't exist)"
- continue
- }
- cfgs+=("$(basename "$f")/$f")
- done
- else
- cfgs+=("$(basename "$cfg")/$cfg")
- fi
- done
-
- OLDIFS="$IFS"
- IFS=$'\n'
- LANG=C cfgs=($(printf '%s\n' "${cfgs[@]}" \
- | sort -u -k1,1 -t '/' | cut -f 2- -d '/'))
- IFS="$OLDIFS"
-
-
- ## Parse configurations
-
- for cfg in "${cfgs[@]}"; do
- prdebug "parsing configuration file \"$cfg\""
-
- local k v mod kverpat path
- while read -r k v; do
- case "$k" in
- search)
- search_list="$search_list $v"
- prdebug "$cfg: added \"$v\" to the list of" \
- "search directories"
- ;;
- override) # module_name kver_pattern dir
- read -r mod kverpat path <<<"$v"
-
- if [[ ! "$mod" || ! "$kverpat" || ! "$path" ]]
- then
- prinfo "$cfg: ignoring incorrect" \
- "override option: \"$k $v\""
- continue
- fi
-
- if [[ '*' = "$kverpat" ]] \
- || [[ "$kernel" =~ $kverpat ]]
- then
- overrides+=("${path}/${mod}")
-
- prdebug "$cfg: added override" \
- "\"${path}/${mod}\""
- else
- prdebug "$cfg: override \"$v\" is" \
- "ignored since \"$kverpat\"" \
- "doesn't match \"$kernel\""
- fi
- ;;
- external) # kverpat dir
- read -r kverpat path <<<"$v"
-
- if [[ ! "$kverpat" || ! "$path" ]]; then
- prinfo "$cfg: ignoring incorrect" \
- "external option: \"$k $v\""
- continue
- fi
-
- if [[ '*' = "$kverpat" \
- || "$kernel" =~ $kverpat ]]
- then
- external_dirs+=("$path")
-
- prdebug "$cfg: added external" \
- "directory \"$path\""
- else
- prdebug "$cfg: external directory" \
- "\"$path\" is ignored since" \
- "\"$kverpat\" doesn't match " \
- "\"$kernel\""
- fi
- ;;
- '#'*|'') # comments and empty strings
- ;;
- include|make_map_files) # ignored by depmod
- ;;
- *)
- prinfo "$cfg: unknown depmod configuration" \
- "option \"$k $v\""
- ;;
- esac
- done < "$cfg"
- done
-
- # "updates built-in" is the default search list
- : "${search_list:=updates}"
-
-
- ## Build a list of regular expressions for grepping modules.dep
-
- local pathlist=()
- for f in "${overrides[@]}"; do
- pathlist+=("^$(re_escape "$f")")
- done
-
- for f in $(printf "%s" "$search_list"); do
- # Ignoring builtin modules
- [ "built-in" != "$f" ] || continue
-
- if [ "external" = "$f" ]; then
- for e in "${external_dirs[@]}"; do
- pathlist+=("$(re_escape "${e%/}")/[^:]+")
- done
- fi
-
- pathlist+=("$(re_escape "${f%/}")/[^:]+")
- done
-
-
- ## Filter modules.dep, canonicalise the resulting filenames and supply
- ## them to instmods.
-
- [ 0 -lt "${#pathlist[@]}" ] || return 0
-
- printf "^%s\.ko(\.gz|\.bz2|\.xz)?:\n" "${pathlist[@]}" \
- | (LANG=C grep -E -o -f - -- "$depmod_modules_dep" || exit 0) \
- | tr -d ':' \
- | (cd "$depmod_module_dir" || exit; xargs -r realpath -se --) \
- | instmods || return 1
-
- return 0
+installkernel() {
+ : "${depmod_modules_dep:=$srcmods/modules.dep}"
+ : "${depmod_module_dir:=$srcmods}"
+
+ [[ -f "${depmod_modules_dep}" ]] || return 0
+
+ # Message printers with custom prefix
+ local mod_name="kernel-modules-extra"
+ prinfo() { dinfo " ${mod_name}: $*"; }
+ prdebug() { ddebug " ${mod_name}: $*"; }
+
+ # Escape a string for usage as a part of extended regular expression.
+ # $1 - string to escape
+ re_escape() {
+ printf "%s" "$1" | sed 's/\([.+?^$\/\\|()\[]\|\]\)/\\\0/'
+ }
+
+ local OLDIFS
+ local cfg
+ local cfgs=()
+ local search_list=""
+ local overrides=()
+ local external_dirs=()
+ local e f
+
+ ## Gathering and sorting configuration file list
+
+ [ -n "${depmod_configs[*]-}" ] \
+ || depmod_configs=(/run/depmod.d/ /etc/depmod.d/ /lib/depmod.d/)
+
+ for cfg in "${depmod_configs[@]}"; do
+ [ -e "$cfg" ] || {
+ prdebug "configuration source \"$cfg\" does not exist"
+ continue
+ }
+
+ # '/' is used as a separator between configuration name and
+ # configuration path
+ if [ -d "$cfg" ]; then
+ for f in "$cfg/"*; do
+ [[ -e "$f" && ! -d "$f" ]] || {
+ prdebug "configuration source" \
+ "\"$cfg\" is ignored" \
+ "(directory or doesn't exist)"
+ continue
+ }
+ cfgs+=("$(basename "$f")/$f")
+ done
+ else
+ cfgs+=("$(basename "$cfg")/$cfg")
+ fi
+ done
+
+ OLDIFS="$IFS"
+ IFS=$'\n'
+ LANG=C cfgs=($(printf '%s\n' "${cfgs[@]}" \
+ | sort -u -k1,1 -t '/' | cut -f 2- -d '/'))
+ IFS="$OLDIFS"
+
+ ## Parse configurations
+
+ for cfg in "${cfgs[@]}"; do
+ prdebug "parsing configuration file \"$cfg\""
+
+ local k v mod kverpat path
+ while read -r k v; do
+ case "$k" in
+ search)
+ search_list="$search_list $v"
+ prdebug "$cfg: added \"$v\" to the list of" \
+ "search directories"
+ ;;
+ override) # module_name kver_pattern dir
+ read -r mod kverpat path <<< "$v"
+
+ if [[ ! "$mod" || ! "$kverpat" || ! "$path" ]]; then
+ prinfo "$cfg: ignoring incorrect" \
+ "override option: \"$k $v\""
+ continue
+ fi
+
+ if [[ '*' = "$kverpat" ]] \
+ || [[ "$kernel" =~ $kverpat ]]; then
+ overrides+=("${path}/${mod}")
+
+ prdebug "$cfg: added override" \
+ "\"${path}/${mod}\""
+ else
+ prdebug "$cfg: override \"$v\" is" \
+ "ignored since \"$kverpat\"" \
+ "doesn't match \"$kernel\""
+ fi
+ ;;
+ external) # kverpat dir
+ read -r kverpat path <<< "$v"
+
+ if [[ ! "$kverpat" || ! "$path" ]]; then
+ prinfo "$cfg: ignoring incorrect" \
+ "external option: \"$k $v\""
+ continue
+ fi
+
+ if [[ '*' = "$kverpat" || \
+ "$kernel" =~ $kverpat ]]; then
+ external_dirs+=("$path")
+
+ prdebug "$cfg: added external" \
+ "directory \"$path\""
+ else
+ prdebug "$cfg: external directory" \
+ "\"$path\" is ignored since" \
+ "\"$kverpat\" doesn't match " \
+ "\"$kernel\""
+ fi
+ ;;
+ '#'* | '') # comments and empty strings
+ ;;
+ include | make_map_files) # ignored by depmod
+ ;;
+ *)
+ prinfo "$cfg: unknown depmod configuration" \
+ "option \"$k $v\""
+ ;;
+ esac
+ done < "$cfg"
+ done
+
+ # "updates built-in" is the default search list
+ : "${search_list:=updates}"
+
+ ## Build a list of regular expressions for grepping modules.dep
+
+ local pathlist=()
+ for f in "${overrides[@]}"; do
+ pathlist+=("^$(re_escape "$f")")
+ done
+
+ for f in $(printf "%s" "$search_list"); do
+ # Ignoring builtin modules
+ [ "built-in" != "$f" ] || continue
+
+ if [ "external" = "$f" ]; then
+ for e in "${external_dirs[@]}"; do
+ pathlist+=("$(re_escape "${e%/}")/[^:]+")
+ done
+ fi
+
+ pathlist+=("$(re_escape "${f%/}")/[^:]+")
+ done
+
+ ## Filter modules.dep, canonicalise the resulting filenames and supply
+ ## them to instmods.
+
+ [ 0 -lt "${#pathlist[@]}" ] || return 0
+
+ printf "^%s\.ko(\.gz|\.bz2|\.xz)?:\n" "${pathlist[@]}" \
+ | (LANG=C grep -E -o -f - -- "$depmod_modules_dep" || exit 0) \
+ | tr -d ':' \
+ | (
+ cd "$depmod_module_dir" || exit
+ xargs -r realpath -se --
+ ) \
+ | instmods || return 1
+
+ return 0
}
local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma'
local _hostonly_drvs
- find_kernel_modules_external () {
+ find_kernel_modules_external() {
local _OLDIFS
local external_pattern="^/"
return 1
}
- install_block_modules_strict () {
+ install_block_modules_strict() {
hostonly='' instmods $_hostonly_drvs
}
- install_block_modules () {
+ install_block_modules() {
instmods \
scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
=drivers/usb/storage \
# if not on hostonly mode, or there are hostonly block device
# install block drivers
- if ! [[ $hostonly ]] || \
- for_each_host_dev_and_slaves_all record_block_dev_drv;
- then
+ if ! [[ $hostonly ]] \
+ || for_each_host_dev_and_slaves_all record_block_dev_drv; then
hostonly='' instmods sg sr_mod sd_mod scsi_dh ata_piix
if [[ "$hostonly_mode" == "strict" ]]; then
#!/bin/sh
_modprobe_d=/etc/modprobe.d
-if [ -d /usr/lib/modprobe.d ] ; then
+if [ -d /usr/lib/modprobe.d ]; then
_modprobe_d=/usr/lib/modprobe.d
-elif [ -d /lib/modprobe.d ] ; then
+elif [ -d /lib/modprobe.d ]; then
_modprobe_d=/lib/modprobe.d
-elif [ ! -d $_modprobe_d ] ; then
+elif [ ! -d $_modprobe_d ]; then
mkdir -p $_modprobe_d
fi
)
done
-
[ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d
for i in $(getargs rd.driver.blacklist -d rdblacklist=); do
(
IFS=,
for p in $i; do
- echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
+ echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
done
)
done
for p in $(getargs rd.driver.post -d rdinsmodpost=); do
- echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
+ echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
_do_insmodpost=1
done
if [[ $hostonly_mode == 'strict' ]] && [[ $hostonly_nics ]]; then
for _nic in $hostonly_nics; do
mapfile -t _net_drivers <<< "$(get_dev_module /sys/class/net/"$_nic")"
- if (( ${#_net_drivers[@]} == 0 )); then
+ if ((${#_net_drivers[@]} == 0)); then
derror "--hostonly-nics contains invalid NIC '$_nic'"
continue
fi
install() {
return 0
}
-
# no updates requested? we're not needed.
[ -e /tmp/liveupdates.info ] || return 0
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
-command -v fetch_url >/dev/null || . /lib/url-lib.sh
-command -v unpack_img >/dev/null || . /lib/img-lib.sh
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
+command -v fetch_url > /dev/null || . /lib/url-lib.sh
+command -v unpack_img > /dev/null || . /lib/img-lib.sh
read url < /tmp/liveupdates.info
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
[ -z "$root" ] && root=$(getarg root=)
liveroot="live:$root"
fi
-if [ "${root%%:*}" = "live" ] ; then
+if [ "${root%%:*}" = "live" ]; then
liveroot=$root
fi
[ "${liveroot%%:*}" = "live" ] || exit 0
case "$liveroot" in
- live:nfs://*|nfs://*) \
+ live:nfs://* | nfs://*)
root="${root#live:}"
- rootok=1 ;;
- live:http://*|http://*) \
+ rootok=1
+ ;;
+ live:http://* | http://*)
root="${root#live:}"
- rootok=1 ;;
- live:https://*|https://*) \
+ rootok=1
+ ;;
+ live:https://* | https://*)
root="${root#live:}"
- rootok=1 ;;
- live:ftp://*|ftp://*) \
+ rootok=1
+ ;;
+ live:ftp://* | ftp://*)
root="${root#live:}"
- rootok=1 ;;
- live:torrent://*|torrent://*) \
+ rootok=1
+ ;;
+ live:torrent://* | torrent://*)
root="${root#live:}"
- rootok=1 ;;
- live:tftp://*|tftp://*) \
+ rootok=1
+ ;;
+ live:tftp://* | tftp://*)
root="${root#live:}"
- rootok=1 ;;
+ rootok=1
+ ;;
esac
[ "$rootok" != "1" ] && exit 0
#!/bin/sh
# livenetroot - fetch a live image from the network and run it
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/url-lib.sh
imgfile=
#retry until the imgfile is populated with data or the max retries
i=1
-while [ "$i" -le $RETRIES ]
-do
+while [ "$i" -le $RETRIES ]; do
imgfile=$(fetch_url "$liveurl")
if [ $? != 0 ]; then
- warn "failed to download live image: error $?"
- imgfile=
+ warn "failed to download live image: error $?"
+ imgfile=
fi
if [ ! -z "$imgfile" -a -s "$imgfile" ]; then
if [ -n "$updates" ]; then
# make sure network comes up even if we're doing a local live device
if [ -z "$netroot" ]; then
- echo > /tmp/net.ifaces
+ echo > /tmp/net.ifaces
fi
echo "$updates" > /tmp/liveupdates.info
echo '[ -e /tmp/liveupdates.done ]' > \
liveurl="${liveurl#live:}"
# setting netroot to "livenet:..." makes "livenetroot" get run after ifup
-if get_url_handler "$liveurl" >/dev/null; then
+if get_url_handler "$liveurl" > /dev/null; then
info "livenet: root image at $liveurl"
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
# run lvm scan if udev has settled
extraargs="$*"
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
VGS=$(getargs rd.lvm.vg -d rd_LVM_VG=)
LVS=$(getargs rd.lvm.lv -d rd_LVM_LV=)
if [ ! -e /etc/lvm/lvm.conf ]; then
{
- echo 'devices {';
+ echo 'devices {'
printf ' filter = [ '
for dev in $lvmdevs; do
- printf '"a|^/dev/%s$|", ' "$dev";
- done;
- echo '"r/.*/" ]';
- echo '}';
+ printf '"a|^/dev/%s$|", ' "$dev"
+ done
+ echo '"r/.*/" ]'
+ echo '}'
# establish LVM locking
if [ -n "$SNAPSHOT" ]; then
- echo 'global {';
- echo ' locking_type = 1';
- echo ' use_lvmetad = 0';
- echo '}';
+ echo 'global {'
+ echo ' locking_type = 1'
+ echo ' use_lvmetad = 0'
+ echo '}'
else
- echo 'global {';
- echo ' locking_type = 4';
- echo ' use_lvmetad = 0';
- echo '}';
+ echo 'global {'
+ echo ' locking_type = 4'
+ echo ' use_lvmetad = 0'
+ echo '}'
fi
} > /etc/lvm/lvm.conf
lvmwritten=1
OLDIFS=$IFS
IFS=.
# shellcheck disable=SC2046
-set -- $(lvm version 2>/dev/null)
+set -- $(lvm version 2> /dev/null)
IFS=$OLDIFS
maj=${1##*:}
min=$2
sub=${3%% *}
-sub=${sub%%\(*};
+sub=${sub%%\(*}
lvm_ignorelockingfailure="--ignorelockingfailure"
lvm_quirk_args="--ignorelockingfailure --ignoremonitoring"
-check_lvm_ver 2 2 57 "$maj" "$min" "$sub" && \
- lvm_quirk_args="$lvm_quirk_args --poll n"
+check_lvm_ver 2 2 57 "$maj" "$min" "$sub" \
+ && lvm_quirk_args="$lvm_quirk_args --poll n"
if check_lvm_ver 2 2 65 "$maj" "$min" "$sub"; then
lvm_quirk_args=" --sysinit $extraargs"
export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
-if [ -n "$SNAPSHOT" ] ; then
+if [ -n "$SNAPSHOT" ]; then
# HACK - this should probably be done elsewhere or turned into a function
# Enable read-write LVM locking
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 1/' /etc/lvm/lvm.conf
SNAP_LV=${SNAPSHOT##*:}
info "Removing existing LVM snapshot $SNAP_LV"
- lvm lvremove --force "$SNAP_LV" 2>&1| vinfo
+ lvm lvremove --force "$SNAP_LV" 2>&1 | vinfo
# Determine snapshot size
- if [ -z "$SNAPSIZE" ] ; then
- SNAPSIZE=$(lvm lvs --noheadings --units m --options lv_size "$ORIG_LV")
+ if [ -z "$SNAPSIZE" ]; then
+ SNAPSIZE=$(lvm lvs --noheadings --units m --options lv_size "$ORIG_LV")
info "No LVM snapshot size provided, using size of $ORIG_LV ($SNAPSIZE)"
fi
info "Creating LVM snapshot $SNAP_LV ($SNAPSIZE)"
- lvm lvcreate -s -n "$SNAP_LV" -L "$SNAPSIZE" "$ORIG_LV" 2>&1| vinfo
+ lvm lvcreate -s -n "$SNAP_LV" -L "$SNAPSIZE" "$ORIG_LV" 2>&1 | vinfo
fi
-if [ -n "$LVS" ] ; then
+if [ -n "$LVS" ]; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
lvm lvscan $lvm_ignorelockingfailure 2>&1 | vinfo
for LV in $LVS; do
for dev in "${!host_fs_types[@]}"; do
[ -e /sys/block/${dev#/dev/}/dm/name ] || 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
- dev=$(</sys/block/${dev#/dev/}/dm/name)
- eval $(dmsetup splitname --nameprefixes --noheadings --rows "$dev" 2>/dev/null)
+ dev=$(< /sys/block/${dev#/dev/}/dm/name)
+ eval $(dmsetup splitname --nameprefixes --noheadings --rows "$dev" 2> /dev/null)
[[ ${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} "
_activated["${DM_VG_NAME}/${DM_LV_NAME}"]=1
fi
if [[ -f $dracutsysrootdir/etc/lvm/lvmlocal.conf ]]; then
inst_simple -H /etc/lvm/lvmlocal.conf
fi
- eval $(lvm dumpconfig global/system_id_source &>/dev/null)
+ eval $(lvm dumpconfig global/system_id_source &> /dev/null)
if [ "$system_id_source" == "file" ]; then
eval $(lvm dumpconfig global/system_id_file)
if [ -f "$system_id_file" ]; then
inst_libdir_file "libdevmapper-event-lvm*.so"
- if [[ $hostonly ]] && find_binary lvs &>/dev/null; then
+ if [[ $hostonly ]] && find_binary lvs &> /dev/null; then
for dev in "${!host_fs_types[@]}"; do
[ -e /sys/block/${dev#/dev/}/dm/name ] || continue
- dev=$(</sys/block/${dev#/dev/}/dm/name)
- eval $(dmsetup splitname --nameprefixes --noheadings --rows "$dev" 2>/dev/null)
+ dev=$(< /sys/block/${dev#/dev/}/dm/name)
+ eval $(dmsetup splitname --nameprefixes --noheadings --rows "$dev" 2> /dev/null)
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || continue
- case "$(lvs --noheadings -o segtype ${DM_VG_NAME} 2>/dev/null)" in
- *thin*|*cache*|*era*)
+ case "$(lvs --noheadings -o segtype ${DM_VG_NAME} 2> /dev/null)" in
+ *thin* | *cache* | *era*)
inst_multiple -o thin_dump thin_restore thin_check thin_repair \
- cache_dump cache_restore cache_check cache_repair \
- era_check era_dump era_invalidate era_restore
- break;;
+ cache_dump cache_restore cache_check cache_repair \
+ era_check era_dump era_invalidate era_restore
+ break
+ ;;
esac
done
fi
if ! [[ $hostonly ]]; then
inst_multiple -o thin_dump thin_restore thin_check thin_repair \
- cache_dump cache_restore cache_check cache_repair \
- era_check era_dump era_invalidate era_restore
+ cache_dump cache_restore cache_check cache_repair \
+ era_check era_dump era_invalidate era_restore
fi
dracut_need_initqueue
LV_DEVS="$(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=)"
if ! getargbool 1 rd.lvm -d -n rd_NO_LVM \
- || ( [ -z "$LV_DEVS" ] && ! getargbool 0 rd.auto ); then
+ || ([ -z "$LV_DEVS" ] && ! getargbool 0 rd.auto); then
info "rd.lvm=0: removing LVM activation"
rm -f -- /etc/udev/rules.d/64-lvm*.rules
else
wait_for_dev -n "/dev/$dev"
done
fi
-
local ret
local final=$1
info "Waiting for mdraid devices to be clean."
- mdadm -vv --wait-clean --scan| vinfo
+ mdadm -vv --wait-clean --scan | vinfo
ret=$?
info "Disassembling mdraid devices."
mdadm -vv --stop --scan | vinfo
- ret=$(($ret+$?))
+ ret=$(($ret + $?))
if [ "x$final" != "x" ]; then
info "/proc/mdstat:"
vinfo < /proc/mdstat
return $ret
}
-if command -v mdadm >/dev/null; then
+if command -v mdadm > /dev/null; then
_do_md_shutdown $1
else
:
return $ret
}
-if command -v mdmon >/dev/null; then
+if command -v mdmon > /dev/null; then
_do_mdmon_takeover $1
fi
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
containers=""
for md in /dev/md[0-9_]*; do
containers="$containers $md"
continue
fi
- mdadm -S "$md" >/dev/null 2>&1
+ mdadm -S "$md" > /dev/null 2>&1
done
for md in $containers; do
- mdadm -S "$md" >/dev/null 2>&1
+ mdadm -S "$md" > /dev/null 2>&1
done
unset containers udevinfo
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
#!/bin/sh
if getargbool 0 rd.md.waitclean; then
- type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+ type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
containers=""
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
continue
fi
info "Waiting for $md to become clean"
- mdadm -W "$md" >/dev/null 2>&1
+ mdadm -W "$md" > /dev/null 2>&1
done
for md in $containers; do
info "Waiting for $md to become clean"
- mdadm -W "$md" >/dev/null 2>&1
+ mdadm -W "$md" > /dev/null 2>&1
done
unset containers udevinfo
#!/bin/sh
-type getargs >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getargs > /dev/null 2>&1 || . /lib/dracut-lib.sh
_md_start() {
local _udevinfo
_UUID=$(
/sbin/mdadm -D --export "$_md" \
| while read -r line || [ -n "$line" ]; do
- str_starts "$line" "MD_UUID=" || continue
- printf "%s" "${line#MD_UUID=}"
- done
- )
+ str_starts "$line" "MD_UUID=" || continue
+ printf "%s" "${line#MD_UUID=}"
+ done
+ )
[ -z "$_UUID" ] && continue
_UUID=$(str_replace "$_UUID" ":" "")
UUID=$(
/sbin/mdadm --examine --export $dev \
| while read line || [ -n "$line" ]; do
- [[ ${line#MD_UUID=} = $line ]] && continue
- printf "%s" "${line#MD_UUID=} "
- done
+ [[ ${line#MD_UUID=} = $line ]] && continue
+ printf "%s" "${line#MD_UUID=} "
+ done
)
[[ -z "$UUID" ]] && continue
prepare_udev_rules 59-persistent-storage-md.rules
# guard against pre-3.0 mdadm versions, that can't handle containers
- if ! mdadm -Q -e imsm /dev/null >/dev/null 2>&1; then
+ if ! mdadm -Q -e imsm /dev/null > /dev/null 2>&1; then
inst_hook pre-trigger 30 "$moddir/md-noimsm.sh"
fi
- if ! mdadm -Q -e ddf /dev/null >/dev/null 2>&1; then
+ if ! mdadm -Q -e ddf /dev/null > /dev/null 2>&1; then
inst_hook pre-trigger 30 "$moddir/md-noddf.sh"
fi
MD_UUID=$(str_replace "$MD_UUID" "-" "")
MD_UUID=$(str_replace "$MD_UUID" ":" "")
-if ( ! [ -n "$MD_UUID" ] && ! getargbool 0 rd.auto ) || ! getargbool 1 rd.md -d -n rd_NO_MD; then
+if (! [ -n "$MD_UUID" ] && ! getargbool 0 rd.auto) || ! getargbool 1 rd.md -d -n rd_NO_MD; then
info "rd.md=0: removing MD RAID activation"
udevproperty rd_NO_MD=1
else
if [ "${line%%UUID CHECK}" != "$line" ]; then
for uuid in $MD_UUID; do
printf 'ENV{ID_FS_UUID}=="%s", GOTO="md_uuid_ok"\n' "$(expr substr $uuid 1 8)-$(expr substr $uuid 9 4)-$(expr substr $uuid 13 4)-$(expr substr $uuid 17 4)-$(expr substr $uuid 21 12)"
- done;
+ done
printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
for uuid in $MD_UUID; do
printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' "$(expr substr $uuid 1 8):$(expr substr $uuid 9 8):$(expr substr $uuid 17 8):$(expr substr $uuid 25 8)"
- done;
+ done
printf 'GOTO="md_end"\n'
printf 'LABEL="md_uuid_ok"\n'
else
fi
fi
-
if [ -e /etc/mdadm.conf ] && getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
udevproperty rd_MDADMCONF=1
rm -f -- $hookdir/pre-pivot/*mdraid-cleanup.sh
if ! getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
rm -f -- /etc/mdadm/mdadm.conf /etc/mdadm.conf
- ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
+ ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2> /dev/null
fi
# noiswmd nodmraid for anaconda / rc.sysinit compatibility
# called by dracut
cmdline() {
for m in scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm_multipath; do
- if grep -m 1 -q "$m" /proc/modules ; then
+ if grep -m 1 -q "$m" /proc/modules; then
printf 'rd.driver.pre=%s ' "$m"
fi
done
}
}
- inst_multiple -o \
+ inst_multiple -o \
dmsetup \
kpartx \
mpath_wait \
mpathconf \
mpathpersist \
- multipath \
+ multipath \
multipathd \
xdrgetprio \
xdrgetuid \
inst_libdir_file "libmultipath*" "multipath/*"
inst_libdir_file 'libgcc_s.so*'
- if [[ $hostonly_cmdline ]] ; then
+ if [[ $hostonly_cmdline ]]; then
local _conf=$(cmdline)
[[ $_conf ]] && echo "$_conf" >> "${initdir}/etc/cmdline.d/90multipath.conf"
fi
$SYSTEMCTL -q --root "$initdir" enable multipathd.service
else
inst_hook pre-trigger 02 "$moddir/multipathd.sh"
- inst_hook cleanup 02 "$moddir/multipathd-stop.sh"
+ inst_hook cleanup 02 "$moddir/multipathd-stop.sh"
fi
- inst_hook cleanup 80 "$moddir/multipathd-needshutdown.sh"
- inst_hook shutdown 20 "$moddir/multipath-shutdown.sh"
+ inst_hook cleanup 80 "$moddir/multipathd-needshutdown.sh"
+ inst_hook shutdown 20 "$moddir/multipath-shutdown.sh"
inst_rules 40-multipath.rules 56-multipath.rules \
- 62-multipath.rules 65-multipath.rules \
- 66-kpartx.rules 67-kpartx-compat.rules \
- 11-dm-mpath.rules 11-dm-parts.rules
+ 62-multipath.rules 65-multipath.rules \
+ 66-kpartx.rules 67-kpartx-compat.rules \
+ 11-dm-mpath.rules 11-dm-parts.rules
}
-
#!/bin/sh
for i in $(multipath -l -v1); do
- if ! dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1' ; then
+ if ! dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1'; then
dmsetup message $i 0 fail_if_no_path
fi
done
#!/bin/sh
for i in $(multipath -l -v1); do
- if $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1') ; then
+ if $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1'); then
need_shutdown
break
fi
if [ -e /etc/multipath.conf ]; then
HARD=""
- while pidof multipathd >/dev/null 2>&1; do
+ while pidof multipathd > /dev/null 2>&1; do
for pid in $(pidof multipathd); do
- kill $HARD $pid >/dev/null 2>&1
+ kill $HARD $pid > /dev/null 2>&1
done
HARD="-9"
done
fi
-
multipathd -B || multipathd
need_shutdown
else
- rm -- /etc/udev/rules.d/??-multipath.rules 2>/dev/null
+ rm -- /etc/udev/rules.d/??-multipath.rules 2> /dev/null
fi
-
if [[ ! $hostonly ]]; then
return 0
fi
- [[ $DRACUT_KERNEL_MODALIASES && -f "$DRACUT_KERNEL_MODALIASES" ]] && \
- grep -q libnvdimm "$DRACUT_KERNEL_MODALIASES" && return 0
+ [[ $DRACUT_KERNEL_MODALIASES && -f "$DRACUT_KERNEL_MODALIASES" ]] \
+ && grep -q libnvdimm "$DRACUT_KERNEL_MODALIASES" && return 0
return 255
}
# this way if the modules are for some reason missing, it will
# still exit successfully and not affect the boot process
case "$pm_model" in
- PowerMac3,6) modprobe -b -q therm_windtunnel ;;
- PowerMac7,2|PowerMac7,3) modprobe -b -q windfarm_pm72 ;;
- PowerMac8,1|PowerMac8,2) modprobe -b -q windfarm_pm81 ;;
- PowerMac9,1) modprobe -b -q windfarm_pm91 ;;
- PowerMac11,2) modprobe -b -q windfarm_pm112 ;;
- PowerMac12,1) modprobe -b -q windfarm_pm121 ;;
- RackMac3,1) modprobe -b -q windfarm_rm31 ;;
+ PowerMac3,6) modprobe -b -q therm_windtunnel ;;
+ PowerMac7,2 | PowerMac7,3) modprobe -b -q windfarm_pm72 ;;
+ PowerMac8,1 | PowerMac8,2) modprobe -b -q windfarm_pm81 ;;
+ PowerMac9,1) modprobe -b -q windfarm_pm91 ;;
+ PowerMac11,2) modprobe -b -q windfarm_pm112 ;;
+ PowerMac12,1) modprobe -b -q windfarm_pm121 ;;
+ RackMac3,1) modprobe -b -q windfarm_rm31 ;;
*) ;;
esac
else
# guess model specific module, then install the rest
case "$(pmac_model)" in
- PowerMac7,2|PowerMac7,3) instmods windfarm_pm72 ;;
- PowerMac8,1|PowerMac8,2) instmods windfarm_pm81 ;;
- PowerMac9,1) instmods windfarm_pm91 ;;
- PowerMac11,2) instmods windfarm_pm112 ;;
- PowerMac12,1) instmods windfarm_pm121 ;;
- RackMac3,1) instmods windfarm_rm31 ;;
+ PowerMac7,2 | PowerMac7,3) instmods windfarm_pm72 ;;
+ PowerMac8,1 | PowerMac8,2) instmods windfarm_pm81 ;;
+ PowerMac9,1) instmods windfarm_pm91 ;;
+ PowerMac11,2) instmods windfarm_pm112 ;;
+ PowerMac12,1) instmods windfarm_pm121 ;;
+ RackMac3,1) instmods windfarm_rm31 ;;
# no match, so skip installation of the rest
*) return 1 ;;
esac
# called by dracut
install() {
- # this will attempt to load the appropriate modules
+ # this will attempt to load the appropriate modules
inst_hook pre-udev 99 "$moddir/load-thermal.sh"
}
installkernel() {
# qemu specific modules
hostonly='' instmods \
- ata_piix ata_generic pata_acpi cdrom sr_mod ahci \
- virtio_blk virtio virtio_ring virtio_pci \
- virtio_scsi virtio_console virtio_rng \
- spapr-vscsi \
- qemu_fw_cfg
+ ata_piix ata_generic pata_acpi cdrom sr_mod ahci \
+ virtio_blk virtio virtio_ring virtio_pci \
+ virtio_scsi virtio_console virtio_rng \
+ spapr-vscsi \
+ qemu_fw_cfg
}
#!/bin/sh
-command -v ask_for_password >/dev/null || . /lib/dracut-crypt-lib.sh
+command -v ask_for_password > /dev/null || . /lib/dracut-crypt-lib.sh
# gpg_decrypt mnt_point keypath keydev device
#
local gpgMinorVersion="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')"
if [ "${gpgMajorVersion}" -ge 2 ] && [ "${gpgMinorVersion}" -ge 1 ] \
- && [ -f /root/crypt-public-key.gpg ] && getargbool 1 rd.luks.smartcard ; then
+ && [ -f /root/crypt-public-key.gpg ] && getargbool 1 rd.luks.smartcard; then
useSmartcard="1"
echo "allow-loopback-pinentry" >> "$gpghome/gpg-agent.conf"
GNUPGHOME="$gpghome" gpg-agent --quiet --daemon
if [ -n "${smartcardSerialNumber}" ]; then
inputPrompt="PIN (OpenPGP card ${smartcardSerialNumber})"
fi
- GNUPGHOME="$gpghome" gpg-connect-agent 1>/dev/null learn /bye
+ GNUPGHOME="$gpghome" gpg-connect-agent 1> /dev/null learn /bye
opts="$opts --pinentry-mode=loopback"
fi
# Clean up the smartcard gpg-agent
if [ "${useSmartcard}" = "1" ]; then
- GNUPGHOME="$gpghome" gpg-connect-agent 1>/dev/null killagent /bye
+ GNUPGHOME="$gpghome" gpg-connect-agent 1> /dev/null killagent /bye
fi
rm -rf -- "$gpghome"
sc_supported() {
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')"
- if [[ "${gpgMajor}" -gt 2 || "${gpgMajor}" -eq 2 && "${gpgMinor}" -ge 1 ]] && \
- require_binaries gpg-agent &&
- require_binaries gpg-connect-agent &&
- require_binaries /usr/libexec/scdaemon &&
- ($DRACUT_LDD "$dracutsysrootdir"/usr/libexec/scdaemon | grep libusb > /dev/null); then
+ if [[ "${gpgMajor}" -gt 2 || "${gpgMajor}" -eq 2 && "${gpgMinor}" -ge 1 ]] \
+ && require_binaries gpg-agent \
+ && require_binaries gpg-connect-agent \
+ && require_binaries /usr/libexec/scdaemon \
+ && ($DRACUT_LDD "$dracutsysrootdir"/usr/libexec/scdaemon | grep libusb > /dev/null); then
return 0
else
return 1
#!/bin/sh
-command -v ask_for_password >/dev/null || . /lib/dracut-crypt-lib.sh
+command -v ask_for_password > /dev/null || . /lib/dracut-crypt-lib.sh
# loop_decrypt mnt_point keypath keydev device
#
DEV="$1"
MNT=/boot/zipl
-if [ -z "$DEV" ] ; then
+if [ -z "$DEV" ]; then
echo "No IPL device given"
> /tmp/install.zipl.cmdline-done
exit 1
[ -d ${MNT} ] || mkdir -p ${MNT}
mount -o ro ${DEV} ${MNT}
-if [ "$?" != "0" ] ; then
+if [ "$?" != "0" ]; then
echo "Failed to mount ${MNT}"
> /tmp/install.zipl.cmdline-done
exit 1
fi
-if [ -f ${MNT}/dracut-cmdline.conf ] ; then
+if [ -f ${MNT}/dracut-cmdline.conf ]; then
cp ${MNT}/dracut-cmdline.conf /etc/cmdline.d/99zipl.conf
fi
-if [ -f ${MNT}/active_devices.txt ] ; then
- while read dev etc ; do
- [ "$dev" = "#" -o "$dev" = "" ] && continue;
+if [ -f ${MNT}/active_devices.txt ]; then
+ while read dev etc; do
+ [ "$dev" = "#" -o "$dev" = "" ] && continue
cio_ignore -r $dev
done < ${MNT}/active_devices.txt
fi
umount ${MNT}
-if [ -f /etc/cmdline.d/99zipl.conf ] ; then
+if [ -f /etc/cmdline.d/99zipl.conf ]; then
systemctl restart dracut-cmdline.service
systemctl restart systemd-udev-trigger.service
fi
local _boot_zipl
_boot_zipl=$(sed -n -e '/^[[:space:]]*#/d' -e 's/\(.*\)\w*\/boot\/zipl.*/\1/p' /etc/fstab)
- if [ -n "$_boot_zipl" ] ; then
+ if [ -n "$_boot_zipl" ]; then
eval $(blkid -s TYPE -o udev ${_boot_zipl})
- if [ -n "$ID_FS_TYPE" ] ; then
+ if [ -n "$ID_FS_TYPE" ]; then
case "$ID_FS_TYPE" in
ext?)
ID_FS_TYPE=ext4
local _boot_zipl
_boot_zipl=$(sed -n -e '/^[[:space:]]*#/d' -e 's/\(.*\)\w*\/boot\/zipl.*/\1/p' /etc/fstab)
- if [ -n "$_boot_zipl" ] ; then
+ if [ -n "$_boot_zipl" ]; then
echo "rd.zipl=${_boot_zipl}"
fi
}
inst_hook cmdline 91 "$moddir/parse-zipl.sh"
inst_script "${moddir}/install_zipl_cmdline.sh" /sbin/install_zipl_cmdline.sh
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _zipl=$(cmdline)
[[ $_zipl ]] && printf "%s\n" "$_zipl" > "${initdir}/etc/cmdline.d/91zipl.conf"
zipl_arg=$(getarg rd.zipl)
-if [ -n "$zipl_arg" ] ; then
+if [ -n "$zipl_arg" ]; then
case "$zipl_arg" in
- LABEL=*) \
- zipl_env="ENV{ID_FS_LABEL}"
- zipl_val=${zipl_arg#LABEL=}
- zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
- ;;
- UUID=*) \
- zipl_env="ENV{ID_FS_UUID}"
- zipl_val=${zipl_arg#UUID=}
- zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
- ;;
- PARTLABEL=*) \
- zipl_env="ENV{ID_FS_PARTLABEL}"
- zipl_val=${zipl_arg#PARTLABEL=}
- zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
- ;;
- PARTUUID=*) \
- zipl_env="ENV{ID_FS_PARTUUID}"
- zipl_val=${zipl_arg#PARTUUID=}
- zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
- ;;
- /dev/mapper/*) \
- zipl_env="ENV{DM_NAME}"
- zipl_val=${zipl_arg#/dev/mapper/}
- ;;
- /dev/disk/by-*) \
- zipl_env="SYMLINK"
- zipl_val=${zipl_arg#/dev/}
- ;;
- /dev/*) \
- zipl_env="KERNEL"
- zipl_val=${zipl_arg}
- ;;
+ LABEL=*)
+ zipl_env="ENV{ID_FS_LABEL}"
+ zipl_val=${zipl_arg#LABEL=}
+ zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
+ ;;
+ UUID=*)
+ zipl_env="ENV{ID_FS_UUID}"
+ zipl_val=${zipl_arg#UUID=}
+ zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
+ ;;
+ PARTLABEL=*)
+ zipl_env="ENV{ID_FS_PARTLABEL}"
+ zipl_val=${zipl_arg#PARTLABEL=}
+ zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
+ ;;
+ PARTUUID=*)
+ zipl_env="ENV{ID_FS_PARTUUID}"
+ zipl_val=${zipl_arg#PARTUUID=}
+ zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
+ ;;
+ /dev/mapper/*)
+ zipl_env="ENV{DM_NAME}"
+ zipl_val=${zipl_arg#/dev/mapper/}
+ ;;
+ /dev/disk/by-*)
+ zipl_env="SYMLINK"
+ zipl_val=${zipl_arg#/dev/}
+ ;;
+ /dev/*)
+ zipl_env="KERNEL"
+ zipl_val=${zipl_arg}
+ ;;
esac
- if [ "$zipl_env" ] ; then
+ if [ "$zipl_env" ]; then
{
printf 'ACTION=="add|change", SUBSYSTEM=="block", %s=="%s", ENV{SYSTEMD_READY}!="0", RUN+="/sbin/initqueue --settled --onetime --unique --name install_zipl_cmdline /sbin/install_zipl_cmdline.sh %s"\n' \
${zipl_env} ${zipl_val} ${zipl_arg}
- echo "[ -f /tmp/install.zipl.cmdline-done ]" >$hookdir/initqueue/finished/wait-zipl-conf.sh
+ echo "[ -f /tmp/install.zipl.cmdline-done ]" > $hookdir/initqueue/finished/wait-zipl-conf.sh
} >> /etc/udev/rules.d/99zipl-conf.rules
cat /etc/udev/rules.d/99zipl-conf.rules
fi
# CIFSROOT is something like: cifs://[<username>[:<password>]]@<host>/<path>
# NETIF is used to get information from DHCP options, if needed.
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
cifs_to_var() {
- local cifsuser; local cifspass
+ local cifsuser
+ local cifspass
# Check required arguments
server=${1##cifs://}
cifsuser=${server%@*}
cifspass=${cifsuser#*:}
if [ "$cifspass" != "$cifsuser" ]; then
- cifsuser=${cifsuser%:*}
+ cifsuser=${cifsuser%:*}
else
- cifspass=$(getarg cifspass)
+ cifspass=$(getarg cifspass)
fi
if [ "$cifsuser" != "$server" ]; then
- server="${server#*@}"
+ server="${server#*@}"
else
- cifsuser=$(getarg cifsuser)
+ cifsuser=$(getarg cifsuser)
fi
path=${server#*/}
server=${server%/*}
if [ ! "$cifsuser" -o ! "$cifspass" ]; then
- die "For CIFS support you need to specify a cifsuser and cifspass either in the cifsuser and cifspass commandline parameters or in the root= CIFS URL."
+ die "For CIFS support you need to specify a cifsuser and cifspass either in the cifsuser and cifspass commandline parameters or in the root= CIFS URL."
fi
options="user=$cifsuser,pass=$cifspass,$(getarg rootflags=)"
}
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/cifs-lib.sh
[ "$#" = 3 ] || exit 1
cifs_to_var "$root"
# shellcheck disable=SC2154
-mount.cifs "//$server/$path" "$NEWROOT" -o "$options" && { [ -e /dev/root ] || ln -s null /dev/root ; }
+mount.cifs "//$server/$path" "$NEWROOT" -o "$options" && { [ -e /dev/root ] || ln -s null /dev/root; }
# inject new exit_if_exists
# shellcheck disable=SC2016
inst_libdir_file 'libcap-ng.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' "$dracutsysrootdir"/etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
# respectively.
#
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/cifs-lib.sh
# This script is sourced, so root should be set. But let's be paranoid
fi
# Root takes precedence over netroot
-if [ "${root%%:*}" = "cifs" ] ; then
- if [ -n "$netroot" ] ; then
+if [ "${root%%:*}" = "cifs" ]; then
+ if [ -n "$netroot" ]; then
warn "root takes precedence over netroot. Ignoring netroot"
fi
netroot=$root
cifs_to_var $netroot
# If we don't have a server, we need dhcp
-if [ -z "$server" ] ; then
+if [ -z "$server" ]; then
DHCPORSERVER="1"
-fi;
+fi
# Done, all good!
rootok=1
inst_hook cmdline 30 "$moddir/parse-dasd.sh"
inst_multiple dasdinfo dasdconf.sh normalize_dasd_arg
conf=/etc/dasd.conf
- if [[ $hostonly && -f $conf ]] ; then
+ if [[ $hostonly && -f $conf ]]; then
inst -H $conf
fi
inst_rules 56-dasd.rules
inst_rules 59-dasd.rules
}
-
inst_multiple grep sed seq
inst_multiple -o dasd_cio_free
}
-
fi
unset dasd_arg
-if [ -x /sbin/dasd_cio_free ] ; then
+if [ -x /sbin/dasd_cio_free ]; then
dasd_cio_free
fi
cmdline() {
is_dasd() {
local _dev=$1
- local _devpath=$(cd -P /sys/dev/block/$_dev ; echo $PWD)
+ local _devpath=$(
+ cd -P /sys/dev/block/$_dev
+ echo $PWD
+ )
[ "${_devpath#*/dasd}" == "$_devpath" ] && return 1
_ccw="${_devpath%%/block/*}"
require_binaries /usr/lib/udev/collect || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
- for bdev in /sys/block/* ; do
+ for bdev in /sys/block/*; do
case "${bdev##*/}" in
dasd*)
- found=$(($found+1));
- break;
+ found=$(($found + 1))
+ break
+ ;;
esac
done
[ $found -eq 0 ] && return 255
install() {
inst_multiple /usr/lib/udev/collect
inst_hook cmdline 30 "$moddir/parse-dasd.sh"
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _dasd=$(cmdline)
[[ $_dasd ]] && printf "%s\n" "$_dasd" >> "${initdir}/etc/cmdline.d/95dasd.conf"
fi
- if [[ $hostonly ]] ; then
+ if [[ $hostonly ]]; then
inst_rules_wildcard 51-dasd-*.rules
inst_rules_wildcard 41-s390x-dasd-*.rules
mark_hostonly /etc/udev/rules.d/51-dasd-*.rules
local _drv _cu_type _dev_type
local _rule=/etc/udev/rules.d/51-dasd-${ccw}.rules
- if [ -x /sbin/cio_ignore ] && cio_ignore -i $ccw > /dev/null ; then
+ if [ -x /sbin/cio_ignore ] && cio_ignore -i $ccw > /dev/null; then
cio_ignore -r $ccw
fi
- if [ -e /sys/bus/ccw/devices/${ccw} ] ; then
+ if [ -e /sys/bus/ccw/devices/${ccw} ]; then
read _cu_type < /sys/bus/ccw/devices/${ccw}/cutype
read _dev_type < /sys/bus/ccw/devices/${ccw}/devtype
fi
case "$_cu_type" in
- 3990/*|2105/*|2107/*|1750/*|9343/*)
+ 3990/* | 2105/* | 2107/* | 1750/* | 9343/*)
_drv=dasd-eckd
;;
- 6310/*)
+ 6310/*)
_drv=dasd-fba
;;
- 3880/*)
- case "$_dev_type" in
- 3380/*)
- _drv=dasd_eckd
- ;;
- 3370/*)
- _drv=dasd-fba
- ;;
- esac
- ;;
+ 3880/*)
+ case "$_dev_type" in
+ 3380/*)
+ _drv=dasd_eckd
+ ;;
+ 3370/*)
+ _drv=dasd-fba
+ ;;
+ esac
+ ;;
esac
[ -z "${_drv}" ] && return 0
[ -e ${_rule} ] && return 0
- cat > $_rule <<EOF
+ cat > $_rule << EOF
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$ccw", IMPORT{program}="collect $ccw %k ${ccw} $_drv"
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="$_drv", IMPORT{program}="collect $ccw %k ${ccw} $_drv"
ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1"
EOF
}
-if [[ -f /sys/firmware/ipl/ipl_type &&
- $(</sys/firmware/ipl/ipl_type) = "ccw" ]] ; then
+if [[ -f /sys/firmware/ipl/ipl_type && \
+ $(< /sys/firmware/ipl/ipl_type) = "ccw" ]]; then
(
_ccw=$(cat /sys/firmware/ipl/device)
ccw_arg=${dasd_arg##*/}
;;
esac
- if [ -n "$ccw_arg" ] ; then
+ if [ -n "$ccw_arg" ]; then
OLDIFS="$IFS"
IFS="-"
set -- $ccw_arg
IFS="$OLDIFS"
while (($# > 0)); do
case $1 in
- autodetect|probeonly)
+ autodetect | probeonly)
shift
;;
*-*)
end=${1##.}
shift
IFS="$OLDIFS"
- for dev in $(seq $(( 16#$start )) $(( 16#$end )) ) ; do
+ for dev in $(seq $((16#$start)) $((16#$end))); do
create_udev_rule "$(printf "%s.%04x" "$prefix" "$dev")"
done
;;
*)
dev=${1%(ro)}
- if [ "$dev" != "$1" ] ; then
+ if [ "$dev" != "$1" ]; then
ro=1
fi
OLDIFS="$IFS"
shift
chan=$1
IFS="$OLDIFS"
- create_udev_rule "$(printf "%01x.%01x.%04x" $(( 16#$sid )) $(( 16#$ssid )) $(( 16#$chan )) )"
+ create_udev_rule "$(printf "%01x.%01x.%04x" $((16#$sid)) $((16#$ssid)) $((16#$chan)))"
shift
;;
esac
# called by dracut
installkernel() {
if [[ $hostonly ]]; then
- for dev in /sys/devices/dcssblk/*/block/dcssblk* ; do
+ for dev in /sys/devices/dcssblk/*/block/dcssblk*; do
[[ -e $dev ]] || continue
hostonly='' instmods dcssblk
return $?
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
dcssblk_arg=$(getarg rd.dcssblk=)
-if [ $? = 0 ];then
- info "Loading dcssblk segments=$dcssblk_arg"
- modprobe dcssblk segments=$dcssblk_arg
+if [ $? = 0 ]; then
+ info "Loading dcssblk segments=$dcssblk_arg"
+ modprobe dcssblk segments=$dcssblk_arg
fi
# called by dracut
install() {
inst_multiple -o ls ps grep more cat rm strace free showmount df du lsblk \
- ping netstat rpcinfo vi scp ping6 ssh find \
- tcpdump cp dd less hostname mkdir systemd-analyze \
- fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck
+ ping netstat rpcinfo vi scp ping6 ssh find \
+ tcpdump cp dd less hostname mkdir systemd-analyze \
+ fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck
- grep '^tcpdump:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
+ grep '^tcpdump:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
}
-
#!/bin/bash
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
-command -v get_fcoe_boot_mac >/dev/null || . /lib/uefi-lib.sh
-command -v set_ifname >/dev/null || . /lib/net-lib.sh
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
+command -v get_fcoe_boot_mac > /dev/null || . /lib/uefi-lib.sh
+command -v set_ifname > /dev/null || . /lib/net-lib.sh
-print_fcoe_uefi_conf()
-{
+print_fcoe_uefi_conf() {
local mac dev vlan
mac=$(get_fcoe_boot_mac "$1")
[ -z "$mac" ] && return 1
dev=$(set_ifname fcoe $mac)
- vlan=$(get_fcoe_boot_vlan "$1")
+ vlan=$(get_fcoe_boot_vlan "$1")
if [ "$vlan" -ne "0" ]; then
case "$vlan" in
[0-9]*)
while [ $cnt -lt 600 ]; do
[ -d /sys/firmware/edd ] && return 0
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
sleep 0.1
done
return 1
for disk in /sys/firmware/edd/int13_*; do
[ -d "$disk" ] || continue
if [ -e "${disk}/pci_dev/driver" ]; then
- driver=$(readlink "${disk}/pci_dev/driver")
- driver=${driver##*/}
+ driver=$(readlink "${disk}/pci_dev/driver")
+ driver=${driver##*/}
fi
# i40e uses dev_port 1 for a virtual fcoe function
if [ "${driver}" = "i40e" ]; then
- dev_port=1
+ dev_port=1
fi
for nic in "${disk}"/pci_dev/net/*; do
[ -d "$nic" ] || continue
- if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then
- if [ "$(cat ${nic}/dev_port)" -ne "${dev_port}" ]; then
- continue
- fi
- fi
+ if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then
+ if [ "$(cat ${nic}/dev_port)" -ne "${dev_port}" ]; then
+ continue
+ fi
+ fi
if [ -e ${nic}/address ]; then
- fcoe_interface=${nic##*/}
- if ! [ -e "/tmp/.fcoe-$fcoe_interface" ]; then
- /sbin/fcoe-up "$fcoe_interface" "$dcb"
- > "/tmp/.fcoe-$fcoe_interface"
- fi
+ fcoe_interface=${nic##*/}
+ if ! [ -e "/tmp/.fcoe-$fcoe_interface" ]; then
+ /sbin/fcoe-up "$fcoe_interface" "$dcb"
+ > "/tmp/.fcoe-$fcoe_interface"
+ fi
fi
done
done
# Write udev rules
{
- if [ -n "$fcoe_mac" ] ; then
+ if [ -n "$fcoe_mac" ]; then
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$name /sbin/fcoe-up $name %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$name /sbin/fcoe-up $name %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
else
# future use.
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh
# Huh? Missing arguments ??
[ -z "$1" -o -z "$2" ] && exit 1
iflink=$(cat /sys/class/net/$netif/iflink)
ifindex=$(cat /sys/class/net/$netif/ifindex)
-if [ "$iflink" != "$ifindex" ] ; then
+if [ "$iflink" != "$ifindex" ]; then
# Skip VLAN devices
exit 0
fi
# Some fcoemon implementations expect --syslog=true
syslogopt="--syslog"
-if fcoemon -h|grep syslog|grep -q yes; then
+if fcoemon -h | grep syslog | grep -q yes; then
fcoemonyes="$syslogopt=yes"
fi
-
netdriver=$(readlink -f /sys/class/net/$netif/device/driver)
netdriver=${netdriver##*/}
echo DCB_REQUIRED=\"no\" >> /etc/fcoe/cfg-$netif
fi
if [ "$vlan" = "yes" ]; then
- echo AUTO_VLAN=\"yes\" >> /etc/fcoe/cfg-$netif
+ echo AUTO_VLAN=\"yes\" >> /etc/fcoe/cfg-$netif
else
- echo AUTO_VLAN=\"no\" >> /etc/fcoe/cfg-$netif
+ echo AUTO_VLAN=\"no\" >> /etc/fcoe/cfg-$netif
fi
- if [ "$mode" = "vn2vn" ] ; then
+ if [ "$mode" = "vn2vn" ]; then
echo MODE=\"vn2vn\" >> /etc/fcoe/cfg-$netif
else
echo MODE=\"fabric\" >> /etc/fcoe/cfg-$netif
lldptool -p && break
info "Waiting for lldpad to be ready"
sleep 1
- i=$(($i+1))
+ i=$(($i + 1))
done
while [ $i -lt 60 ]; do
dcbtool sc "$netif" dcb on && break
info "Retrying to turn dcb on"
sleep 1
- i=$(($i+1))
+ i=$(($i + 1))
done
while [ $i -lt 60 ]; do
dcbtool sc "$netif" pfc e:1 a:1 w:1 && break
info "Retrying to turn dcb on"
sleep 1
- i=$(($i+1))
+ i=$(($i + 1))
done
while [ $i -lt 60 ]; do
dcbtool sc "$netif" app:fcoe e:1 a:1 w:1 && break
info "Retrying to turn fcoe on"
sleep 1
- i=$(($i+1))
+ i=$(($i + 1))
done
sleep 1
#!/bin/bash
-if ! getargbool 1 rd.fcoe -d -n rd.nofcoe ; then
- info "rd.fcoe=0: skipping lldpad activation"
- return 0
+if ! getargbool 1 rd.fcoe -d -n rd.nofcoe; then
+ info "rd.fcoe=0: skipping lldpad activation"
+ return 0
fi
# Note lldpad will stay running after switchroot, the system initscripts
lldptool -p && break
info "Waiting for lldpad to be ready"
sleep 1
- i=$(($i+1))
+ i=$(($i + 1))
done
[ -d $link ] || return
read iflink < $link/iflink
- for if in /sys/class/net/* ; do
- read idx < $if/ifindex
- if [ $idx -eq $iflink ] ; then
- echo ${if##*/}
- fi
+ for if in /sys/class/net/*; do
+ read idx < $if/ifindex
+ if [ $idx -eq $iflink ]; then
+ echo ${if##*/}
+ fi
done
}
# called by dracut
cmdline() {
{
- for c in /sys/bus/fcoe/devices/ctlr_* ; do
+ for c in /sys/bus/fcoe/devices/ctlr_*; do
[ -L $c ] || continue
read enabled < $c/enabled
read mode < $c/mode
[ $enabled -eq 0 ] && continue
- if [ $mode = "VN2VN" ] ; then
+ if [ $mode = "VN2VN" ]; then
mode="vn2vn"
else
mode="fabric"
fi
- d=$(cd -P $c; echo $PWD)
+ d=$(
+ cd -P $c
+ echo $PWD
+ )
i=${d%/*}
ifname=${i##*/}
read mac < ${i}/address
- s=$(dcbtool gc ${i##*/} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
- if [ -z "$s" ] ; then
- p=$(get_vlan_parent ${i})
- if [ "$p" ] ; then
- s=$(dcbtool gc ${p} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
+ s=$(dcbtool gc ${i##*/} dcb 2> /dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
+ if [ -z "$s" ]; then
+ p=$(get_vlan_parent ${i})
+ if [ "$p" ]; then
+ s=$(dcbtool gc ${p} dcb 2> /dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
ifname=${p##*/}
- fi
+ fi
fi
- if [ "$s" = "on" ] ; then
- dcb="dcb"
+ if [ "$s" = "on" ]; then
+ dcb="dcb"
else
- dcb="nodcb"
+ dcb="nodcb"
fi
# Some Combined Network Adapters(CNAs) implement DCB in firmware.
# 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).
- 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"
- if [ "$p" ] ; then
- grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null
+ if [ "$p" ]; then
+ grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &> /dev/null
[ $? -eq 0 ] && dcb="nodcb"
fi
mkdir -m 0755 -p "$initdir/var/lib/lldpad"
mkdir -m 0755 -p "$initdir/etc/fcoe"
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _fcoeconf=$(cmdline)
[[ $_fcoeconf ]] && printf "%s\n" "$_fcoeconf" >> "${initdir}/etc/cmdline.d/95fcoe.conf"
fi
inst_hook shutdown 40 "$moddir/stop-fcoe.sh"
dracut_need_initqueue
}
-
# fcoe=eth0:nodcb:vn2vn
# fcoe=4a:3f:4c:04:f8:d7:nodcb:fabric
-if ! getargbool 1 rd.fcoe -d -n rd.nofcoe ; then
- info "rd.fcoe=0: skipping fcoe"
- return 0
+if ! getargbool 1 rd.fcoe -d -n rd.nofcoe; then
+ info "rd.fcoe=0: skipping fcoe"
+ return 0
fi
[ -z "$fcoe" ] && fcoe=$(getarg fcoe=)
parse_fcoe_opts
if [ "$fcoe_interface" = "edd" ]; then
- if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then
+ if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ]; then
warn "Invalid FCoE DCB option: $fcoe_dcb"
fi
/sbin/initqueue --settled --unique /sbin/fcoe-edd $fcoe_dcb
unset fcoe_mac
unset fcoe_interface
parse_fcoe_opts
- if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then
+ if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ]; then
warn "Invalid FCoE DCB option: $fcoe_dcb"
fi
. $(command -v fcoe-genrules.sh)
#!/bin/bash
-for f in /sys/bus/fcoe/devices/ctlr_* ; do
+for f in /sys/bus/fcoe/devices/ctlr_*; do
[ -e $f ] || continue
echo 0 > $f/enabled
done
# called by dracut
check() {
- [[ -f $dracutsysrootdir/etc/fstab.sys ]] || [[ -n $add_fstab || -n $fstab_lines ]]
+ [[ -f $dracutsysrootdir/etc/fstab.sys ]] || [[ -n $add_fstab || -n $fstab_lines ]]
}
# called by dracut
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type det_fs > /dev/null 2>&1 || . /lib/fs-lib.sh
fstab_mount() {
local _dev _mp _fs _opts _dump _pass _rest
info "Mounting from $1"
while read _dev _mp _fs _opts _dump _pass _rest || [ -n "$_dev" ]; do
[ -z "${_dev%%#*}" ] && continue # Skip comment lines
- ismounted $_mp && continue # Skip mounted filesystem
+ ismounted $_mp && continue # Skip mounted filesystem
if [ "$_pass" -gt 0 ] && ! strstr "$_opts" _netdev; then
fsck_single "$_dev" "$_fs" "$_opts"
fi
#!/bin/sh
-if [ -z "${DRACUT_SYSTEMD}" ] && { [ -e /sys/module/bnx2i ] || [ -e /sys/module/qedi ]; } ; then
- killproc iscsiuio
+if [ -z "${DRACUT_SYSTEMD}" ] && { [ -e /sys/module/bnx2i ] || [ -e /sys/module/qedi ]; }; then
+ killproc iscsiuio
fi
# iscsistart needs this.
#
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
-type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type parse_iscsi_root > /dev/null 2>&1 || . /lib/net-lib.sh
+type write_fs_tab > /dev/null 2>&1 || . /lib/fs-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# XXX modprobe crc32c should go in the cmdline parser, but I haven't yet
# figured out a way how to check whether this is built-in or not
-modprobe crc32c 2>/dev/null
+modprobe crc32c 2> /dev/null
# start iscsiuio if needed
-if [ -z "${DRACUT_SYSTEMD}" ] && \
- ( [ -e /sys/module/bnx2i ] || [ -e /sys/module/qedi ] ) && \
- ! [ -e /tmp/iscsiuio-started ]; then
- iscsiuio
- > /tmp/iscsiuio-started
+if [ -z "${DRACUT_SYSTEMD}" ] \
+ && ([ -e /sys/module/bnx2i ] || [ -e /sys/module/qedi ]) \
+ && ! [ -e /tmp/iscsiuio-started ]; then
+ iscsiuio
+ > /tmp/iscsiuio-started
fi
-
-handle_firmware()
-{
+handle_firmware() {
local ifaces retry
# Depending on the 'ql4xdisablesysfsboot' qla4xxx
if ! iscsiadm -m fw; then
warn "iscsiadm: Could not get list of targets from firmware."
else
- ifaces=$(set -- /sys/firmware/ibft/ethernet*; echo $#)
+ ifaces=$(
+ set -- /sys/firmware/ibft/ethernet*
+ echo $#
+ )
retry=$(cat /tmp/session-retry)
if [ $retry -lt $ifaces ]; then
- retry=$((retry+1))
+ retry=$((retry + 1))
echo $retry > /tmp/session-retry
return 1
else
return 0
}
-
-handle_netroot()
-{
+handle_netroot() {
local iscsi_initiator iscsi_target_name iscsi_target_ip iscsi_target_port
local iscsi_target_group iscsi_protocol iscsirw iscsi_lun
local iscsi_username iscsi_password
arg=$(getarg rd.iscsi.in.password -d iscsi_in_password=)
[ -n "$arg" ] && iscsi_in_password=$arg
for p in $(getargs rd.iscsi.param -d iscsi_param); do
- [ "${p%=*}" = node.session.initial_login_retry_max ] && \
- login_retry_max_seen=yes
- iscsi_param="$iscsi_param $p"
+ [ "${p%=*}" = node.session.initial_login_retry_max ] \
+ && login_retry_max_seen=yes
+ iscsi_param="$iscsi_param $p"
done
# this sets iscsi_target_name and possibly overwrites most
# Bail out early, if there is no route to the destination
if is_ip "$iscsi_target_ip" && [ "$netif" != "timeout" ] && ! all_ifaces_setup && getargbool 1 rd.iscsi.testroute; then
- ip route get "$iscsi_target_ip" >/dev/null 2>&1 || return 0
+ ip route get "$iscsi_target_ip" > /dev/null 2>&1 || return 0
fi
#limit iscsistart login retries
fi
fi
-# XXX is this needed?
+ # XXX is this needed?
getarg ro && iscsirw=ro
getarg rw && iscsirw=rw
fsopts=${fsopts:+$fsopts,}${iscsirw}
if [ -z "$iscsi_initiator" ] && [ -f /sys/firmware/ibft/initiator/initiator-name ] && ! [ -f /tmp/iscsi_set_initiator ]; then
- iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line;done < /sys/firmware/ibft/initiator/initiator-name)
- echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
- rm -f /etc/iscsi/initiatorname.iscsi
- mkdir -p /etc/iscsi
- ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
- > /tmp/iscsi_set_initiator
- if [ -n "$DRACUT_SYSTEMD" ]; then
- systemctl try-restart iscsid
- # FIXME: iscsid is not yet ready, when the service is :-/
- sleep 1
- fi
+ iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line; done < /sys/firmware/ibft/initiator/initiator-name)
+ echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
+ rm -f /etc/iscsi/initiatorname.iscsi
+ mkdir -p /etc/iscsi
+ ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
+ > /tmp/iscsi_set_initiator
+ if [ -n "$DRACUT_SYSTEMD" ]; then
+ systemctl try-restart iscsid
+ # FIXME: iscsid is not yet ready, when the service is :-/
+ sleep 1
+ fi
fi
if [ -z "$iscsi_initiator" ]; then
fi
fi
-
if [ -z "$iscsi_target_port" ]; then
iscsi_target_port=3260
fi
fi
fi
- if [ -z "$DRACUT_SYSTEMD" ]; then
- iscsid
- sleep 2
- fi
+ if [ -z "$DRACUT_SYSTEMD" ]; then
+ iscsid
+ sleep 2
+ fi
-# FIXME $iscsi_protocol??
+ # FIXME $iscsi_protocol??
if [ "$root" = "dhcp" ] || [ "$netroot" = "dhcp" ]; then
# if root is not specified try to mount the whole iSCSI LUN
wait_for_dev -n /dev/root
# install mount script
- [ -z "$DRACUT_SYSTEMD" ] && \
- echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > $hookdir/mount/01-$$-iscsi.sh
+ [ -z "$DRACUT_SYSTEMD" ] \
+ && echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > $hookdir/mount/01-$$-iscsi.sh
fi
if strglobin $iscsi_target_ip '*:*:*' && ! strglobin $iscsi_target_ip '['; then
sleep 2
fi
-if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
+if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware; then
if [ "$netif" = "timeout" ] || [ "$netif" = "online" ] || [ "$netif" = "dummy" ]; then
[ -f /tmp/session-retry ] || echo 1 > /tmp/session-retry
handle_firmware
# booting from root.
[[ $hostonly ]] || [[ $mount_needs ]] && {
- pushd . >/dev/null
+ pushd . > /dev/null
for_each_host_dev_and_slaves block_is_iscsi
local _is_iscsi=$?
- popd >/dev/null
+ popd > /dev/null
[[ $_is_iscsi == 0 ]] || return 255
}
return 0
iface_mod=${iface_desc%%,*}
iface_mac=${iface_desc#*,}
iface_mac=${iface_mac%%,*}
- if [ "$ibft_mac" = "$iface_mac" ] ; then
+ if [ "$ibft_mac" = "$iface_mac" ]; then
echo $iface_mod
return 0
fi
# so the 'ip=ibft' parameter must not be set
# - specify firmware booting cmdline parameter
- for d in /sys/firmware/* ; do
- if [ -d ${d}/ethernet0 ] ; then
+ for d in /sys/firmware/*; do
+ if [ -d ${d}/ethernet0 ]; then
read ibft_mac < ${d}/ethernet0/mac
ibft_mod=$(get_ibft_mod $ibft_mac)
fi
- if [ -z "$ibft_mod" ] && [ -d ${d}/ethernet1 ] ; then
+ if [ -z "$ibft_mod" ] && [ -d ${d}/ethernet1 ]; then
read ibft_mac < ${d}/ethernet1/mac
ibft_mod=$(get_ibft_mod $ibft_mac)
fi
- if [ -d ${d}/initiator ] ; then
- if [ ${d##*/} = "ibft" ] && [ "$ibft_mod" != "bnx2i" ] ; then
+ if [ -d ${d}/initiator ]; then
+ if [ ${d##*/} = "ibft" ] && [ "$ibft_mod" != "bnx2i" ]; then
echo -n "rd.iscsi.ibft=1 "
fi
echo -n "rd.iscsi.firmware=1 "
[ "$host" = "$session" ] && return 1
iscsi_host=${host##*/}
- for flash in ${host}/flashnode_sess-* ; do
+ for flash in ${host}/flashnode_sess-*; do
[ -f "$flash" ] || continue
[ ! -e "$flash/is_boot_target" ] && continue
is_boot=$(cat $flash/is_boot_target)
- if [ $is_boot -eq 1 ] ; then
+ if [ $is_boot -eq 1 ]; then
# qla4xxx flashnode session; skip iBFT discovery
iscsi_initiator=$(cat /sys/class/iscsi_host/${iscsi_host}/initiatorname)
echo "rd.iscsi.initiator=${iscsi_initiator}"
- return;
+ return
fi
done
- for d in ${session}/* ; do
+ for d in ${session}/*; do
case $d in
- *connection*)
- c=${d##*/}
- conn=${d}/iscsi_connection/${c}
- if [ -d ${conn} ] ; then
- iscsi_address=$(cat ${conn}/persistent_address)
- iscsi_port=$(cat ${conn}/persistent_port)
- fi
- ;;
- *session)
- if [ -d ${d}/${iscsi_session} ] ; then
+ *connection*)
+ c=${d##*/}
+ conn=${d}/iscsi_connection/${c}
+ if [ -d ${conn} ]; then
+ iscsi_address=$(cat ${conn}/persistent_address)
+ iscsi_port=$(cat ${conn}/persistent_port)
+ fi
+ ;;
+ *session)
+ if [ -d ${d}/${iscsi_session} ]; then
iscsi_initiator=$(cat ${d}/${iscsi_session}/initiatorname)
- iscsi_targetname=$(cat ${d}/${iscsi_session}/targetname)
- fi
- ;;
+ iscsi_targetname=$(cat ${d}/${iscsi_session}/targetname)
+ fi
+ ;;
esac
done
[ -z "$iscsi_address" ] && return
ip_params_for_remote_addr "$iscsi_address"
- if [ -n "$iscsi_address" -a -n "$iscsi_targetname" ] ; then
- if [ -n "$iscsi_port" -a "$iscsi_port" -eq 3260 ] ; then
+ if [ -n "$iscsi_address" -a -n "$iscsi_targetname" ]; then
+ if [ -n "$iscsi_port" -a "$iscsi_port" -eq 3260 ]; then
iscsi_port=
fi
- if [ -n "$iscsi_lun" -a "$iscsi_lun" -eq 0 ] ; then
+ if [ -n "$iscsi_lun" -a "$iscsi_lun" -eq 0 ]; then
iscsi_lun=
fi
# In IPv6 case rd.iscsi.initatior= must pass address in [] brackets
return 0
}
-
install_softiscsi() {
[ -d /sys/firmware/ibft ] && return 0
local iscsi_dev
[[ -L "/sys/dev/block/$_dev" ]] || return
- iscsi_dev=$(cd -P /sys/dev/block/$_dev; echo $PWD)
+ iscsi_dev=$(
+ cd -P /sys/dev/block/$_dev
+ echo $PWD
+ )
install_iscsiroot $iscsi_dev
}
cmdline() {
local _iscsiconf=$(install_ibft)
{
- if [ "$_iscsiconf" ] ; then
+ if [ "$_iscsiconf" ]; then
echo ${_iscsiconf}
else
install_softiscsi
fi
# Detect iBFT and perform mandatory steps
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _iscsiconf=$(cmdline)
[[ $_iscsiconf ]] && printf "%s\n" "$_iscsiconf" >> "${initdir}/etc/cmdline.d/95iscsi.conf"
fi
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
else
inst_multiple -o \
- $systemdsystemunitdir/iscsi.service \
- $systemdsystemunitdir/iscsid.service \
- $systemdsystemunitdir/iscsid.socket \
- $systemdsystemunitdir/iscsiuio.service \
- $systemdsystemunitdir/iscsiuio.socket \
- iscsiadm iscsid
+ $systemdsystemunitdir/iscsi.service \
+ $systemdsystemunitdir/iscsid.service \
+ $systemdsystemunitdir/iscsid.socket \
+ $systemdsystemunitdir/iscsiuio.service \
+ $systemdsystemunitdir/iscsiuio.socket \
+ iscsiadm iscsid
for i in \
iscsid.socket \
[ -n "$iscsiroot" ] && [ -n "$iscsi_firmware" ] && die "Mixing iscsiroot and iscsi_firmware is dangerous"
-type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
+type write_fs_tab > /dev/null 2>&1 || . /lib/fs-lib.sh
# Root takes precedence over netroot
-if [ "${root%%:*}" = "iscsi" ] ; then
- if [ -n "$netroot" ] ; then
+if [ "${root%%:*}" = "iscsi" ]; then
+ if [ -n "$netroot" ]; then
echo "Warning: root takes precedence over netroot. Ignoring netroot"
fi
netroot=$root
done
# Root takes precedence over netroot
-if [ "${root}" = "/dev/root" ] && getarg "netroot=dhcp" ; then
+if [ "${root}" = "/dev/root" ] && getarg "netroot=dhcp"; then
# if root is not specified try to mount the whole iSCSI LUN
printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
[ -n "$DRACUT_SYSTEMD" ] && systemctl is-active systemd-udevd && udevadm control --reload-rules
fi
-if [ -n "$iscsiroot" ] ; then
- [ -z "$netroot" ] && netroot=$root
+if [ -n "$iscsiroot" ]; then
+ [ -z "$netroot" ] && netroot=$root
# @deprecated
echo "Warning: Argument iscsiroot is deprecated and might be removed in a future"
echo "release. See 'man dracut.kernel' for more information."
# Accept iscsiroot argument?
- [ -z "$netroot" ] || [ "$netroot" = "iscsi" ] || \
- die "Argument iscsiroot only accepted for empty root= or [net]root=iscsi"
+ [ -z "$netroot" ] || [ "$netroot" = "iscsi" ] \
+ || die "Argument iscsiroot only accepted for empty root= or [net]root=iscsi"
# Override root with iscsiroot content?
[ -z "$netroot" ] || [ "$netroot" = "iscsi" ] && netroot=iscsi:$iscsiroot
if [ "$root" != "dhcp" ] && [ "$netroot" != "dhcp" ]; then
[ -z "$netroot" ] && netroot=iscsi:
fi
- modprobe -b -q iscsi_boot_sysfs 2>/dev/null
+ modprobe -b -q iscsi_boot_sysfs 2> /dev/null
modprobe -b -q iscsi_ibft
# if no ip= is given, but firmware
echo "${DRACUT_SYSTEMD+systemctl is-active initrd-root-device.target || }[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh
modprobe --all -b -q qla4xxx cxgb3i cxgb4i bnx2i be2iscsi
if [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then
- if ! getargbool 1 rd.neednet >/dev/null || ! getarg "ip="; then
+ if ! getargbool 1 rd.neednet > /dev/null || ! getarg "ip="; then
initqueue --unique --onetime --settled /sbin/iscsiroot dummy "'$netroot'" "'$NEWROOT'"
fi
fi
-if arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=) && [ -n "$arg" ] && ! [ -f /run/initiatorname.iscsi ] ; then
+if arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=) && [ -n "$arg" ] && ! [ -f /run/initiatorname.iscsi ]; then
iscsi_initiator=$arg
echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
ln -fs /run/initiatorname.iscsi /dev/.initiatorname.iscsi
# If not given on the cmdline and initiator-name available via iBFT
if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ] && ! [ -f /tmp/iscsi_set_initiator ]; then
- iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line;done < /sys/firmware/ibft/initiator/initiator-name)
+ iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line; done < /sys/firmware/ibft/initiator/initiator-name)
if [ -n "$iscsi_initiator" ]; then
echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
rm -f /etc/iscsi/initiatorname.iscsi
for nroot in $(getargs netroot); do
[ "${nroot%%:*}" = "iscsi" ] || continue
- type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
+ type parse_iscsi_root > /dev/null 2>&1 || . /lib/net-lib.sh
parse_iscsi_root "$nroot" || return 1
netroot_enc=$(str_replace "$nroot" '/' '\2f')
echo "${DRACUT_SYSTEMD+systemctl is-active initrd-root-device.target || }[ -f '/tmp/iscsistarted-$netroot_enc' ]" > $hookdir/initqueue/finished/iscsi_started.sh
[ -z $DEVPATH ] && exit 1
-if [ -n "$1" ] ; then
+if [ -n "$1" ]; then
LUN=$1
else
LUN=-
HOST=${ID%%:*}
CHANNEL=${ID%%-*}
CHANNEL=${CHANNEL#*:}
-if [ -f /sys$DEVPATH/scsi_target_id ] ; then
+if [ -f /sys$DEVPATH/scsi_target_id ]; then
TARGET=$(cat /sys$DEVPATH/scsi_target_id)
fi
[ -z "$TARGET" ] && exit 1
cmdline() {
get_lunmask() {
local _dev=$1
- local _devpath=$(cd -P /sys/dev/block/$_dev ; echo $PWD)
+ local _devpath=$(
+ cd -P /sys/dev/block/$_dev
+ echo $PWD
+ )
local _sdev _lun _rport _end_device _classdev _wwpn _sas_address
[ "${_devpath#*/sd}" == "$_devpath" ] && return 1
_lun="${_sdev##*:}"
# Check for FibreChannel
_rport="${_devpath##*/rport-}"
- if [ "$_rport" != "$_devpath" ] ; then
+ if [ "$_rport" != "$_devpath" ]; then
_rport="${_rport%%/*}"
_classdev="/sys/class/fc_remote_ports/rport-${_rport}"
[ -d "$_classdev" ] || return 1
fi
# Check for SAS
_end_device="${_devpath##*/end_device-}"
- if [ "$_end_device" != "$_devpath" ] ; then
+ if [ "$_end_device" != "$_devpath" ]; then
_end_device="${_end_device%%/*}"
_classdev="/sys/class/sas_device/end_device-${_end_device}"
[ -e "$_classdev" ] || return 1
inst_script "$moddir/fc_transport_scan_lun.sh" /usr/lib/udev/fc_transport_scan_lun.sh
inst_script "$moddir/sas_transport_scan_lun.sh" /usr/lib/udev/sas_transport_scan_lun.sh
inst_hook cmdline 30 "$moddir/parse-lunmask.sh"
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _lunmask
- for _lunmask in $(cmdline) ; do
+ for _lunmask in $(cmdline); do
printf "%s\n" "$_lunmask" >> "${initdir}/etc/cmdline.d/95lunmask.conf"
done
fi
[ -e ${_rule} ] && return 0
- if [ ! -f "$_rule" ] ; then
- if [ "$transport" = "fc" ] ; then
- cat > $_rule <<EOF
+ if [ ! -f "$_rule" ]; then
+ if [ "$transport" = "fc" ]; then
+ cat > $_rule << EOF
ACTION=="add", SUBSYSTEM=="fc_remote_ports", ATTR{port_name}=="$tgtid", PROGRAM="fc_transport_scan_lun.sh $lun"
EOF
- elif [ "$transport" = "sas" ] ; then
- cat > $_rule <<EOF
+ elif [ "$transport" = "sas" ]; then
+ cat > $_rule << EOF
ACTION=="add", SUBSYSTEM=="sas_device", ATTR{sas_address}=="$tgtid", PROGRAM="sas_transport_scan_lun.sh $lun"
EOF
fi
local IFS=","
set $lunmask_arg
IFS="$OLDIFS"
- if [ -d /sys/module/scsi_mod ] ; then
+ if [ -d /sys/module/scsi_mod ]; then
printf "manual" > /sys/module/scsi_mod/parameters/scan
- elif [ ! -f /etc/modprobe.d/95lunmask.conf ] ; then
+ elif [ ! -f /etc/modprobe.d/95lunmask.conf ]; then
echo "options scsi_mod scan=manual" > /etc/modprobe.d/95lunmask.conf
fi
create_udev_rule $1 $2 $3
[ -z $DEVPATH ] && exit 1
-if [ -n "$1" ] ; then
+if [ -n "$1" ]; then
LUN=$1
else
LUN=-
HOST=${ID%%:*}
CHANNEL=${ID%%-*}
CHANNEL=${CHANNEL#*:}
-if [ -f /sys$DEVPATH/scsi_target_id ] ; then
+if [ -f /sys$DEVPATH/scsi_target_id ]; then
TARGET=$(cat /sys$DEVPATH/scsi_target_id)
fi
[ -z "$TARGET" ] && exit 1
fi
dracut_need_initqueue
}
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
[ -z "$root" ] && root=$(getarg root=)
ROOTFLAGS="$(getarg rootflags)"
nroot=${root#nbd:}
-nbdserver=${nroot%%:*};
+nbdserver=${nroot%%:*}
if [ "${nbdserver%"${nbdserver#?}"}" = "[" ]; then
nbdserver=${nroot#[}
- nbdserver=${nbdserver%%]:*}\]; nroot=${nroot#*]:}
+ nbdserver=${nbdserver%%]:*}\]
+ nroot=${nroot#*]:}
else
nroot=${nroot#*:}
fi
-nbdport=${nroot%%:*}; nroot=${nroot#*:}
-nbdfstype=${nroot%%:*}; nroot=${nroot#*:}
+nbdport=${nroot%%:*}
+nroot=${nroot#*:}
+nbdfstype=${nroot%%:*}
+nroot=${nroot#*:}
nbdflags=${nroot%%:*}
if [ "$nbdflags" = "$nbdfstype" ]; then
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
[ "${nroot%%:*}" = "nbd" ] || return
nroot=${nroot#nbd:}
-nbdserver=${nroot%%:*};
+nbdserver=${nroot%%:*}
if [ "${nbdserver%"${nbdserver#?}"}" = "[" ]; then
nbdserver=${nroot#[}
- nbdserver=${nbdserver%%]:*}; nroot=${nroot#*]:}
+ nbdserver=${nbdserver%%]:*}
+ nroot=${nroot#*]:}
else
nroot=${nroot#*:}
fi
-nbdport=${nroot%%:*}; nroot=${nroot#*:}
-nbdfstype=${nroot%%:*}; nroot=${nroot#*:}
+nbdport=${nroot%%:*}
+nroot=${nroot#*:}
+nbdfstype=${nroot%%:*}
+nroot=${nroot#*:}
nbdflags=${nroot%%:*}
nbdopts=${nroot#*:}
wait_for_dev -n /dev/root
if [ -z "$DRACUT_SYSTEMD" ]; then
- type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
+ type write_fs_tab > /dev/null 2>&1 || . /lib/fs-lib.sh
write_fs_tab /dev/root "$nbdfstype" "$fsopts"
printf '/bin/mount %s\n' \
- "$NEWROOT" \
- > $hookdir/mount/01-$$-nbd.sh
+ "$NEWROOT" \
+ > $hookdir/mount/01-$$-nbd.sh
fi
# if we're on systemd, use the nbd-generator script
# to create the /sysroot mount.
preopts="-systemd-mark $preopts"
fi
-if [ "$nbdport" -gt 0 ] 2>/dev/null; then
+if [ "$nbdport" -gt 0 ] 2> /dev/null; then
nbdport="$nbdport"
else
nbdport="-name $nbdport"
fi
-nbd-client -check /dev/nbd0 >/dev/null || \
- nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
+nbd-client -check /dev/nbd0 > /dev/null \
+ || nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
# NBD doesn't emit uevents when it gets connected, so kick it
echo change > /sys/block/nbd0/uevent
# root= takes precedence over netroot= if root=nbd[...]
#
-
# This script is sourced, so root should be set. But let's be paranoid
[ -z "$root" ] && root=$(getarg root=)
fi
# Root takes precedence over netroot
-if [ "${root%%:*}" = "nbd" ] ; then
- if [ -n "$netroot" ] ; then
+if [ "${root%%:*}" = "nbd" ]; then
+ if [ -n "$netroot" ]; then
warn "root takes precedence over netroot. Ignoring netroot"
fi
# If it's not nbd we don't continue
[ "${netroot%%:*}" = "nbd" ] || return
-
# Check required arguments
nroot=${netroot#nbd:}
-server=${nroot%%:*};
+server=${nroot%%:*}
if [ "${server%"${server#?}"}" = "[" ]; then
server=${nroot#[}
- server=${server%%]:*}\]; nroot=${nroot#*]:}
+ server=${server%%]:*}\]
+ nroot=${nroot#*]:}
else
nroot=${nroot#*:}
fi
root=block:/dev/root
# the device is created and waited for in ./nbdroot.sh
fi
-
### nfsroot= ###
nfs_device=$(findmnt -t nfs4 -n -o SOURCE /)
- if [ -n "$nfs_device" ];then
+ if [ -n "$nfs_device" ]; then
nfs_root="root=nfs4:$nfs_device"
else
nfs_device=$(findmnt -t nfs -n -o SOURCE /)
if [[ $nfs_device =~ [0-9]*\.[0-9]*\.[0-9]*.[0-9]* ]] || [[ $nfs_device =~ \[[^]]*\] ]]; then
nfs_address="${nfs_device%%:*}"
else
- lookup=$(host "${nfs_device%%:*}"| grep " address " | head -n1)
+ lookup=$(host "${nfs_device%%:*}" | grep " address " | head -n1)
nfs_address=${lookup##* }
fi
inst_libdir_file 'libnfsidmap_nsswitch.so*' 'libnfsidmap/*.so' 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' "$dracutsysrootdir"/etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/net-lib.sh
# TODO: make these things not pollute the calling namespace
arg="${arg##$nfs:}"
# check if we have a server
- if strstr "$arg" ':/' ; then
+ if strstr "$arg" ':/'; then
server="${arg%%:/*}"
arg="/${arg##*:/}"
fi
options="${options%%:}"
# Does it really start with '/'?
- [ -n "${path%%/*}" ] && path="error";
+ [ -n "${path%%/*}" ] && path="error"
#Fix kernel legacy style separating path and options with ','
- if [ "$path" != "${path#*,}" ] ; then
+ if [ "$path" != "${path#*,}" ]; then
options=${path#*,}
path=${path%%,*}
fi
IFS=,
for f in $options; do
case $f in
- ro|rw) nfsrw=$f ;;
- lock|nolock) nfslock=$f ;;
+ ro | rw) nfsrw=$f ;;
+ lock | nolock) nfslock=$f ;;
*) flags=${flags:+$flags,}$f ;;
esac
done
IFS="$OLDIFS"
# Override rw/ro if set on cmdline
- getarg ro >/dev/null && nfsrw=ro
- getarg rw >/dev/null && nfsrw=rw
+ getarg ro > /dev/null && nfsrw=ro
+ getarg rw > /dev/null && nfsrw=rw
options=$nfsrw${flags:+,$flags}
}
#!/bin/sh
if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then
- [ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
- mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
+ [ ! -d /var/lib/nfs/rpc_pipefs/nfs ] \
+ && mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
# Start rpcbind or rpcbind
# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
- command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
- if command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ]; then
+ command -v portmap > /dev/null && [ -z "$(pidof portmap)" ] && portmap
+ if command -v rpcbind > /dev/null && [ -z "$(pidof rpcbind)" ]; then
mkdir -p /run/rpcbind
rpcbind
fi
# Start rpc.statd as mount won't let us use locks on a NFSv4
# filesystem without talking to it. NFSv4 does locks internally,
# rpc.lockd isn't needed
- command -v rpc.statd >/dev/null && [ -z "$(pidof rpc.statd)" ] && rpc.statd
- command -v rpc.idmapd >/dev/null && [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
+ command -v rpc.statd > /dev/null && [ -z "$(pidof rpc.statd)" ] && rpc.statd
+ command -v rpc.idmapd > /dev/null && [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
else
warn 'Kernel module "sunrpc" not in the initramfs, or support for filesystem "rpc_pipefs" missing!'
fi
#!/bin/sh
-type incol2 >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type incol2 > /dev/null 2>&1 || . /lib/dracut-lib.sh
-[ -f /tmp/nfs.rpc_pipefs_path ] && rpcpipefspath=`cat /tmp/nfs.rpc_pipefs_path`
+[ -f /tmp/nfs.rpc_pipefs_path ] && rpcpipefspath=$(cat /tmp/nfs.rpc_pipefs_path)
[ -z "$rpcpipefspath" ] && rpcpipefspath=var/lib/nfs/rpc_pipefs
pid=$(pidof rpc.statd)
if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then
# try to create the destination directory
- [ -d $NEWROOT/$rpcpipefspath ] || \
- mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2>/dev/null
+ [ -d $NEWROOT/$rpcpipefspath ] \
+ || mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2> /dev/null
if [ -d $NEWROOT/$rpcpipefspath ]; then
# mount --move does not seem to work???
mount --bind /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath
- umount /var/lib/nfs/rpc_pipefs 2>/dev/null
+ umount /var/lib/nfs/rpc_pipefs 2> /dev/null
else
- umount /var/lib/nfs/rpc_pipefs 2>/dev/null
+ umount /var/lib/nfs/rpc_pipefs 2> /dev/null
fi
fi
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/nfs-lib.sh
[ "$#" = 3 ] || exit 1
nfs_to_var $root $netif
[ -z "$server" ] && die "Required parameter 'server' is missing"
-mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || ln -s null /dev/root ; [ -e /dev/nfs ] || ln -s null /dev/nfs; }
+mount_nfs $root $NEWROOT $netif && {
+ [ -e /dev/root ] || ln -s null /dev/root
+ [ -e /dev/nfs ] || ln -s null /dev/nfs
+}
[ -f $NEWROOT/etc/fstab ] && cat $NEWROOT/etc/fstab > /dev/null
# NFSv3 is used.
#
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
- . /lib/nfs-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+. /lib/nfs-lib.sh
# This script is sourced, so root should be set. But let's be paranoid
[ -z "$root" ] && root=$(getarg root=)
# netroot= cmdline argument must be ignored, but must be used if
# we're inside netroot to parse dhcp root-path
-if [ -n "$netroot" ] ; then
+if [ -n "$netroot" ]; then
for n in $(getargs netroot=); do
[ "$n" = "$netroot" ] && break
done
netroot=$root
fi
else
- netroot=$root;
+ netroot=$root
fi
# LEGACY: nfsroot= is valid only if root=/dev/nfs
-if [ -n "$nfsroot" ] ; then
+if [ -n "$nfsroot" ]; then
# @deprecated
warn "Argument nfsroot is deprecated and might be removed in a future release. See 'man dracut.kernel' for more information."
- if [ "$(getarg root=)" != "/dev/nfs" ]; then
+ if [ "$(getarg root=)" != "/dev/nfs" ]; then
die "Argument nfsroot only accepted for legacy root=/dev/nfs"
fi
- netroot=nfs:$nfsroot;
+ netroot=nfs:$nfsroot
fi
case "$netroot" in
- /dev/nfs) netroot=nfs;;
+ /dev/nfs) netroot=nfs ;;
/dev/*)
if [ -n "$oldnetroot" ]; then
netroot="$oldnetroot"
else
unset netroot
fi
- return
- ;;
+ return
+ ;;
# LEGACY: root=<server-ip>:/<path
- [0-9]*:/*|[0-9]*\.[0-9]*\.[0-9]*[!:]|/*)
- netroot=nfs:$netroot;;
+ [0-9]*:/* | [0-9]*\.[0-9]*\.[0-9]*[!:] | /*)
+ netroot=nfs:$netroot
+ ;;
esac
# Continue if nfs
case "${netroot%%:*}" in
- nfs|nfs4|/dev/nfs);;
+ nfs | nfs4 | /dev/nfs) ;;
*)
if [ -n "$oldnetroot" ]; then
netroot="$oldnetroot"
netroot="$fstype:$server:$path:$options"
# If we don't have a server, we need dhcp
-if [ -z "$server" ] ; then
+if [ -z "$server" ]; then
DHCPORSERVER="1"
-fi;
+fi
# Done, all good!
rootok=1
[[ -L "/sys/dev/block/$_dev" ]] || return 0
cd -P "/sys/dev/block/$_dev" || return 0
- if [ -f partition ] ; then
+ if [ -f partition ]; then
cd ..
fi
- for d in device/nvme* ; do
+ for d in device/nvme*; do
[ -L "$d" ] || continue
- if readlink "$d" | grep -q nvme-fabrics ; then
+ if readlink "$d" | grep -q nvme-fabrics; then
trtype=$(cat "$d"/transport)
break
fi
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
- pushd . >/dev/null
+ pushd . > /dev/null
for_each_host_dev_and_slaves is_nvmf
local _is_nvmf=$?
- popd >/dev/null
+ popd > /dev/null
[[ $_is_nvmf == 0 ]] || return 255
- if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ] ; then
- if [ ! -f /etc/nvme/discovery.conf ] ; then
+ if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then
+ if [ ! -f /etc/nvme/discovery.conf ]; then
echo "No discovery arguments present"
return 255
fi
[[ -L "/sys/dev/block/$_dev" ]] || return 0
cd -P "/sys/dev/block/$_dev" || return 0
- if [ -f partition ] ; then
+ if [ -f partition ]; then
cd ..
fi
- for d in device/nvme* ; do
+ for d in device/nvme*; do
[ -L "$d" ] || continue
- if readlink "$d" | grep -q nvme-fabrics ; then
+ if readlink "$d" | grep -q nvme-fabrics; then
trtype=$(cat "$d"/transport)
break
fi
done
}
- if [ -f /etc/nvme/hostnqn ] ; then
+ if [ -f /etc/nvme/hostnqn ]; then
_hostnqn=$(cat /etc/nvme/hostnqn)
echo -n " nvmf.hostnqn=${_hostnqn}"
fi
- if [ -f /etc/nvme/hostid ] ; then
+ if [ -f /etc/nvme/hostid ]; then
_hostid=$(cat /etc/nvme/hostid)
echo -n " nvmf.hostid=${_hostid}"
fi
[[ $hostonly ]] || [[ $mount_needs ]] && {
- pushd . >/dev/null
+ pushd . > /dev/null
for_each_host_dev_and_slaves gen_nvmf_cmdline
- popd >/dev/null
+ popd > /dev/null
}
}
# called by dracut
install() {
if [[ $hostonly_cmdline == "yes" ]]; then
- local _nvmf_args=$(cmdline)
- [[ "$_nvmf_args" ]] && printf "%s" "$_nvmf_args" >> "${initdir}/etc/cmdline.d/95nvmf-args.conf"
+ local _nvmf_args=$(cmdline)
+ [[ "$_nvmf_args" ]] && printf "%s" "$_nvmf_args" >> "${initdir}/etc/cmdline.d/95nvmf-args.conf"
fi
inst_simple "/etc/nvme/hostnqn"
inst_simple "/etc/nvme/hostid"
# specify any discover parameters for FC.
#
-type is_ip >/dev/null 2>&1 || . /lib/net-lib.sh
+type is_ip > /dev/null 2>&1 || . /lib/net-lib.sh
-if getargbool 0 rd.nonvmf ; then
+if getargbool 0 rd.nonvmf; then
warn "rd.nonvmf=0: skipping nvmf"
return 0
fi
initqueue --onetime modprobe --all -b -q nvme nvme_tcp nvme_core nvme_fabrics
validate_ip_conn() {
- if ! getargbool 0 rd.neednet ; then
+ if ! getargbool 0 rd.neednet; then
warn "$trtype transport requires rd.neednet=1"
return 1
fi
local_address=$(ip -o route get to $traddr | sed -n 's/.*src \([0-9a-f.:]*\).*/\1/p')
# confirm we got a local IP address
- if ! is_ip "$local_address" ; then
- warn "$traddr is an invalid address";
+ if ! is_ip "$local_address"; then
+ warn "$traddr is an invalid address"
return 1
fi
ifname=$(ip -o route get to $local_address | sed -n 's/.*dev \([^ ]*\).*/\1/p')
- if ip l show "$ifname" >/dev/null 2>&1 ; then
- warn "invalid network interface $ifname"
- return 1
+ if ip l show "$ifname" > /dev/null 2>&1; then
+ warn "invalid network interface $ifname"
+ return 1
fi
# confirm there's a route to destination
- if ip route get "$traddr" >/dev/null 2>&1 ; then
+ if ip route get "$traddr" > /dev/null 2>&1; then
warn "no route to $traddr"
return 1
fi
return 0
;;
esac
- if [ "$traddr" = "none" ] ; then
+ if [ "$traddr" = "none" ]; then
warn "traddr is mandatory for $trtype"
- return 0;
+ return 0
fi
- if [ "$trtype" = "fc" ] ; then
- if [ "$traddr" = "auto" ] ; then
+ if [ "$trtype" = "fc" ]; then
+ if [ "$traddr" = "auto" ]; then
rm /etc/nvme/discovery.conf
return 1
fi
- if [ "$hosttraddr" = "none" ] ; then
+ if [ "$hosttraddr" = "none" ]; then
warn "host traddr is mandatory for fc"
return 0
fi
- elif [ "$trtype" != "rdma" ] && [ "$trtype" != "tcp" ] ; then
+ elif [ "$trtype" != "rdma" ] && [ "$trtype" != "tcp" ]; then
warn "unsupported transport $trtype"
return 0
fi
if [ "$trtype" = "tcp" ]; then
validate_ip_conn
fi
- if [ "$trtype" = "fc" ] ; then
+ if [ "$trtype" = "fc" ]; then
echo "--transport=$trtype --traddr=$traddr --host-traddr=$hosttraddr" >> /etc/nvme/discovery.conf
else
echo "--transport=$trtype --traddr=$traddr --host-traddr=$hosttraddr --trsvcid=$trsvcid" >> /etc/nvme/discovery.conf
}
nvmf_hostnqn=$(getarg nvmf.hostnqn=)
-if [ -n "$nvmf_hostnqn" ] ; then
+if [ -n "$nvmf_hostnqn" ]; then
echo "$nvmf_hostnqn" > /etc/nvme/hostnqn
fi
nvmf_hostid=$(getarg nvmf.hostid=)
-if [ -n "$nvmf_hostid" ] ; then
+if [ -n "$nvmf_hostid" ]; then
echo "$nvmf_hostid" > /etc/nvme/hostid
fi
[ -f "/etc/nvme/hostnqn" ] || exit 0
[ -f "/etc/nvme/hostid" ] || exit 0
-if [ -f "/etc/nvme/discovery.conf" ] ; then
+if [ -f "/etc/nvme/discovery.conf" ]; then
/sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
- if [ "$trtype" = "tcp" ] ; then
+ if [ "$trtype" = "tcp" ]; then
> /tmp/net.$ifname.did-setup
fi
else
# No nvme command line arguments present, try autodiscovery
- if [ "$trtype" = "fc" ] ; then
+ if [ "$trtype" = "fc" ]; then
/sbin/initqueue --finished --onetime --unique --name nvme-fc-autoconnect /sbin/nvmf-autoconnect.sh
fi
fi
for i in /sys/devices/qeth/*/online; do
read _online < $i
[ $_online -eq 1 ] && return 0
- done
+ done
}
return 255
}
# called by dracut
installkernel() {
- instmods qeth
+ instmods qeth
}
# called by dracut
inst_rules_qeth() {
for rule in /etc/udev/rules.d/{4,5}1-qeth-${1}.rules; do
- # prefer chzdev generated 41- rules
- if [ -f "$rule" ]; then
- inst_rules "$rule"
- break
- fi
+ # prefer chzdev generated 41- rules
+ if [ -f "$rule" ]; then
+ inst_rules "$rule"
+ break
+ fi
done
}
# not readable in qeth interfaces
# that have just been assembled, ignore
# read error and assume no carrier
- read carrier 2>/dev/null < "$1/carrier"
+ read carrier 2> /dev/null < "$1/carrier"
[ "$carrier" -eq 1 ] && return 0
- return 1;
+ return 1
}
for dev in /sys/class/net/*; do
# called by dracut
install() {
local _bin
- local _resumeconf
+ local _resumeconf
if [[ $hostonly_cmdline == "yes" ]]; then
- _resumeconf=$(cmdline)
- [[ $_resumeconf ]] && printf "%s\n" "$_resumeconf" >> "${initdir}/etc/cmdline.d/95resume.conf"
+ _resumeconf=$(cmdline)
+ [[ $_resumeconf ]] && printf "%s\n" "$_resumeconf" >> "${initdir}/etc/cmdline.d/95resume.conf"
fi
# if systemd is included and has the hibernate-resume tool, use it and nothing else
if dracut_module_included "systemd" && [[ -x $dracutsysrootdir$systemdutildir/systemd-hibernate-resume ]]; then
inst_multiple -o \
- "$systemdutildir"/system-generators/systemd-hibernate-resume-generator \
- "$systemdsystemunitdir"/systemd-hibernate-resume@.service \
- "$systemdutildir"/systemd-hibernate-resume
+ "$systemdutildir"/system-generators/systemd-hibernate-resume-generator \
+ "$systemdsystemunitdir"/systemd-hibernate-resume@.service \
+ "$systemdutildir"/systemd-hibernate-resume
return 0
fi
# Optional uswsusp support
- for _bin in /usr/sbin/resume /usr/lib/suspend/resume /usr/lib/uswsusp/resume
- do
+ for _bin in /usr/sbin/resume /usr/lib/suspend/resume /usr/lib/uswsusp/resume; do
[[ -x $dracutsysrootdir${_bin} ]] && {
inst "${_bin}" /usr/sbin/resume
[[ $hostonly ]] && [[ -f $dracutsysrootdir/etc/suspend.conf ]] && inst -H /etc/suspend.conf
inst_script "$moddir/parse-resume.sh" /lib/dracut/parse-resume.sh
fi
- inst_script "$moddir/resume.sh" /lib/dracut/resume.sh
+ inst_script "$moddir/resume.sh" /lib/dracut/resume.sh
}
-
if resume=$(getarg resume=) && ! getarg noresume; then
export resume
- echo "$resume" >/.resume
+ echo "$resume" > /.resume
else
unset resume
fi
-
resume="$(label_uuid_to_dev "$resume")"
if splash=$(getarg splash=); then
fi
case "$splash" in
- quiet )
+ quiet)
a_splash="-P splash=y"
- ;;
- * )
+ ;;
+ *)
a_splash="-P splash=n"
- ;;
+ ;;
esac
-
if ! getarg noresume; then
if [ -n "$resume" ]; then
wait_for_dev /dev/resume
{
printf "KERNEL==\"%s\", ACTION==\"add|change\", SYMLINK+=\"resume\"\n" \
- ${resume#/dev/};
+ ${resume#/dev/}
printf "SYMLINK==\"%s\", ACTION==\"add|change\", SYMLINK+=\"resume\"\n" \
- ${resume#/dev/};
+ ${resume#/dev/}
} >> /etc/udev/rules.d/99-resume-link.rules
{
printf -- 'KERNEL=="%s", ' "${resume#/dev/}"
printf -- '%s' 'ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",'
printf -- " RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \'%s\'\"\n" \
- "$a_splash" "$resume";
+ "$a_splash" "$resume"
printf -- 'SYMLINK=="%s", ' "${resume#/dev/}"
printf -- '%s' 'ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",'
printf -- " RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \'%s\'\"\n" \
- "$a_splash" "$resume";
+ "$a_splash" "$resume"
fi
printf -- 'KERNEL=="%s", ' "${resume#/dev/}"
printf -- ' RUN+="/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s $tempnode"\n' "$a_splash"
fi
printf -- '%s' 'SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",'
- printf -- '%s\n' ' RUN+="/sbin/initqueue --finished --unique --name 00resume echo %M:%m > /sys/power/resume"';
+ printf -- '%s\n' ' RUN+="/sbin/initqueue --finished --unique --name 00resume echo %M:%m > /sys/power/resume"'
} >> /etc/udev/rules.d/99-resume.rules
fi
fi
[ -s /.resume -a -b "$resume" ] && {
# First try user level resume; it offers splash etc
case "$splash" in
- quiet )
+ quiet)
a_splash="-P splash=y"
- ;;
- * )
+ ;;
+ *)
a_splash="-P splash=n"
- ;;
+ ;;
esac
[ -x "$(command -v resume)" ] && command resume $a_splash "$resume"
- (readlink -fn $resume > /sys/power/resume)>/.resume
+ (readlink -fn $resume > /sys/power/resume) > /.resume
}
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type det_fs > /dev/null 2>&1 || . /lib/fs-lib.sh
mount_root() {
local _ret
fsckoptions="-j $journaldev $fsckoptions"
rflags="${rflags:+${rflags},}jdev=$journaldev"
;;
- *);;
+ *) ;;
esac
fi
READONLY=yes
fi
- if getarg noreadonlyroot ; then
+ if getarg noreadonlyroot; then
READONLY=no
fi
- if [ -f "$NEWROOT"/fastboot ] || getargbool 0 fastboot ; then
+ if [ -f "$NEWROOT"/fastboot ] || getargbool 0 fastboot; then
fastboot=yes
fi
fsckoptions=$(cat "$NEWROOT"/fsckoptions)
fi
- if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then
+ if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck; then
fsckoptions="-f $fsckoptions"
elif [ -f "$NEWROOT"/.autofsck ]; then
- [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && \
- . "$NEWROOT"/etc/sysconfig/autofsck
+ [ -f "$NEWROOT"/etc/sysconfig/autofsck ] \
+ && . "$NEWROOT"/etc/sysconfig/autofsck
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
fi
rootopts=
if getargbool 1 rd.fstab -d -n rd_NO_FSTAB \
- && ! getarg rootflags >/dev/null \
+ && ! getarg rootflags > /dev/null \
&& [ -f "$NEWROOT/etc/fstab" ] \
&& ! [ -L "$NEWROOT/etc/fstab" ]; then
# if $NEWROOT/etc/fstab contains special mount options for
# printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
ran_fsck=0
- if fsck_able "$rootfs" && \
- [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \
- ! strstr "${rflags}" _netdev && \
- ! getargbool 0 rd.skipfsck; then
+ if fsck_able "$rootfs" \
+ && [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] \
+ && ! strstr "${rflags}" _netdev \
+ && ! getargbool 0 rd.skipfsck; then
umount "$NEWROOT"
fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
_ret=$?
fi
if ! getargbool 0 rd.skipfsck; then
- [ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2>/dev/null
- [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2>/dev/null
+ [ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2> /dev/null
+ [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2> /dev/null
fi
}
case "${root#block:}" in
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
root="block:$(label_uuid_to_dev "$root")"
- rootok=1 ;;
+ rootok=1
+ ;;
/dev/*)
root="block:${root#block:}"
- rootok=1 ;;
+ rootok=1
+ ;;
esac
[ "${root%%:*}" = "block" ] && wait_for_dev "${root#block:}"
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
for root in $(getargs rootfallback=); do
root=$(label_uuid_to_dev "$root")
[[ $mount_needs ]] && return 1
# If our prerequisites are not met, fail.
- require_binaries ssh scp || return 1
+ require_binaries ssh scp || return 1
if [[ $sshkey ]]; then
[[ ! -f $dracutsysrootdir$sshkey ]] && {
echo network
}
-inst_sshenv()
-{
+inst_sshenv() {
if [[ -d $dracutsysrootdir/root/.ssh ]]; then
inst_dir /root/.ssh
chmod 700 "${initdir}"/root/.ssh
_nsslibs=$(
sed -e 's/#.*//; s/^[^:]*://; s/\[[^]]*\]//' \
"$dracutsysrootdir"/etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
+ )
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
}
-
[[ -x $dracutsysrootdir$_i ]] || continue
inst "$_i"
- if ! [[ -f ${initdir}${systemdutildir}/systemd-udevd ]]; then
+ if ! [[ -f ${initdir}${systemdutildir}/systemd-udevd ]]; then
ln -fs "$_i" "${initdir}${systemdutildir}"/systemd-udevd
fi
break
73-seat-late.rules \
75-net-description.rules \
80-drivers.rules 95-udev-late.rules \
- 80-net-name-slot.rules\
- 80-net-setup-link.rules \
+ 80-net-name-slot.rules 80-net-setup-link.rules \
95-late.rules \
"$moddir/59-persistent-storage.rules" \
"$moddir/61-persistent-storage.rules" \
{
for i in cdrom tape dialout floppy; do
- if ! grep -q "^$i:" "$initdir"/etc/group 2>/dev/null; then
- if ! grep "^$i:" "$dracutsysrootdir"/etc/group 2>/dev/null; then
- case $i in
- cdrom) echo "$i:x:11:";;
- dialout) echo "$i:x:18:";;
- floppy) echo "$i:x:19:";;
- tape) echo "$i:x:33:";;
- esac
+ if ! grep -q "^$i:" "$initdir"/etc/group 2> /dev/null; then
+ if ! grep "^$i:" "$dracutsysrootdir"/etc/group 2> /dev/null; then
+ case $i in
+ cdrom) echo "$i:x:11:" ;;
+ dialout) echo "$i:x:18:" ;;
+ floppy) echo "$i:x:19:" ;;
+ tape) echo "$i:x:33:" ;;
+ esac
fi
fi
done
inst_multiple -o /etc/pcmcia/config.opts
- [[ -f $dracutsysrootdir/etc/arch-release ]] && \
- inst_script "$moddir/load-modules.sh" /lib/udev/load-modules.sh
+ [[ -f $dracutsysrootdir/etc/arch-release ]] \
+ && inst_script "$moddir/load-modules.sh" /lib/udev/load-modules.sh
inst_libdir_file "libnss_files*"
}
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
filter_rootopts() {
rootopts=$1
local v
while [ $# -gt 0 ]; do
case $1 in
- rw|ro);;
- defaults);;
+ rw | ro) ;;
+ defaults) ;;
*)
- v="$v,${1}";;
+ v="$v,${1}"
+ ;;
esac
shift
done
info "Remounting ${root#virtfs:} with -o ${rflags}"
mount -t ${rootfs} -o "$rflags" "${root#virtfs:}" "$NEWROOT" 2>&1 | vinfo
- [ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2>/dev/null
- [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2>/dev/null
+ [ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2> /dev/null
+ [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2> /dev/null
}
if [ -n "$root" -a -z "${root%%virtfs:*}" ]; then
#!/bin/sh
-if [ "${root%%:*}" = "virtfs" ] ; then
+if [ "${root%%:*}" = "virtfs" ]; then
modprobe 9pnet_virtio
rootok=1
getargbool 1 rd.zfcp.conf -d -n rd_NO_ZFCPCONF || rm /etc/zfcp.conf
for zfcp_arg in $(getargs rd.zfcp -d 'rd_ZFCP='); do
- echo $zfcp_arg | grep '^0\.[0-9a-fA-F]\.[0-9a-fA-F]\{4\}\(,0x[0-9a-fA-F]\{16\},0x[0-9a-fA-F]\{16\}\)\?$' >/dev/null
+ echo $zfcp_arg | grep '^0\.[0-9a-fA-F]\.[0-9a-fA-F]\{4\}\(,0x[0-9a-fA-F]\{16\},0x[0-9a-fA-F]\{16\}\)\?$' > /dev/null
test $? -ne 0 && die "For argument 'rd.zfcp=$zfcp_arg'\nSorry, invalid format."
(
IFS=","
cmdline() {
is_zfcp() {
local _dev=$1
- local _devpath=$(cd -P /sys/dev/block/$_dev ; echo $PWD)
+ local _devpath=$(
+ cd -P /sys/dev/block/$_dev
+ echo $PWD
+ )
local _sdev _scsiid _hostno _lun _wwpn _ccw _port_type
local _allow_lun_scan _is_npiv
;;
esac
_ccw=$(cat ${_sdev}/hba_id)
- if [ "$_is_npiv" ] && [ "$_allow_lun_scan" = "Y" ] ; then
+ if [ "$_is_npiv" ] && [ "$_allow_lun_scan" = "Y" ]; then
echo "rd.zfcp=${_ccw}"
else
_lun=$(cat ${_sdev}/fcp_lun)
[[ $hostonly ]] || [[ $mount_needs ]] && {
found=0
- for _ccw in /sys/bus/ccw/devices/*/host* ; do
+ for _ccw in /sys/bus/ccw/devices/*/host*; do
[ -d "$_ccw" ] || continue
- found=$(($found+1));
+ found=$(($found + 1))
done
[ $found -eq 0 ] && return 255
}
install() {
inst_multiple /usr/lib/udev/collect
inst_hook cmdline 30 "$moddir/parse-zfcp.sh"
- if [[ $hostonly_cmdline == "yes" ]] ; then
+ if [[ $hostonly_cmdline == "yes" ]]; then
local _zfcp
- for _zfcp in $(cmdline) ; do
+ for _zfcp in $(cmdline); do
printf "%s\n" "$_zfcp" >> "${initdir}/etc/cmdline.d/94zfcp.conf"
done
fi
- if [[ $hostonly ]] ; then
+ if [[ $hostonly ]]; then
inst_rules_wildcard 51-zfcp-*.rules
inst_rules_wildcard 41-s390x-zfcp-*.rules
fi
local _rule=/etc/udev/rules.d/51-zfcp-${ccw}.rules
local _cu_type _dev_type
- if [ -x /sbin/cio_ignore ] && cio_ignore -i $ccw > /dev/null ; then
+ if [ -x /sbin/cio_ignore ] && cio_ignore -i $ccw > /dev/null; then
cio_ignore -r $ccw
fi
- if [ -e /sys/bus/ccw/devices/${ccw} ] ; then
+ if [ -e /sys/bus/ccw/devices/${ccw} ]; then
read _cu_type < /sys/bus/ccw/devices/${ccw}/cutype
read _dev_type < /sys/bus/ccw/devices/${ccw}/devtype
fi
- if [ "$_cu_type" != "1731/03" ] ; then
- return 0;
+ if [ "$_cu_type" != "1731/03" ]; then
+ return 0
fi
- if [ "$_dev_type" != "1732/03" ] && [ "$_dev_type" != "1732/04" ] ; then
- return 0;
+ if [ "$_dev_type" != "1732/03" ] && [ "$_dev_type" != "1732/04" ]; then
+ return 0
fi
- if [ ! -f "$_rule" ] ; then
- cat > $_rule <<EOF
+ if [ ! -f "$_rule" ]; then
+ cat > $_rule << EOF
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$ccw", IMPORT{program}="collect $ccw %k ${ccw} zfcp"
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="zfcp", IMPORT{program}="collect $ccw %k ${ccw} zfcp"
ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1"
fi
[ -z "$wwpn" ] || [ -z "$lun" ] && return
m=$(sed -n "/.*${wwpn}.*${lun}.*/p" $_rule)
- if [ -z "$m" ] ; then
- cat >> $_rule <<EOF
+ if [ -z "$m" ]; then
+ cat >> $_rule << EOF
ACTION=="add", KERNEL=="rport-*", ATTR{port_name}=="$wwpn", SUBSYSTEMS=="ccw", KERNELS=="$ccw", ATTR{[ccw/$ccw]$wwpn/unit_add}="$lun"
EOF
fi
- if [ -x /sbin/cio_ignore ] && ! cio_ignore -i $ccw > /dev/null ; then
+ if [ -x /sbin/cio_ignore ] && ! cio_ignore -i $ccw > /dev/null; then
cio_ignore -r $ccw
fi
}
-if [[ -f /sys/firmware/ipl/ipl_type &&
- $(</sys/firmware/ipl/ipl_type) = "fcp" ]] ; then
+if [[ -f /sys/firmware/ipl/ipl_type && \
+ $(< /sys/firmware/ipl/ipl_type) = "fcp" ]]; then
(
_wwpn=$(cat /sys/firmware/ipl/wwpn)
_lun=$(cat /sys/firmware/ipl/lun)
ccw_arg=${zfcp_arg##*/}
;;
esac
- if [ -n "$ccw_arg" ] ; then
+ if [ -n "$ccw_arg" ]; then
OLDIFS="$IFS"
IFS="-"
set -- $ccw_arg
inst_rules 81-ccw.rules
inst_multiple znet_cio_free grep sed seq readlink /lib/udev/ccw_init
}
-
SECURITYFSDIR="/sys/kernel/security"
export SECURITYFSDIR
-if ! findmnt "${SECURITYFSDIR}" >/dev/null 2>&1; then
- mount -t securityfs -o nosuid,noexec,nodev securityfs ${SECURITYFSDIR} >/dev/null 2>&1
+if ! findmnt "${SECURITYFSDIR}" > /dev/null 2>&1; then
+ mount -t securityfs -o nosuid,noexec,nodev securityfs ${SECURITYFSDIR} > /dev/null 2>&1
fi
inst_multiple biosdevname
inst_rules 71-biosdevname.rules
}
-
info "biosdevname=1: activating biosdevname network renaming"
udevproperty UDEV_BIOSDEVNAME=1
fi
-
MULTIKERNELMODE="NO"
PCRLOCKNUM=11
-load_masterkey()
-{
+load_masterkey() {
# read the configuration from the config file
- [ -f "${MASTERKEYSCONFIG}" ] && \
- . ${MASTERKEYSCONFIG}
+ [ -f "${MASTERKEYSCONFIG}" ] \
+ && . ${MASTERKEYSCONFIG}
# override the kernel master key path name from the 'masterkey=' parameter
# in the kernel command line
MASTERKEYARG=$(getarg masterkey=)
- [ $? -eq 0 ] && \
- MASTERKEY=${MASTERKEYARG}
+ [ $? -eq 0 ] \
+ && MASTERKEY=${MASTERKEYARG}
# override the kernel master key type from the 'masterkeytype=' parameter
# in the kernel command line
MASTERKEYTYPEARG=$(getarg masterkeytype=)
- [ $? -eq 0 ] && \
- MASTERKEYTYPE=${MASTERKEYTYPEARG}
+ [ $? -eq 0 ] \
+ && MASTERKEYTYPE=${MASTERKEYTYPEARG}
# set default values
- [ -z "${MASTERKEYTYPE}" ] && \
- MASTERKEYTYPE="trusted"
+ [ -z "${MASTERKEYTYPE}" ] \
+ && MASTERKEYTYPE="trusted"
if [ -z "${MASTERKEY}" ]; then
# append the kernel version to the default masterkey path name
KEYBLOB=$(cat ${MASTERKEYPATH})
# add the 'load' prefix if the key type is 'trusted'
- [ "${MASTERKEYTYPE}" = "trusted" ] && \
- KEYBLOB="load ${KEYBLOB} pcrlock=${PCRLOCKNUM}"
+ [ "${MASTERKEYTYPE}" = "trusted" ] \
+ && KEYBLOB="load ${KEYBLOB} pcrlock=${PCRLOCKNUM}"
# load the kernel master key
info "Loading the kernel master key"
- keyctl add "${MASTERKEYTYPE}" "kmk-${MASTERKEYTYPE}" "${KEYBLOB}" @u >/dev/null || {
- info "masterkey: failed to load the kernel master key: kmk-${MASTERKEYTYPE}";
- return 1;
+ keyctl add "${MASTERKEYTYPE}" "kmk-${MASTERKEYTYPE}" "${KEYBLOB}" @u > /dev/null || {
+ info "masterkey: failed to load the kernel master key: kmk-${MASTERKEYTYPE}"
+ return 1
}
return 0
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
getarg "rd.cmdline=ask" || exit 0
#!/bin/sh
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
[ -f /usr/lib/initrd-release ] && . /usr/lib/initrd-release
[ -n "$VERSION" ] && info "dracut-$VERSION"
case "${root#block:}${root_unset}" in
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
root="block:$(label_uuid_to_dev "$root")"
- rootok=1 ;;
+ rootok=1
+ ;;
/dev/*)
root="block:${root}"
- rootok=1 ;;
- UNSET|gpt-auto|tmpfs)
+ rootok=1
+ ;;
+ UNSET | gpt-auto | tmpfs)
# systemd's gpt-auto-generator/fstab-generator handles this case.
- rootok=1 ;;
+ rootok=1
+ ;;
esac
[ -z "${root}${root_unset}" ] && die "Empty root= argument"
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
-type plymouth >/dev/null 2>&1 && plymouth quit
+type plymouth > /dev/null 2>&1 && plymouth quit
export _rdshell_name="dracut" action="Boot" hook="emergency"
_emergency_action=$(getarg rd.emergency)
case "$_emergency_action" in
reboot)
- reboot || exit 1;;
+ reboot || exit 1
+ ;;
poweroff)
- poweroff || exit 1;;
+ poweroff || exit 1
+ ;;
halt)
- halt || exit 1;;
+ halt || exit 1
+ ;;
esac
exit 0
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
RDRETRY=$(getarg rd.retry -d 'rd_retry=')
RDRETRY=${RDRETRY:-180}
-RDRETRY=$(($RDRETRY*2))
+RDRETRY=$(($RDRETRY * 2))
export RDRETRY
main_loop=0
check_finished && break 2
done
- udevadm settle --timeout=0 >/dev/null 2>&1 || continue
+ udevadm settle --timeout=0 > /dev/null 2>&1 || continue
for job in $hookdir/initqueue/settled/*.sh; do
[ -e "$job" ] || break
check_finished && break 2
done
- udevadm settle --timeout=0 >/dev/null 2>&1 || continue
+ udevadm settle --timeout=0 > /dev/null 2>&1 || continue
# no more udev jobs and queues empty.
sleep 0.5
[ -e "$i" ] && continue 2
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:"
for _f in $hookdir/initqueue/finished/*.sh; do
warn "$_f: \"$(cat "$_f")\""
for job in $hookdir/initqueue/timeout/*.sh; do
[ -e "$job" ] || break
job=$job . $job
- udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0
+ udevadm settle --timeout=0 > /dev/null 2>&1 || main_loop=0
[ -f $hookdir/initqueue/work ] && main_loop=0
[ $main_loop -eq 0 ] && break
done
fi
fi
- main_loop=$(($main_loop+1))
+ main_loop=$(($main_loop + 1))
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."
fi
warn "Not all disks have been found."
#!/bin/sh
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
i=0
while :; do
if ismounted "$NEWROOT"; then
- usable_root "$NEWROOT" && break;
+ usable_root "$NEWROOT" && break
umount "$NEWROOT"
fi
for f in $hookdir/mount/*.sh; do
[ -f "$f" ] && . "$f"
if ismounted "$NEWROOT"; then
- usable_root "$NEWROOT" && break;
+ usable_root "$NEWROOT" && break
warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f -- "$f"
fi
done
- i=$(($i+1))
+ i=$(($i + 1))
[ $i -gt 20 ] && emergency_shell "Can't mount root filesystem"
done
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup
-_bv=$(getarg rd.break -d rdbreak) && [ -z "$_bv" ] &&
- emergency_shell -n switch_root "Break before switch_root"
+_bv=$(getarg rd.break -d rdbreak) && [ -z "$_bv" ] \
+ && emergency_shell -n switch_root "Break before switch_root"
unset _bv
# remove helper symlink
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
getarg 'rd.break=pre-trigger' 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break pre-trigger"
-udevadm control --reload >/dev/null 2>&1 || :
+udevadm control --reload > /dev/null 2>&1 || :
export -p > /dracut-state.sh
#!/bin/sh
export DRACUT_SYSTEMD=1
if [ -f /dracut-state.sh ]; then
- . /dracut-state.sh 2>/dev/null
+ . /dracut-state.sh 2> /dev/null
fi
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
source_hook pre-udev
_modprobe_d=/etc/modprobe.d
-if [ -d /usr/lib/modprobe.d ] ; then
+if [ -d /usr/lib/modprobe.d ]; then
_modprobe_d=/usr/lib/modprobe.d
-elif [ -d /lib/modprobe.d ] ; then
+elif [ -d /lib/modprobe.d ]; then
_modprobe_d=/lib/modprobe.d
-elif [ ! -d $_modprobe_d ] ; then
+elif [ ! -d $_modprobe_d ]; then
mkdir -p $_modprobe_d
fi
)
done
-
[ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d
for i in $(getargs rd.driver.blacklist -d rdblacklist=); do
(
IFS=,
for p in $i; do
- echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
+ echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
done
)
done
for p in $(getargs rd.driver.post -d rdinsmodpost=); do
- echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
+ echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
_do_insmodpost=1
done
inst_multiple sulogin
}
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
-generator_wait_for_dev()
-{
+generator_wait_for_dev() {
local _name
local _timeout
fi
}
-generator_mount_rootfs()
-{
+generator_mount_rootfs() {
local _type=$2
local _flags=$3
local _name
fi
}
-generator_fsck_after_pre_mount()
-{
+generator_fsck_after_pre_mount() {
local _name
[ -z "$1" ] && return 0
case "${root#block:}" in
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
root="block:$(label_uuid_to_dev "$root")"
- rootok=1 ;;
+ rootok=1
+ ;;
/dev/nfs) # ignore legacy /dev/nfs
;;
/dev/*)
root="block:${root}"
- rootok=1 ;;
+ rootok=1
+ ;;
esac
GENERATOR_DIR="$1"
-if [ "$rootok" = "1" ]; then
- generator_wait_for_dev "${root#block:}" "$RDRETRY"
- generator_fsck_after_pre_mount "${root#block:}"
- strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
+if [ "$rootok" = "1" ]; then
+ generator_wait_for_dev "${root#block:}" "$RDRETRY"
+ generator_fsck_after_pre_mount "${root#block:}"
+ strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
fi
exit 0
ECRYPTFSSRCDIR="/secret"
ECRYPTFS_EXTRA_MOUNT_OPTS=""
-load_ecryptfs_key()
-{
+load_ecryptfs_key() {
# override the eCryptfs key path name from the 'ecryptfskey=' parameter in the kernel
# command line
ECRYPTFSKEYARG=$(getarg ecryptfskey=)
- [ $? -eq 0 ] && \
- ECRYPTFSKEY=${ECRYPTFSKEYARG}
+ [ $? -eq 0 ] \
+ && ECRYPTFSKEY=${ECRYPTFSKEYARG}
# set the default value
- [ -z "${ECRYPTFSKEY}" ] && \
- ECRYPTFSKEY="/etc/keys/ecryptfs-trusted.blob";
+ [ -z "${ECRYPTFSKEY}" ] \
+ && ECRYPTFSKEY="/etc/keys/ecryptfs-trusted.blob"
# set the eCryptfs key path name
ECRYPTFSKEYPATH="${NEWROOT}${ECRYPTFSKEY}"
# load the eCryptfs encrypted key blob
ECRYPTFSKEYID=$(keyctl add ${ECRYPTFSKEYTYPE} ${ECRYPTFSKEYDESC} "load ${KEYBLOB}" @u)
[ $? -eq 0 ] || {
- info "eCryptfs: failed to load the eCryptfs key: ${ECRYPTFSKEYDESC}";
- return 1;
+ info "eCryptfs: failed to load the eCryptfs key: ${ECRYPTFSKEYDESC}"
+ return 1
}
return 0
}
-unload_ecryptfs_key()
-{
+unload_ecryptfs_key() {
# unlink the eCryptfs encrypted key
keyctl unlink ${ECRYPTFSKEYID} @u || {
- info "eCryptfs: failed to unlink the eCryptfs key: ${ECRYPTFSKEYDESC}";
- return 1;
+ info "eCryptfs: failed to unlink the eCryptfs key: ${ECRYPTFSKEYDESC}"
+ return 1
}
return 0
}
-mount_ecryptfs()
-{
+mount_ecryptfs() {
# read the configuration from the config file
- [ -f "${ECRYPTFSCONFIG}" ] && \
- . ${ECRYPTFSCONFIG}
+ [ -f "${ECRYPTFSCONFIG}" ] \
+ && . ${ECRYPTFSCONFIG}
# load the eCryptfs encrypted key
load_ecryptfs_key || return 1
# set the default value for ECRYPTFSDSTDIR
- [ -z "${ECRYPTFSDSTDIR}" ] && \
- ECRYPTFSDSTDIR=${ECRYPTFSSRCDIR}
+ [ -z "${ECRYPTFSDSTDIR}" ] \
+ && ECRYPTFSDSTDIR=${ECRYPTFSSRCDIR}
# set the eCryptfs filesystem mount point
ECRYPTFSSRCMNT="${NEWROOT}${ECRYPTFSSRCDIR}"
# build the mount options variable
ECRYPTFS_MOUNT_OPTS="ecryptfs_sig=${ECRYPTFSKEYDESC}"
- [ ! -z "${ECRYPTFS_EXTRA_MOUNT_OPTS}" ] && \
- ECRYPTFS_MOUNT_OPTS="${ECRYPTFS_MOUNT_OPTS},${ECRYPTFS_EXTRA_MOUNT_OPTS}"
+ [ ! -z "${ECRYPTFS_EXTRA_MOUNT_OPTS}" ] \
+ && ECRYPTFS_MOUNT_OPTS="${ECRYPTFS_MOUNT_OPTS},${ECRYPTFS_EXTRA_MOUNT_OPTS}"
# mount the eCryptfs filesystem
info "Mounting the configured eCryptfs filesystem"
- mount -i -t ecryptfs -o${ECRYPTFS_MOUNT_OPTS} ${ECRYPTFSSRCMNT} ${ECRYPTFSDSTMNT} >/dev/null || {
- info "eCryptfs: mount of the eCryptfs filesystem failed";
- return 1;
+ mount -i -t ecryptfs -o${ECRYPTFS_MOUNT_OPTS} ${ECRYPTFSSRCMNT} ${ECRYPTFSDSTMNT} > /dev/null || {
+ info "eCryptfs: mount of the eCryptfs filesystem failed"
+ return 1
}
# unload the eCryptfs encrypted key
EVMKEYTYPE="encrypted"
EVMKEYID=""
-load_evm_key()
-{
+load_evm_key() {
# read the configuration from the config file
- [ -f "${EVMCONFIG}" ] && \
- . ${EVMCONFIG}
+ [ -f "${EVMCONFIG}" ] \
+ && . ${EVMCONFIG}
# override the EVM key path name from the 'evmkey=' parameter in the kernel
# command line
EVMKEYARG=$(getarg evmkey=)
- [ $? -eq 0 ] && \
- EVMKEY=${EVMKEYARG}
+ [ $? -eq 0 ] \
+ && EVMKEY=${EVMKEYARG}
# set the default value
- [ -z "${EVMKEY}" ] && \
- EVMKEY="/etc/keys/evm-trusted.blob";
+ [ -z "${EVMKEY}" ] \
+ && EVMKEY="/etc/keys/evm-trusted.blob"
# set the EVM key path name
EVMKEYPATH="${NEWROOT}${EVMKEY}"
# load the EVM encrypted key
EVMKEYID=$(keyctl add ${EVMKEYTYPE} ${EVMKEYDESC} "load ${KEYBLOB}" @u)
[ $? -eq 0 ] || {
- info "integrity: failed to load the EVM encrypted key: ${EVMKEYDESC}";
- return 1;
+ info "integrity: failed to load the EVM encrypted key: ${EVMKEYDESC}"
+ return 1
}
return 0
}
-load_evm_x509()
-{
+load_evm_x509() {
info "Load EVM IMA X509"
# override the EVM key path name from the 'evmx509=' parameter in
# the kernel command line
EVMX509ARG=$(getarg evmx509=)
- [ $? -eq 0 ] && \
- EVMX509=${EVMX509ARG}
+ [ $? -eq 0 ] \
+ && EVMX509=${EVMX509ARG}
# set the default value
- [ -z "${EVMX509}" ] && \
- EVMX509="/etc/keys/x509_evm.der";
+ [ -z "${EVMX509}" ] \
+ && EVMX509="/etc/keys/x509_evm.der"
# set the EVM public key path name
EVMX509PATH="${NEWROOT}${EVMX509}"
evm_pubid=${line%%:*}
else
# look for an existing regular keyring
- evm_pubid=`keyctl search @u keyring _evm`
+ evm_pubid=$(keyctl search @u keyring _evm)
if [ -z "${evm_pubid}" ]; then
# create a new regular _evm keyring
- evm_pubid=`keyctl newring _evm @u`
+ evm_pubid=$(keyctl newring _evm @u)
fi
fi
# load the EVM public key onto the EVM keyring
EVMX509ID=$(evmctl import ${EVMX509PATH} ${evm_pubid})
[ $? -eq 0 ] || {
- info "integrity: failed to load the EVM X509 cert ${EVMX509PATH}";
- return 1;
+ info "integrity: failed to load the EVM X509 cert ${EVMX509PATH}"
+ return 1
}
if [ "${RD_DEBUG}" = "yes" ]; then
return 0
}
-unload_evm_key()
-{
+unload_evm_key() {
# unlink the EVM encrypted key
keyctl unlink ${EVMKEYID} @u || {
- info "integrity: failed to unlink the EVM encrypted key: ${EVMKEYDESC}";
- return 1;
+ info "integrity: failed to unlink the EVM encrypted key: ${EVMKEYDESC}"
+ return 1
}
return 0
}
-enable_evm()
-{
+enable_evm() {
# check kernel support for EVM
if [ ! -e "${EVMSECFILE}" ]; then
if [ "${RD_DEBUG}" = "yes" ]; then
IMASECDIR="${SECURITYFSDIR}/ima"
IMACONFIG="${NEWROOT}/etc/sysconfig/ima"
-load_x509_keys()
-{
+load_x509_keys() {
KEYRING_ID=$1
# override the default configuration
IMAKEYSDIR="/etc/keys/ima"
fi
- PUBKEY_LIST=`ls ${NEWROOT}${IMAKEYSDIR}/*`
+ PUBKEY_LIST=$(ls ${NEWROOT}${IMAKEYSDIR}/*)
for PUBKEY in ${PUBKEY_LIST}; do
# check for public key's existence
if [ ! -f "${PUBKEY}" ]; then
X509ID=$(evmctl import ${PUBKEY} ${KEYRING_ID})
if [ $? -ne 0 ]; then
info "integrity: IMA x509 cert not loaded on keyring: ${PUBKEY}"
- fi
+ fi
done
if [ "${RD_DEBUG}" = "yes" ]; then
- keyctl show ${KEYRING_ID}
+ keyctl show ${KEYRING_ID}
fi
return 0
}
if [ $? -eq 0 ]; then
_ima_id=${line%%:*}
else
- _ima_id=`keyctl search @u keyring _ima`
+ _ima_id=$(keyctl search @u keyring _ima)
if [ -z "${_ima_id}" ]; then
- _ima_id=`keyctl newring _ima @u`
+ _ima_id=$(keyctl newring _ima @u)
fi
fi
IMACONFIG="${NEWROOT}/etc/sysconfig/ima"
IMAPOLICY="/etc/sysconfig/ima-policy"
-load_ima_policy()
-{
+load_ima_policy() {
# check kernel support for IMA
if [ ! -e "${IMASECDIR}" ]; then
if [ "${RD_DEBUG}" = "yes" ]; then
fi
# override the default configuration
- [ -f "${IMACONFIG}" ] && \
- . ${IMACONFIG}
+ [ -f "${IMACONFIG}" ] \
+ && . ${IMACONFIG}
# set the IMA policy path name
IMAPOLICYPATH="${NEWROOT}${IMAPOLICY}"
# check the existence of the IMA policy file
[ -f "${IMAPOLICYPATH}" ] && {
- info "Loading the provided IMA custom policy";
- printf '%s' "${IMAPOLICYPATH}" > ${IMASECDIR}/policy || \
- cat "${IMAPOLICYPATH}" > ${IMASECDIR}/policy
+ info "Loading the provided IMA custom policy"
+ printf '%s' "${IMAPOLICYPATH}" > ${IMASECDIR}/policy \
+ || cat "${IMAPOLICYPATH}" > ${IMASECDIR}/policy
}
return 0
install() {
inst_hook initqueue/settled 99 "$moddir/pollcdrom.sh"
}
-
inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"
inst_multiple setenforce
}
-
# FIXME: load selinux policy. this should really be done after we switchroot
-rd_load_policy()
-{
+rd_load_policy() {
# If SELinux is disabled exit now
getarg "selinux=0" > /dev/null && return 0
umount $NEWROOT/sys
if [ "$SELINUX" = "disabled" ]; then
- return 0;
+ return 0
fi
if [ $ret -eq 0 -o $ret -eq 2 ]; then
install() {
local _i
local _installs
- if find_binary rsyslogd >/dev/null; then
+ if find_binary rsyslogd > /dev/null; then
_installs="rsyslogd"
inst_libdir_file rsyslog/lmnet.so rsyslog/imklog.so rsyslog/imuxsock.so rsyslog/imjournal.so
- elif find_binary syslogd >/dev/null; then
+ elif find_binary syslogd > /dev/null; then
_installs="syslogd"
- elif find_binary syslog-ng >/dev/null; then
+ elif find_binary syslog-ng > /dev/null; then
_installs="syslog-ng"
else
derror "Could not find any syslog binary although the syslogmodule" \
fi
if [ -n "$_installs" ]; then
inst_multiple cat $_installs
- inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
+ inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
inst_hook cleanup 99 "$moddir/syslog-cleanup.sh"
inst_hook initqueue/online 70 "$moddir/rsyslogd-start.sh"
inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
fi
dracut_need_initqueue
}
-
#sysloglevel=level What level has to be logged
#syslogtype=rsyslog|syslog|syslogng
# Don't auto detect syslog but set it
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
detect_syslog() {
syslogtype=""
# Triggered by initqueue/online and starts rsyslogd with bootparameters
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
# prevent starting again if already running
if [ -f /var/run/syslogd.pid ]; then
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
# Kills rsyslogd
# Just cleans up a previously started syslogd
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
if [ -f /tmp/syslog.server ]; then
read syslogtype < /tmp/syslog.type
- if command -v "${syslogtype}-stop" >/dev/null; then
+ if command -v "${syslogtype}-stop" > /dev/null; then
${syslogtype}-stop
else
warn "syslog-cleanup: Could not find script to stop syslog of type \"$syslogtype\". Syslog will not be stopped."
fi
-fi
\ No newline at end of file
+fi
#!/bin/sh
-type info >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh
+type info > /dev/null 2>&1 || . /lib/dracut-lib.sh
+type fsck_single > /dev/null 2>&1 || . /lib/fs-lib.sh
filtersubvol() {
local _oldifs
IFS="$_oldifs"
while [ $# -gt 0 ]; do
case $1 in
- subvol\=*) :;;
+ subvol\=*) : ;;
*) printf '%s' "${1}," ;;
esac
shift
done
}
-fsck_usr()
-{
+fsck_usr() {
local _dev=$1
local _fs=$2
local _fsopts=$3
_fsckoptions=$(cat "$NEWROOT"/fsckoptions)
fi
- if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then
+ if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck; then
_fsckoptions="-f $_fsckoptions"
elif [ -f "$NEWROOT"/.autofsck ]; then
[ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck
fsck_single "$_dev" "$_fs" "$_fsopts" "$_fsckoptions"
}
-mount_usr()
-{
+mount_usr() {
local _dev _mp _fs _opts _rest _usr_found _ret _freq _passno
# check, if we have to mount the /usr filesystem
while read _dev _mp _fs _opts _freq _passno || [ -n "$_dev" ]; do
if [ "$_mp" = "/usr" ]; then
_dev="$(label_uuid_to_dev "$_dev")"
- if strstr "$_opts" "subvol=" && \
- [ "${root#block:}" -ef $_dev ] && \
- [ -n "$rflags" ]; then
+ if strstr "$_opts" "subvol=" \
+ && [ "${root#block:}" -ef $_dev ] \
+ && [ -n "$rflags" ]; then
# for btrfs subvolumes we have to mount /usr with the same rflags
rflags=$(filtersubvol "$rflags")
rflags=${rflags%%,}
if [ "0" != "${_passno:-0}" ]; then
fsck_usr "$_dev" "$_fs" "$_opts"
_fsck_ret=$?
- [ $_fsck_ret -ne 255 ] && echo $_fsck_ret >/run/initramfs/usr-fsck
+ [ $_fsck_ret -ne 255 ] && echo $_fsck_ret > /run/initramfs/usr-fsck
fi
fi
trim() {
local var="$*"
- var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
- var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
+ var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
+ var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
printf "%s" "$var"
}
info() {
check_quiet
echo "<30>dracut: $*" > /dev/kmsg
- [ "$DRACUT_QUIET" != "yes" ] && \
- echo "dracut: $*" >&2 || :
+ [ "$DRACUT_QUIET" != "yes" ] \
+ && echo "dracut: $*" >&2 || :
}
else
vwarn() {
while read line || [ -n "$line" ]; do
- warn $line;
+ warn $line
done
}
vinfo() {
while read line || [ -n "$line" ]; do
- info $line;
+ info $line
done
}
# example:
# str_replace ' one two three ' ' ' '_'
str_replace() {
- local in="$1"; local s="$2"; local r="$3"
+ local in="$1"
+ local s="$2"
+ local r="$3"
local out=''
while strstr "${in}" "$s"; do
for _pid in /proc/*; do
_pid=${_pid##/proc/}
case $_pid in
- *[!0-9]*) continue;;
+ *[!0-9]*) continue ;;
esac
[ -e "/proc/$_pid/exe" ] || continue
[ -e "/proc/$_pid/root" ] || continue
- if strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" ; then
+ if strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2> /dev/null)" "$1"; then
kill -9 "$_pid"
_killed=1
fi
if [ -e /etc/cmdline ]; then
while read -r _line || [ -n "$_line" ]; do
- CMDLINE_ETC="$CMDLINE_ETC $_line";
- done </etc/cmdline;
+ CMDLINE_ETC="$CMDLINE_ETC $_line"
+ done < /etc/cmdline
fi
for _i in /etc/cmdline.d/*.conf; do
[ -e "$_i" ] || continue
while read -r _line || [ -n "$_line" ]; do
- CMDLINE_ETC_D="$CMDLINE_ETC_D $_line";
- done <"$_i";
+ CMDLINE_ETC_D="$CMDLINE_ETC_D $_line"
+ done < "$_i"
done
if [ -e /proc/cmdline ]; then
while read -r _line || [ -n "$_line" ]; do
CMDLINE_PROC="$CMDLINE_PROC $_line"
- done </proc/cmdline;
+ done < /proc/cmdline
fi
CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE_PROC"
printf "%s" "$CMDLINE"
export CMDLINE
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if dracut-getarg "$2" >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if dracut-getarg "$2" > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if dracut-getarg "$2" >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if dracut-getarg "$2" > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if dracut-getarg "$1"; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
debug_on
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
debug_on
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
isdigit() {
case "$1" in
- *[!0-9]*|"") return 1;;
+ *[!0-9]* | "") return 1 ;;
esac
return 0
local _b
unset _b
local _default _min _max
- _default="$1"; shift
- _min="$1"; shift
- _max="$1"; shift
+ _default="$1"
+ shift
+ _min="$1"
+ shift
+ _max="$1"
+ shift
_b=$(getarg "$1")
[ $? -ne 0 -a -z "$_b" ] && _b=$_default
if [ -n "$_b" ]; then
- isdigit "$_b" && _b=$(($_b)) && \
- [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
+ isdigit "$_b" && _b=$(($_b)) \
+ && [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
fi
echo $_default
}
return 0
fi
debug_on
- return 1;
+ return 1
}
-
# Prints value of given option. If option is a flag and it's present,
# it just returns 0. Otherwise 1 is returned.
# $1 = options separated by commas
# Output:
# sha256
getoptcomma() {
- local line=",$1,"; local opt="$2"; local tmp
+ local line=",$1,"
+ local opt="$2"
+ local tmp
case "${line}" in
*,${opt}=*,*)
echo "${tmp%%,*}"
return 0
;;
- *,${opt},*) return 0;;
+ *,${opt},*) return 0 ;;
esac
return 1
}
# TODO: ':' inside fields.
splitsep() {
debug_off
- local sep="$1"; local str="$2"; shift 2
+ local sep="$1"
+ local str="$2"
+ shift 2
local tmp
while [ -n "$str" -a "$#" -gt 1 ]; do
RD_DEBUG=no
if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
RD_DEBUG=yes
- [ -n "$BASH" ] && \
- export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
- fi
+ [ -n "$BASH" ] \
+ && export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
+ fi
fi
export RD_DEBUG
fi
source_all() {
local f
local _dir
- _dir=$1; shift
- [ "$_dir" ] && [ -d "/$_dir" ] || return
+ _dir=$1
+ shift
+ [ "$_dir" ] && [ -d "/$_dir" ] || return
for f in "/$_dir"/*.sh; do [ -e "$f" ] && . "$f" "$@"; done
}
source_hook() {
local _dir
- _dir=$1; shift
+ _dir=$1
+ shift
source_all "/lib/dracut/hooks/$_dir" "$@"
}
local f
for f in $hookdir/initqueue/finished/*.sh; do
[ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0
- { [ -e "$f" ] && ( . "$f" ) ; } || return 1
+ { [ -e "$f" ] && (. "$f"); } || return 1
done
return 0
}
source_conf() {
local f
- [ "$1" ] && [ -d "/$1" ] || return
+ [ "$1" ] && [ -d "/$1" ] || return
for f in "/$1"/*.conf; do [ -e "$f" ] && . "$f"; done
}
die() {
{
- echo "<24>dracut: FATAL: $*";
- echo "<24>dracut: Refusing to continue";
+ echo "<24>dracut: FATAL: $*"
+ echo "<24>dracut: Refusing to continue"
} > /dev/kmsg
{
- echo "warn dracut: FATAL: \"$*\"";
- echo "warn dracut: Refusing to continue";
+ echo "warn dracut: FATAL: \"$*\""
+ echo "warn dracut: Refusing to continue"
} >> $hookdir/emergency/01-die.sh
[ -d /run/initramfs ] || mkdir -p -- /run/initramfs
fi
}
-
check_occurances() {
# Count the number of times the character $ch occurs in $str
# Return 0 if the count matches the expected number, 1 otherwise
while [ "${str#*$ch}" != "${str}" ]; do
str="${str#*$ch}"
- count=$(( $count + 1 ))
+ count=$(($count + 1))
done
[ $count -eq $expected ]
incol2() {
debug_off
- local dummy check;
- local file="$1";
- local str="$2";
+ local dummy check
+ local file="$1"
+ local str="$2"
- [ -z "$file" ] && return 1;
- [ -z "$str" ] && return 1;
+ [ -z "$file" ] && return 1
+ [ -z "$str" ] && return 1
while read dummy check restofline || [ -n "$check" ]; do
if [ "$check" = "$str" ]; then
# usage: ismounted <mountpoint>
# usage: ismounted /dev/<device>
-if command -v findmnt >/dev/null; then
+if command -v findmnt > /dev/null; then
ismounted() {
findmnt "$1" > /dev/null 2>&1
}
# TODO: symlinks
udevmatch() {
case "$1" in
- UUID=????????-????-????-????-????????????|LABEL=*|PARTLABEL=*|PARTUUID=????????-????-????-????-????????????)
- printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}"
- ;;
- UUID=*)
- printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}"
- ;;
- PARTUUID=*)
- printf 'ENV{ID_FS_PARTUUID}=="%s*"' "${1#*=}"
- ;;
- /dev/?*) printf -- 'KERNEL=="%s"' "${1#/dev/}" ;;
- *) return 255 ;;
+ UUID=????????-????-????-????-???????????? | LABEL=* | PARTLABEL=* | PARTUUID=????????-????-????-????-????????????)
+ printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}"
+ ;;
+ UUID=*)
+ printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}"
+ ;;
+ PARTUUID=*)
+ printf 'ENV{ID_FS_PARTUUID}=="%s*"' "${1#*=}"
+ ;;
+ /dev/?*) printf -- 'KERNEL=="%s"' "${1#/dev/}" ;;
+ *) return 255 ;;
esac
}
# # funiq /mnt cdrom
# /mnt/cdrom2
funiq() {
- local dir="$1"; local prefix="$2"
+ local dir="$1"
+ local prefix="$2"
local i=0
[ -d "${dir}" ] || return 1
while [ -e "${dir}/${prefix}$i" ]; do
- i=$(($i+1)) || return 1
+ i=$(($i + 1)) || return 1
done
echo "${dir}/${prefix}$i"
#
# mkuniqdir subdir new_dir_name
mkuniqdir() {
- local dir="$1"; local prefix="$2"
- local retdir; local retdir_new
+ local dir="$1"
+ local prefix="$2"
+ local retdir
+ local retdir_new
[ -d "${dir}" ] || mkdir -m 0755 -p "${dir}" || return 1
retdir=$(funiq "${dir}" "${prefix}") || return 1
- until mkdir -m 0755 "${retdir}" 2>/dev/null; do
+ until mkdir -m 0755 "${retdir}" 2> /dev/null; do
retdir_new=$(funiq "${dir}" "${prefix}") || return 1
[ "$retdir_new" = "$retdir" ] && return 1
retdir="$retdir_new"
# copytree SRC DEST
copytree() {
local src="$1" dest="$2"
- mkdir -p "$dest"; dest=$(readlink -e -q "$dest")
- ( cd "$src"; cp -af . -t "$dest" )
+ mkdir -p "$dest"
+ dest=$(readlink -e -q "$dest")
+ (
+ cd "$src"
+ cp -af . -t "$dest"
+ )
}
# Evaluates command for UUIDs either given as arguments for this function or all
cd /dev/disk/by-uuid
[ "$1" = -p ] && local prefix="$2" && shift 2
- local cmd="$1"; shift; local uuids_list="$*"
- local uuid; local full_uuid; local ___
+ local cmd="$1"
+ shift
+ local uuids_list="$*"
+ local uuid
+ local full_uuid
+ local ___
[ -n "${cmd}" ] || return 1
# /dev/sdb1
# /dev/sdf3
devnames() {
- local dev="$1"; local d; local names
+ local dev="$1"
+ local d
+ local names
case "$dev" in
- UUID=*)
- dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
- && return 255
- [ -z "$dev" ] && return 255
- ;;
- LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;;
- /dev/?*) ;;
- *) return 255 ;;
+ UUID=*)
+ dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
+ && return 255
+ [ -z "$dev" ] && return 255
+ ;;
+ LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;;
+ /dev/?*) ;;
+ *) return 255 ;;
esac
for d in $dev; do
}"
}
-
usable_root() {
local _i
while [ $# -gt 0 ]; do
case "$1" in
--hook)
- _hookname="/$2";shift;;
+ _hookname="/$2"
+ shift
+ ;;
--unique)
- _unique="yes";;
+ _unique="yes"
+ ;;
--name)
- _name="$2";shift;;
+ _name="$2"
+ shift
+ ;;
*)
- break;;
+ break
+ ;;
esac
shift
done
local _devname="dev-$(str_replace "$1" '/' '\\x2f')"
echo "$_dev $_mp $_fs $_fsopts 0 0" >> /etc/fstab
- exec 7>/etc/udev/rules.d/99-mount-${_devname}.rules
+ exec 7> /etc/udev/rules.d/99-mount-${_devname}.rules
echo 'SUBSYSTEM!="block", GOTO="mount_end"' >&7
echo 'ACTION!="add|change", GOTO="mount_end"' >&7
if [ -n "$_dev" ]; then
# Installs a initqueue-finished script,
# which will cause the main loop only to exit,
# if <mountpoint> is mounted.
-wait_for_mount()
-{
+wait_for_mount() {
local _name
_name="$(str_replace "$1" '/' '\\x2f')"
printf '. /lib/dracut-lib.sh\nismounted "%s"\n' $1 \
# get a systemd-compatible unit name from a path
# (mimicks unit_name_from_path_instance())
-dev_unit_name()
-{
+dev_unit_name() {
local dev="$1"
- if command -v systemd-escape >/dev/null; then
+ if command -v systemd-escape > /dev/null; then
systemd-escape -p -- "$dev"
return
fi
# set_systemd_timeout_for_dev <dev>
# Set 'rd.timeout' as the systemd timeout for <dev>
-set_systemd_timeout_for_dev()
-{
+set_systemd_timeout_for_dev() {
local _name
local _needreload
local _noreload
if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device ]; then
[ -d ${PREFIX}/etc/systemd/system/initrd.target.wants ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.wants
ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device
- type mark_hostonly >/dev/null 2>&1 && mark_hostonly /etc/systemd/system/initrd.target.wants/${_name}.device
+ type mark_hostonly > /dev/null 2>&1 && mark_hostonly /etc/systemd/system/initrd.target.wants/${_name}.device
_needreload=1
fi
echo "JobTimeoutSec=$_timeout"
echo "JobRunningTimeoutSec=$_timeout"
} > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
- type mark_hostonly >/dev/null 2>&1 && mark_hostonly /etc/systemd/system/${_name}.device.d/timeout.conf
+ type mark_hostonly > /dev/null 2>&1 && mark_hostonly /etc/systemd/system/${_name}.device.d/timeout.conf
_needreload=1
fi
# Installs a initqueue-finished script,
# which will cause the main loop only to exit,
# if the device <dev> is recognized by the system.
-wait_for_dev()
-{
+wait_for_dev() {
local _name
local _noreload
_name="$(str_replace "$1" '/' '\x2f')"
- type mark_hostonly >/dev/null 2>&1 && mark_hostonly "$hookdir/initqueue/finished/devexists-${_name}.sh"
+ type mark_hostonly > /dev/null 2>&1 && mark_hostonly "$hookdir/initqueue/finished/devexists-${_name}.sh"
[ -e "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
set_systemd_timeout_for_dev $_noreload $1
}
-cancel_wait_for_dev()
-{
+cancel_wait_for_dev() {
local _name
_name="$(str_replace "$1" '/' '\x2f')"
rm -f -- "$hookdir/initqueue/finished/devexists-${_name}.sh"
[ -x "$_exe" ] || return 1
for _i in /proc/[0-9]*; do
[ "$_i" = "/proc/1" ] && continue
- if [ -e "$_i"/_exe ] && [ "$_i/_exe" -ef "$_exe" ] ; then
+ if [ -e "$_i"/_exe ] && [ "$_i/_exe" -ef "$_exe" ]; then
kill $_sig ${_i##*/}
fi
done
}
need_shutdown() {
- >/run/initramfs/.need_shutdown
+ > /run/initramfs/.need_shutdown
}
-wait_for_loginit()
-{
+wait_for_loginit() {
[ "$RD_DEBUG" = "yes" ] || return
[ -e /run/initramfs/loginit.pipe ] || return
debug_off
echo "DRACUT_LOG_END"
- exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
- # wait for loginit
+ exec 0<> /dev/console 1<> /dev/console 2<> /dev/console
+ # wait for loginit
i=0
while [ $i -lt 10 ]; do
if [ ! -e /run/initramfs/loginit.pipe ]; then
[ -z "${j##*Running*}" ] || break
fi
sleep 0.1
- i=$(($i+1))
+ i=$(($i + 1))
done
if [ $i -eq 10 ]; then
- kill %1 >/dev/null 2>&1
- kill $(while read line || [ -n "$line" ];do echo $line;done</run/initramfs/loginit.pid)
+ kill %1 > /dev/null 2>&1
+ kill $(while read line || [ -n "$line" ]; do echo $line; done < /run/initramfs/loginit.pid)
fi
setdebug
}
# pidof version for root
-if ! command -v pidof >/dev/null 2>/dev/null; then
+if ! command -v pidof > /dev/null 2> /dev/null; then
pidof() {
debug_off
local _cmd
if [ -n "$_exe" ]; then
[ "$i" -ef "$_exe" ] || continue
else
- _rl=$(readlink -f "$i");
+ _rl=$(readlink -f "$i")
[ "${_rl%/$_cmd}" != "$_rl" ] || continue
fi
i=${i%/exe}
}
fi
-_emergency_shell()
-{
+_emergency_shell() {
local _name="$1"
if [ -n "$DRACUT_SYSTEMD" ]; then
> /.console_lock
- echo "PS1=\"$_name:\\\${PWD}# \"" >/etc/profile
+ echo "PS1=\"$_name:\\\${PWD}# \"" > /etc/profile
systemctl start dracut-emergency.service
rm -f -- /etc/profile
rm -f -- /.console_lock
echo 'Dropping to debug shell.'
echo
export PS1="$_name:\${PWD}# "
- [ -e /.profile ] || >/.profile
+ [ -e /.profile ] || > /.profile
_ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
if [ -z "$_ctty" ]; then
_ctty=/dev/$_ctty
fi
[ -c "$_ctty" ] || _ctty=/dev/tty1
- case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY="--ctty";; esac
- setsid $CTTY /bin/sh -i -l 0<>$_ctty 1<>$_ctty 2<>$_ctty
+ case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY="--ctty" ;; esac
+ setsid $CTTY /bin/sh -i -l 0<> $_ctty 1<> $_ctty 2<> $_ctty
fi
}
-emergency_shell()
-{
+emergency_shell() {
local _ctty
set +e
local _rdshell_name="dracut" action="Boot" hook="emergency"
_rdshell_name=$2
shift 2
elif [ "$1" = "--shutdown" ]; then
- _rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
- if type plymouth >/dev/null 2>&1; then
+ _rdshell_name=$2
+ action="Shutdown"
+ hook="shutdown-emergency"
+ if type plymouth > /dev/null 2>&1; then
plymouth --hide-splash
elif [ -x /oldroot/bin/plymouth ]; then
/oldroot/bin/plymouth --hide-splash
shift 2
fi
- echo ; echo
+ echo
+ echo
warn "$*"
echo
case "$_emergency_action" in
reboot)
- reboot || exit 1;;
+ reboot || exit 1
+ ;;
poweroff)
- poweroff || exit 1;;
+ poweroff || exit 1
+ ;;
halt)
- halt || exit 1;;
+ halt || exit 1
+ ;;
esac
}
# Retain the values of these variables but ensure that they are unexported
# This is a POSIX-compliant equivalent of bash's "export -n"
-export_n()
-{
+export_n() {
local var
local val
for var in "$@"; do
[ "$_list" = "$_sublist" ] && return 0
for _v in $_sublist; do
- if [ -n "$_v" ] && ! ( [ -n "$_iglist" ] && strstr "$_iglist" "$_v" )
- then
+ if [ -n "$_v" ] && ! ([ -n "$_iglist" ] && strstr "$_iglist" "$_v"); then
strstr "$_list" "$_v" || return 1
fi
done
setmemdebug
# parameters: func log_level prefix msg [trace_level:trace]...
-make_trace_mem()
-{
+make_trace_mem() {
local log_level prefix msg msg_printed
local trace trace_level trace_in_higher_levels insert_trace
}
# parameters: type
-show_memstats()
-{
+show_memstats() {
case $1 in
shortmem)
- cat /proc/meminfo | grep -e "^MemFree" -e "^Cached" -e "^Slab"
+ cat /proc/meminfo | grep -e "^MemFree" -e "^Cached" -e "^Slab"
;;
mem)
cat /proc/meminfo
export PATH
# mount some important things
-[ ! -d /proc/self ] && \
- mount -t proc -o nosuid,noexec,nodev proc /proc >/dev/null
+[ ! -d /proc/self ] \
+ && mount -t proc -o nosuid,noexec,nodev proc /proc > /dev/null
if [ "$?" != "0" ]; then
echo "Cannot mount proc on /proc! Compile the kernel with CONFIG_PROC_FS!"
exit 1
fi
-[ ! -d /sys/kernel ] && \
- mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null
+[ ! -d /sys/kernel ] \
+ && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys > /dev/null
if [ "$?" != "0" ]; then
echo "Cannot mount sysfs on /sys! Compile the kernel with CONFIG_SYSFS!"
setdebug
if ! ismounted /dev; then
- mount -t devtmpfs -o mode=0755,noexec,nosuid,strictatime devtmpfs /dev >/dev/null
+ mount -t devtmpfs -o mode=0755,noexec,nosuid,strictatime devtmpfs /dev > /dev/null
fi
if ! ismounted /dev; then
fi
# prepare the /dev directory
-[ ! -h /dev/fd ] && ln -s /proc/self/fd /dev/fd >/dev/null 2>&1
-[ ! -h /dev/stdin ] && ln -s /proc/self/fd/0 /dev/stdin >/dev/null 2>&1
-[ ! -h /dev/stdout ] && ln -s /proc/self/fd/1 /dev/stdout >/dev/null 2>&1
-[ ! -h /dev/stderr ] && ln -s /proc/self/fd/2 /dev/stderr >/dev/null 2>&1
+[ ! -h /dev/fd ] && ln -s /proc/self/fd /dev/fd > /dev/null 2>&1
+[ ! -h /dev/stdin ] && ln -s /proc/self/fd/0 /dev/stdin > /dev/null 2>&1
+[ ! -h /dev/stdout ] && ln -s /proc/self/fd/1 /dev/stdout > /dev/null 2>&1
+[ ! -h /dev/stderr ] && ln -s /proc/self/fd/2 /dev/stderr > /dev/null 2>&1
if ! ismounted /dev/pts; then
mkdir -m 0755 -p /dev/pts
- mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null
+ mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts > /dev/null
fi
if ! ismounted /dev/shm; then
mkdir -m 0755 -p /dev/shm
- mount -t tmpfs -o mode=1777,noexec,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null
+ mount -t tmpfs -o mode=1777,noexec,nosuid,nodev,strictatime tmpfs /dev/shm > /dev/null
fi
if ! ismounted /run; then
mkdir -m 0755 -p /newrun
if ! str_starts "$(readlink -f /bin/sh)" "/run/"; then
- mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
+ mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun > /dev/null
else
# the initramfs binaries are located in /run, so don't mount it with noexec
- mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
+ mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun > /dev/null
fi
- cp -a /run/* /newrun >/dev/null 2>&1
+ cp -a /run/* /newrun > /dev/null 2>&1
mount --move /newrun /run
rm -fr -- /newrun
fi
-if command -v kmod >/dev/null 2>/dev/null; then
- kmod static-nodes --format=tmpfiles 2>/dev/null | \
- while read type file mode a a a majmin || [ -n "$type" ]; do
+if command -v kmod > /dev/null 2> /dev/null; then
+ kmod static-nodes --format=tmpfiles 2> /dev/null \
+ | while read type file mode a a a majmin || [ -n "$type" ]; do
type=${type%\!}
case $type in
d)
if [ "$RD_DEBUG" = "yes" ]; then
mkfifo /run/initramfs/loginit.pipe
- loginit $DRACUT_QUIET </run/initramfs/loginit.pipe >/dev/console 2>&1 &
- exec >/run/initramfs/loginit.pipe 2>&1
+ loginit $DRACUT_QUIET < /run/initramfs/loginit.pipe > /dev/console 2>&1 &
+ exec > /run/initramfs/loginit.pipe 2>&1
else
- exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
+ exec 0<> /dev/console 1<> /dev/console 2<> /dev/console
fi
[ -f /usr/lib/initrd-release ] && . /usr/lib/initrd-release
getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
source_hook pre-trigger
-udevadm control --reload >/dev/null 2>&1 || :
+udevadm control --reload > /dev/null 2>&1 || :
# then the rest
-udevadm trigger --type=subsystems --action=add >/dev/null 2>&1
-udevadm trigger --type=devices --action=add >/dev/null 2>&1
+udevadm trigger --type=subsystems --action=add > /dev/null 2>&1
+udevadm trigger --type=devices --action=add > /dev/null 2>&1
make_trace_mem "hook initqueue" '1:shortmem' '2+:mem' '3+:slab'
getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue"
RDRETRY=$(getarg rd.retry -d 'rd_retry=')
RDRETRY=${RDRETRY:-180}
-RDRETRY=$(($RDRETRY*2))
+RDRETRY=$(($RDRETRY * 2))
export RDRETRY
main_loop=0
export main_loop
check_finished && break 2
done
- $UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
+ $UDEV_QUEUE_EMPTY > /dev/null 2>&1 || continue
for job in $hookdir/initqueue/settled/*.sh; do
[ -e "$job" ] || break
check_finished && break 2
done
- $UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
+ $UDEV_QUEUE_EMPTY > /dev/null 2>&1 || continue
# no more udev jobs and queues empty.
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
[ -e "$job" ] || break
job=$job . $job
- udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0
+ udevadm settle --timeout=0 > /dev/null 2>&1 || main_loop=0
[ -f $hookdir/initqueue/work ] && main_loop=0
done
fi
- main_loop=$(($main_loop+1))
+ main_loop=$(($main_loop + 1))
[ $main_loop -gt $RDRETRY ] \
- && { flock -s 9 ; emergency_shell "Could not boot."; } 9>/.console_lock
+ && {
+ flock -s 9
+ emergency_shell "Could not boot."
+ } 9> /.console_lock
done
unset job
unset queuetriggered
getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
source_hook pre-mount
-
getarg 'rd.break=mount' -d 'rdbreak=mount' && emergency_shell -n mount "Break mount"
# mount scripts actually try to mount the root filesystem, and may
# be sourced any number of times. As soon as one suceeds, no more are sourced.
_i_mount=0
while :; do
if ismounted "$NEWROOT"; then
- usable_root "$NEWROOT" && break;
+ usable_root "$NEWROOT" && break
umount "$NEWROOT"
fi
for f in $hookdir/mount/*.sh; do
[ -f "$f" ] && . "$f"
if ismounted "$NEWROOT"; then
- usable_root "$NEWROOT" && break;
+ usable_root "$NEWROOT" && break
warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f -- "$f"
fi
done
- _i_mount=$(($_i_mount+1))
+ _i_mount=$(($_i_mount + 1))
[ $_i_mount -gt 20 ] \
- && { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock
+ && {
+ flock -s 9
+ emergency_shell "Can't mount root filesystem"
+ } 9> /.console_lock
done
{
udevadm control --stop-exec-queue
HARD=""
- while pidof udevd >/dev/null 2>&1; do
+ while pidof udevd > /dev/null 2>&1; do
for pid in $(pidof udevd); do
- kill $HARD $pid >/dev/null 2>&1
+ kill $HARD $pid > /dev/null 2>&1
done
HARD="-9"
done
i=${i%%=*}
[ -z "$i" ] && continue
case $i in
- root|PATH|HOME|TERM|PS4|RD_*)
- :;;
+ root | PATH | HOME | TERM | PS4 | RD_*)
+ :
+ ;;
*)
- unset "$i";;
+ unset "$i"
+ ;;
esac
done
-. /tmp/export.orig 2>/dev/null || :
+. /tmp/export.orig 2> /dev/null || :
rm -f -- /tmp/export.orig
initargs=""
-read CLINE </proc/cmdline
-if getarg init= >/dev/null ; then
+read CLINE < /proc/cmdline
+if getarg init= > /dev/null; then
ignoreargs="console BOOT_IMAGE"
# only pass arguments after init= to the init
CLINE=${CLINE#*init=}
set -- $CLINE
for x in "$@"; do
case "$x" in
- [0-9]|s|S|single|emergency|auto ) \
+ [0-9] | s | S | single | emergency | auto)
initargs="$initargs $x"
;;
esac
# remove helper symlink
[ -h /dev/root ] && rm -f -- /dev/root
-bv=$(getarg rd.break -d rdbreak) && [ -z "$bv" ] &&
- emergency_shell -n switch_root "Break before switch_root"
+bv=$(getarg rd.break -d rdbreak) && [ -z "$bv" ] \
+ && emergency_shell -n switch_root "Break before switch_root"
unset bv
info "Switching root"
-
unset PS4
CAPSH=$(command -v capsh)
info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped."
unset RD_DEBUG
exec $CAPSH --drop="$CAPS_INIT_DROP" -- \
- -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" || \
- {
- warn "Command:"
- warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs
- warn "failed."
- emergency_shell
- }
+ -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" \
+ || {
+ warn "Command:"
+ warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs
+ warn "failed."
+ emergency_shell
+ }
else
unset RD_DEBUG
exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || {
- warn "Something went very badly wrong in the initramfs. Please "
- warn "file a bug against dracut."
- emergency_shell
+ warn "Something went very badly wrong in the initramfs. Please "
+ warn "file a bug against dracut."
+ emergency_shell
}
fi
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
while [ $# -gt 0 ]; do
case "$1" in
--onetime)
- onetime="yes";;
+ onetime="yes"
+ ;;
--online)
- qname="/online";;
+ qname="/online"
+ ;;
--settled)
- qname="/settled";;
+ qname="/settled"
+ ;;
--finished)
- qname="/finished";;
+ qname="/finished"
+ ;;
--timeout)
- qname="/timeout";;
+ qname="/timeout"
+ ;;
--unique)
- unique="yes";;
+ unique="yes"
+ ;;
--name)
- name="$2";shift;;
+ name="$2"
+ shift
+ ;;
--env)
- env="$2"; shift;;
+ env="$2"
+ shift
+ ;;
*)
- break;;
+ break
+ ;;
esac
shift
done
shift
[ -x "$exe" ] || exe=$(command -v $exe)
-if [ -z "$exe" ] ; then
+if [ -z "$exe" ]; then
echo "Invalid command"
exit 1
fi
printf -- "$$" > /run/initramfs/loginit.pid
-[ -e /dev/kmsg ] && exec 5>/dev/kmsg || exec 5>/dev/null
-exec 6>/run/initramfs/init.log
+[ -e /dev/kmsg ] && exec 5> /dev/kmsg || exec 5> /dev/null
+exec 6> /run/initramfs/init.log
while read line || [ -n "$line" ]; do
if [ "$line" = "DRACUT_LOG_END" ]; then
# add common users in /etc/passwd, it will be used by nfs/ssh currently
# use password for hostonly images to facilitate secure sulogin in emergency console
[[ $hostonly ]] && pwshadow='x'
- grep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo "root:$pwshadow:0:0::/root:/bin/sh" >> "$initdir/etc/passwd"
+ grep '^root:' "$initdir/etc/passwd" 2> /dev/null || echo "root:$pwshadow:0:0::/root:/bin/sh" >> "$initdir/etc/passwd"
grep '^nobody:' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd"
[[ $hostonly ]] && grep '^root:' "$dracutsysrootdir"/etc/shadow >> "$initdir/etc/shadow"
# Derive an os-release file from the host, if it exists
if [[ -e $dracutsysrootdir/etc/os-release ]]; then
. "$dracutsysrootdir"/etc/os-release
- grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' "$dracutsysrootdir"/etc/os-release >"${initdir}"/usr/lib/initrd-release
+ grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' "$dracutsysrootdir"/etc/os-release > "${initdir}"/usr/lib/initrd-release
[[ -n ${VERSION} ]] && VERSION+=" "
[[ -n ${PRETTY_NAME} ]] && PRETTY_NAME+=" "
else
echo ID=dracut
echo VERSION_ID=\"$DRACUT_VERSION\"
echo ANSI_COLOR='"0;34"'
- } >${initdir}/usr/lib/initrd-release
+ } > ${initdir}/usr/lib/initrd-release
fi
VERSION+="dracut-$DRACUT_VERSION"
PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)"
# for resume and udev rules generated when parsing resume=
# argument take care of the waiting for us
for _dev2 in "${swap_devs[@]}"; do
- [[ "$_dev" == "$_dev2" ]] && continue 2
+ [[ "$_dev" == "$_dev2" ]] && continue 2
done
_pdev=$(get_persistent_dev $_dev)
case "$_pdev" in
- /dev/?*) wait_for_dev $_pdev;;
+ /dev/?*) wait_for_dev $_pdev ;;
*) ;;
esac
done
if [ -z "$fstype" ]; then
fstype="auto"
fi
-
[ -d /run/initramfs ] || mkdir -p /run/initramfs
-exec >/run/initramfs/rdsosreport.txt 2>&1
+exec > /run/initramfs/rdsosreport.txt 2>&1
PWFILTER='s/\(ftp:\/\/.*\):.*@/\1:*******@/g;s/\(cifs:\/\/.*\):.*@/\1:*******@/g;s/cifspass=[^ ]*/cifspass=*******/g;s/iscsi:.*@/iscsi:******@/g;s/rd.iscsi.password=[^ ]*/rd.iscsi.password=******/g;s/rd.iscsi.in.password=[^ ]*/rd.iscsi.in.password=******/g'
set -x
cat $_i | sed -e "$PWFILTER"
done
-if command -v lvm >/dev/null 2>/dev/null; then
+if command -v lvm > /dev/null 2> /dev/null; then
lvm pvdisplay
lvm vgdisplay
lvm lvdisplay
fi
-command -v dmsetup >/dev/null 2>/dev/null && dmsetup ls --tree
+command -v dmsetup > /dev/null 2> /dev/null && dmsetup ls --tree
cat /proc/mdstat
-command -v ip >/dev/null 2>/dev/null && ip addr
+command -v ip > /dev/null 2> /dev/null && ip addr
-if command -v journalctl >/dev/null 2>/dev/null; then
+if command -v journalctl > /dev/null 2> /dev/null; then
journalctl -ab --no-pager -o short-monotonic | sed -e "$PWFILTER"
else
dmesg | sed -e "$PWFILTER"
[ -f /run/initramfs/init.log ] && cat /run/initramfs/init.log | sed -e "$PWFILTER"
fi
-
#!/bin/sh
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
fsck_ask_reboot() {
info "note - fsck suggests reboot, if you"
fsck_tail() {
[ $_ret -gt 0 ] && warn "$_drv returned with $_ret"
if [ $_ret -ge 4 ]; then
- [ -n "$_out" ] && echo "$_out"|vwarn
+ [ -n "$_out" ] && echo "$_out" | vwarn
fsck_ask_err
else
- [ -n "$_out" ] && echo "$_out"|vinfo
+ [ -n "$_out" ] && echo "$_out" | vinfo
[ $_ret -ge 2 ] && fsck_ask_reboot
fi
}
return 1
;;
ext?)
- type e2fsck >/dev/null 2>&1 &&
- _drv="fsck_drv_com e2fsck" &&
- return 0
+ type e2fsck > /dev/null 2>&1 \
+ && _drv="fsck_drv_com e2fsck" \
+ && return 0
;;
f2fs)
- type fsck.f2fs >/dev/null 2>&1 &&
- _drv="fsck_drv_com fsck.f2fs" &&
- return 0
- ;;
+ type fsck.f2fs > /dev/null 2>&1 \
+ && _drv="fsck_drv_com fsck.f2fs" \
+ && return 0
+ ;;
jfs)
- type jfs_fsck >/dev/null 2>&1 &&
- _drv="fsck_drv_com jfs_fsck" &&
- return 0
+ type jfs_fsck > /dev/null 2>&1 \
+ && _drv="fsck_drv_com jfs_fsck" \
+ && return 0
;;
reiserfs)
- type reiserfsck >/dev/null 2>&1 &&
- _drv="fsck_drv_com reiserfsck" &&
- return 0
+ type reiserfsck > /dev/null 2>&1 \
+ && _drv="fsck_drv_com reiserfsck" \
+ && return 0
;;
btrfs)
# type btrfsck >/dev/null 2>&1 &&
;;
nfs*)
# nfs can be a nop, returning success
- _drv=":" &&
- return 0
+ _drv=":" \
+ && return 0
;;
*)
- type fsck >/dev/null 2>&1 &&
- _drv="fsck_drv_std fsck" &&
- return 0
+ type fsck > /dev/null 2>&1 \
+ && _drv="fsck_drv_std fsck" \
+ && return 0
;;
esac
# note, we don't enforce -a here, thus fsck is being run (in theory)
# interactively; otherwise some tool might complain about lack of terminal
# (and using -a might not be safe)
- fsck $_fop "$_dev" >/dev/console 2>&1
+ fsck $_fop "$_dev" > /dev/console 2>&1
_ret=$?
fsck_tail
[ $# -lt 2 ] && return 255
# if UUID= marks more than one device, take only the first one
- [ -e "$_dev" ] || _dev=$(devnames "$_dev"| while read line || [ -n "$line" ]; do if [ -n "$line" ]; then echo $line; break;fi;done)
+ [ -e "$_dev" ] || _dev=$(devnames "$_dev" | while read line || [ -n "$line" ]; do if [ -n "$line" ]; then
+ echo $line
+ break
+ fi; done)
[ -e "$_dev" ] || return 255
_fs=$(det_fs "$_dev" "$_fs")
fsck_able "$_fs" || return 255
local _ret
local _out
- [ $# -eq 0 ] || ! type fsck >/dev/null 2>&1 && return 255
+ [ $# -eq 0 ] || ! type fsck > /dev/null 2>&1 && return 255
info "Checking filesystems (fsck -M -T -a):"
for _dev in "$@"; do
local _orig="${2:-auto}"
local _fs
- _fs=$(udevadm info --query=env --name="$_dev" | \
- while read line || [ -n "$line" ]; do
- if str_starts $line "ID_FS_TYPE="; then
- echo ${line#ID_FS_TYPE=}
- break
- fi
- done)
+ _fs=$(udevadm info --query=env --name="$_dev" \
+ | while read line || [ -n "$line" ]; do
+ if str_starts $line "ID_FS_TYPE="; then
+ echo ${line#ID_FS_TYPE=}
+ break
+ fi
+ done)
_fs=${_fs:-auto}
if [ "$_fs" = "auto" ]; then
for _o in $CMDLINE; do
case $_o in
rw)
- _rw=1;;
+ _rw=1
+ ;;
ro)
- _rw=0;;
+ _rw=0
+ ;;
esac
done
if [ "$_rw" = "1" ]; then
return
fi
- if type systemctl >/dev/null 2>/dev/null; then
+ if type systemctl > /dev/null 2> /dev/null; then
systemctl daemon-reload
systemctl --no-block start initrd-root-fs.target
fi
return 0
}
-
echo_fs_helper() {
local dev=$1 fs=$2
case "$fs" in
include_fs_helper_modules() {
local dev=$1 fs=$2
case "$fs" in
- xfs|btrfs|ext4)
+ xfs | btrfs | ext4)
instmods crc32c
;;
f2fs)
#
# TODO: identify/unpack rpm, deb, maybe others?
-
# super-simple "file" that only identifies archives.
# works with stdin if $1 is not set.
det_archive() {
# NOTE: echo -e works in ash and bash, but not dash
local bz="BZh" xz="$(echo -e '\xfd7zXZ')" gz="$(echo -e '\x1f\x8b')" zs="$(echo -e '\x28\xB5\x2F\xFD')"
- local headerblock="$(dd ${1:+if=$1} bs=262 count=1 2>/dev/null)"
+ local headerblock="$(dd ${1:+if=$1} bs=262 count=1 2> /dev/null)"
case "$headerblock" in
$xz*) echo "xz" ;;
$gz*) echo "gzip" ;;
# determine filesystem type for a filesystem image
det_fs_img() {
local dev=$(losetup --find --show "$1") rv=""
- det_fs $dev; rv=$?
+ det_fs $dev
+ rv=$?
losetup -d $dev
return $rv
}
local img="$1" outdir="$2" archiver="" decompr=""
local ft="$(det_archive $img)"
case "$ft" in
- xz|gzip|bzip2|zstd) decompr="$ft -dc" ;;
- cpio|tar) decompr="cat";;
+ xz | gzip | bzip2 | zstd) decompr="$ft -dc" ;;
+ cpio | tar) decompr="cat" ;;
*) return 1 ;;
esac
ft="$($decompr $img | det_archive)"
*) return 2 ;;
esac
mkdir -p $outdir
- ( cd $outdir; $decompr | $archiver 2>/dev/null ) < $img
+ (
+ cd $outdir
+ $decompr | $archiver 2> /dev/null
+ ) < $img
}
# unpack_fs FSIMAGE OUTDIR
# unpack a filesystem image
unpack_fs() {
local img="$1" outdir="$2" mnt="$(mkuniqdir /tmp unpack_fs.)"
- mount -o loop $img $mnt || { rmdir $mnt; return 1; }
- mkdir -p $outdir; outdir="$(cd $outdir; pwd)"
+ mount -o loop $img $mnt || {
+ rmdir $mnt
+ return 1
+ }
+ mkdir -p $outdir
+ outdir="$(
+ cd $outdir
+ pwd
+ )"
copytree $mnt $outdir
umount $mnt
rmdir $mnt
# unpack_img IMAGEFILE OUTDIR
unpack_img() {
local img="$1" outdir="$2"
- [ -r "$img" ] || { warn "can't read img!"; return 1; }
- [ -n "$outdir" ] || { warn "unpack_img: no output dir given"; return 1; }
+ [ -r "$img" ] || {
+ warn "can't read img!"
+ return 1
+ }
+ [ -n "$outdir" ] || {
+ warn "unpack_img: no output dir given"
+ return 1
+ }
if [ "$(det_archive $img)" ]; then
- unpack_archive "$@" || { warn "can't unpack archive file!"; return 1; }
+ unpack_archive "$@" || {
+ warn "can't unpack archive file!"
+ return 1
+ }
else
- unpack_fs "$@" || { warn "can't unpack filesystem image!"; return 1; }
+ unpack_fs "$@" || {
+ warn "can't unpack filesystem image!"
+ return 1
+ }
fi
}
inst_multiple -o cpio xz bzip2 zstd
inst_simple "$moddir/img-lib.sh" "/lib/img-lib.sh"
}
-
return 0
fi
-if type -P systemctl >/dev/null; then
+if type -P systemctl > /dev/null; then
systemctl stop memstrack.service
else
- get_pid_of_tracer () {
+ get_pid_of_tracer() {
local _user _pid _rest
read _user _pid _rest <<< $(ps aux | grep [m]emstrack | head -1)
echo $_pid
# memdebug=4 and memdebug=5 requires debug fs to be mounted.
# And there is no need to umount it.
-type getargnum >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type getargnum > /dev/null 2>&1 || . /lib/dracut-lib.sh
# "sys/kernel/tracing" has the priority if exists.
get_trace_base() {
fi
}
-if ! is_debugfs_ready ; then
+if ! is_debugfs_ready; then
prepare_debugfs
fi
echo "memstrack - will report memory usage summary"
memstrack --report module_summary --notui --throttle 80 -o /.memstrack &
else
- exit 0;
+ exit 0
fi
fi
#!/bin/bash
check() {
- if find_binary memstrack >/dev/null; then
+ if find_binary memstrack > /dev/null; then
dinfo "memstrack is available"
return 0
fi
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
done
}
-
# and that it can actually be used. When console=null is used,
# echo will fail. We do the check in a subshell, because otherwise
# the process will be killed when when running as PID 1.
-[ -w /dev/console ] && \
- ( echo </dev/console &>/dev/null ) && \
- exec </dev/console >>/dev/console 2>>/dev/console
+[ -w /dev/console ] \
+ && (echo < /dev/console &> /dev/null) \
+ && exec < /dev/console >> /dev/console 2>> /dev/console
export TERM=linux
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
# if "kexec" was installed after creating the initramfs, we try to copy it from the real root
# libz normally is pulled in via kmod/modprobe and udevadm
-if [ "$ACTION" = "kexec" ] && ! command -v kexec >/dev/null 2>&1; then
+if [ "$ACTION" = "kexec" ] && ! command -v kexec > /dev/null 2>&1; then
for p in /usr/sbin /usr/bin /sbin /bin; do
- cp -a /oldroot/${p}/kexec $p >/dev/null 2>&1 && break
+ cp -a /oldroot/${p}/kexec $p > /dev/null 2>&1 && break
done
hash kexec
fi
umount_a() {
local _verbose="n"
if [ "$1" = "-v" ]; then
- _verbose="y"; shift
+ _verbose="y"
+ shift
exec 7>&2
else
- exec 7>/dev/null
+ exec 7> /dev/null
fi
local _did_umount="n"
# indefinitely if this is e.g. a stuck NFS mount. The command is
# invoked in a subshell to silence also the "Killed" message that might
# be produced by the shell.
- (set +m; timeout --signal=KILL "$_umount_timeout" umount "$mp") 2>&7
+ (
+ set +m
+ timeout --signal=KILL "$_umount_timeout" umount "$mp"
+ ) 2>&7
local ret=$?
if [ $ret -eq 0 ]; then
_did_umount="y"
elif [ "$_verbose" = "y" ]; then
warn "Unmounting $mp failed with status $ret."
fi
- done </proc/mounts
+ done < /proc/mounts
losetup -D 2>&7
_cnt=0
while [ $_cnt -le 40 ]; do
umount_a || break
- _cnt=$(($_cnt+1))
+ _cnt=$(($_cnt + 1))
done
[ $_cnt -ge 40 ] && umount_a -v
for _pid in /proc/*; do
_pid=${_pid##/proc/}
case $_pid in
- *[!0-9]*) continue;;
+ *[!0-9]*) continue ;;
esac
[ $_pid -eq $$ ] && continue
[ -e "/proc/$_pid/exe" ] || continue
[ -e "/proc/$_pid/root" ] || continue
- if strstr "$(ls -l /proc/$_pid /proc/$_pid/fd 2>/dev/null)" "oldroot"; then
+ if strstr "$(ls -l /proc/$_pid /proc/$_pid/fd 2> /dev/null)" "oldroot"; then
warn "Blocking umount of /oldroot [$_pid] $(cat /proc/$_pid/cmdline)"
else
warn "Still running [$_pid] $(cat /proc/$_pid/cmdline)"
local __s=0
for __f in $hookdir/shutdown/*.sh; do
[ -e "$__f" ] || continue
- ( . "$__f" $1 )
+ (. "$__f" $1)
if [ $? -eq 0 ]; then
rm -f -- $__f
else
_cnt=0
while [ $_cnt -le 40 ]; do
_check_shutdown && break
- _cnt=$(($_cnt+1))
+ _cnt=$(($_cnt + 1))
done
[ $_cnt -ge 40 ] && _check_shutdown final
getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"
case "$ACTION" in
- reboot|poweroff|halt)
+ reboot | poweroff | halt)
$ACTION -f -n
warn "$ACTION failed!"
;;
check() {
require_binaries mksquashfs unsquashfs || return 1
- for i in CONFIG_SQUASHFS CONFIG_BLK_DEV_LOOP CONFIG_OVERLAY_FS ; do
+ for i in CONFIG_SQUASHFS CONFIG_BLK_DEV_LOOP CONFIG_OVERLAY_FS; do
if ! check_kernel_config $i; then
dinfo "dracut-squash module requires kernel configuration $i (y or m)"
return 1
install() {
inst_simple "$moddir/uefi-lib.sh" "/lib/uefi-lib.sh"
}
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-getbyte () {
+getbyte() {
local IFS= LC_CTYPE=C res c=0
read -r -n 1 -d '' c
res=$?
return $res
}
-getword () {
+getword() {
local b1=0 b2=0 val=0
b1=$(getbyte)
b2=$(getbyte)
- (( val = b2 * 256 + b1 ))
+ ((val = b2 * 256 + b1))
echo $val
return 0
}
# Acpi(PNP0A08,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/MAC(90E2BA265ED4,0x0)/Vlan(172)/Fibre(0x4EA06104A0CC0050,0x0)
-uefi_device_path()
-{
+uefi_device_path() {
data=${1:-/sys/firmware/efi/efivars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac}
[ -f "$data" ] || return 1
local IFS= LC_CTYPE=C res tt len type hextype first
first=1
{
- getword >/dev/null
- getword >/dev/null
+ getword > /dev/null
+ getword > /dev/null
while :; do
type=$(getbyte) || return 1
subtype=$(getbyte) || return 1
;;
0303)
# FIBRE
- getword &>/dev/null
- getword &>/dev/null
+ getword &> /dev/null
+ getword &> /dev/null
printf "Fibre(0x%x%x%x%x%x%x%x%x,0x%x)" \
- $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
- $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
- $(( $(getword) + $(getword) * 65536 + 4294967296 * ( $(getword) + $(getword) * 65536 ) ))
+ $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
+ $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
+ $(($(getword) + $(getword) * 65536 + 4294967296 * ($(getword) + $(getword) * 65536)))
;;
030b)
# MAC
printf "MAC(%02x%02x%02x%02x%02x%02x," $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte)
- for((i=0; i<26; i++)); do tt=$(getbyte) || return 1; done
+ for ((i = 0; i < 26; i++)); do tt=$(getbyte) || return 1; done
#read -r -d '' -n 26 tt || return 1
- printf "0x%x)" $(getbyte)
+ printf "0x%x)" $(getbyte)
;;
0314)
# VLAN
;;
*)
#printf "Unknown(Type:0x%02x SubType:0x%02x len=%d)\n" "$type" "$subtype" "$len" >&2
- for((i=0; i<len-4; i++)); do tt=$(getbyte); done
+ for ((i = 0; i < len - 4; i++)); do tt=$(getbyte); done
;;
esac
done
# /home/harald/Downloads/FcoeBootDevice-80005007-4248-4e4b-8df4-93060220756f
-get_fcoe_boot_mac()
-{
+get_fcoe_boot_mac() {
data=${1:-/sys/firmware/efi/efivars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac}
[ -f "$data" ] || return 1
local IFS= LC_CTYPE=C tt len type hextype
{
- getword >/dev/null
- getword >/dev/null
+ getword > /dev/null
+ getword > /dev/null
while :; do
type=$(getbyte) || return 1
subtype=$(getbyte) || return 1
030b)
# MAC
printf "%02x:%02x:%02x:%02x:%02x:%02x" $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte)
- for((i=0; i<27; i++)); do tt=$(getbyte) || return 1; done
+ for ((i = 0; i < 27; i++)); do tt=$(getbyte) || return 1; done
;;
7fff)
# END
;;
*)
#printf "Unknown(Type:0x%02x SubType:0x%02x len=%d)\n" "$type" "$subtype" "$len" >&2
- for((i=0; i<len-4; i++)); do tt=$(getbyte); done
+ for ((i = 0; i < len - 4; i++)); do tt=$(getbyte); done
;;
esac
done
} < "$data"
}
-get_fcoe_boot_vlan()
-{
+get_fcoe_boot_vlan() {
data=${1:-/sys/firmware/efi/efivars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac}
[ -f "$data" ] || return 1
local IFS= LC_CTYPE=C tt len type hextype
{
- getword >/dev/null
- getword >/dev/null
+ getword > /dev/null
+ getword > /dev/null
while :; do
type=$(getbyte) || return 1
subtype=$(getbyte) || return 1
;;
*)
#printf "Unknown(Type:0x%02x SubType:0x%02x len=%d)\n" "$type" "$subtype" "$len" >&2
- for((i=0; i<len; i++)); do tt=$(getbyte); done
+ for ((i = 0; i < len; i++)); do tt=$(getbyte); done
;;
esac
done
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
-
#!/bin/sh
->/dev/watchdog
+> /dev/watchdog
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
echo "made it to the rootfs!"
if getargbool 0 rd.shell; then
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
echo "Powering down."
mount -n -o remount,ro /
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient \
- umount strace less setsid dd
+ mount dmesg dhclient mkdir cp ping dhclient \
+ umount strace less setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
-
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -a "debug watchdog" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -a "debug watchdog" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
umount /root
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
poweroff -f
-
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
-
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
plymouth --quit
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
echo "made it to the rootfs!"
if getargbool 0 rd.shell; then
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
echo "Powering down."
mount -n -o remount,ro /
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient \
- umount strace less setsid systemd-analyze dd
+ mount dmesg dhclient mkdir cp ping dhclient \
+ umount strace less setsid systemd-analyze dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
-
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -a "debug systemd" \
- -o "network kernel-network-modules" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -a "debug systemd" \
+ -o "network kernel-network-modules" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}
udevadm settle
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
-sfdisk /dev/sdb <<EOF
+sfdisk /dev/sdb << EOF
,1M
,
EOF
#!/bin/sh
->/dev/watchdog
+> /dev/watchdog
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
ismounted() {
while read a m a || [ -n "$m" ]; do
stty sane
echo "made it to the rootfs!"
if getargbool 0 rd.shell; then
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
echo "Powering down."
mount -n -o remount,ro /
#DEBUGFAIL="rd.shell rd.break"
client_run() {
- local test_name="$1"; shift
+ local test_name="$1"
+ shift
local client_opts="$*"
echo "CLIENT TEST START: $test_name"
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient \
- umount strace less setsid dd
+ mount dmesg dhclient mkdir cp ping dhclient \
+ umount strace less setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_simple ./fstab /etc/fstab
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
- --nomdadmconf \
- --nohardlink \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
+ --nomdadmconf \
+ --nohardlink \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
if ! grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs; then
echo "Could not create root filesystem"
return 1
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -a "debug watchdog" \
- -o "network kernel-network-modules" \
- -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -a "debug watchdog" \
+ -o "network kernel-network-modules" \
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
udevadm settle
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
-sfdisk /dev/sdb <<EOF
+sfdisk /dev/sdb << EOF
,1M
,
EOF
#!/bin/sh
->/dev/watchdog
+> /dev/watchdog
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
ismounted() {
while read a m a || [ -n "$a" ]; do
stty sane
echo "made it to the rootfs!"
if getargbool 0 rd.shell; then
-# while sleep 1; do sleep 1;done
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ # while sleep 1; do sleep 1;done
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
set -x
/usr/bin/systemctl poweroff
#DEBUGOUT="quiet systemd.log_level=debug systemd.log_target=console loglevel=77 rd.info rd.debug"
DEBUGOUT="loglevel=0 "
client_run() {
- local test_name="$1"; shift
+ local test_name="$1"
+ shift
local client_opts="$*"
echo "CLIENT TEST START: $test_name"
ln -sfn /run/lock "$initdir/var/lock"
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg mkdir cp ping dd \
- umount strace less setsid tree systemctl reset
+ mount dmesg mkdir cp ping dd \
+ umount strace less setsid tree systemctl reset
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
mkdir -p $initdir/var/log/journal
# install some basic config files
- inst_multiple -o \
- /etc/machine-id \
- /etc/adjtime \
- /etc/passwd \
- /etc/shadow \
- /etc/group \
- /etc/shells \
- /etc/nsswitch.conf \
- /etc/pam.conf \
- /etc/securetty \
- /etc/os-release \
- /etc/localtime
+ inst_multiple -o \
+ /etc/machine-id \
+ /etc/adjtime \
+ /etc/passwd \
+ /etc/shadow \
+ /etc/group \
+ /etc/shells \
+ /etc/nsswitch.conf \
+ /etc/pam.conf \
+ /etc/securetty \
+ /etc/os-release \
+ /etc/localtime
# we want an empty environment
> $initdir/etc/environment
# setup the testsuite target
mkdir -p $initdir/etc/systemd/system
- cat >$initdir/etc/systemd/system/testsuite.target <<EOF
+ cat > $initdir/etc/systemd/system/testsuite.target << EOF
[Unit]
Description=Testsuite target
Requires=basic.target
inst ./test-init.sh /sbin/test-init
# setup the testsuite service
- cat >$initdir/etc/systemd/system/testsuite.service <<EOF
+ cat > $initdir/etc/systemd/system/testsuite.service << EOF
[Unit]
Description=Testsuite service
After=basic.target
# install basic tools needed
inst_multiple sh bash setsid loadkeys setfont \
- login sushell sulogin gzip sleep echo mount umount
+ login sushell sulogin gzip sleep echo mount umount
inst_multiple modprobe
# install libnss_files for login
/lib64/security \
/lib/security -xtype f \
| while read file || [ -n "$file" ]; do
- inst_multiple -o $file
- done
+ inst_multiple -o $file
+ done
# install dbus socket and service file
inst /usr/lib/systemd/system/dbus.socket
(
echo "FONT=eurlatgr"
echo "KEYMAP=us"
- ) >$initrd/etc/vconsole.conf
+ ) > $initrd/etc/vconsole.conf
# install basic keyboard maps and fonts
for i in \
# install any Execs from the service files
grep -Eho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
| while read i || [ -n "$i" ]; do
- i=${i##Exec*=}; i=${i##-}
- inst_multiple -o $i
- done
+ i=${i##Exec*=}
+ i=${i##-}
+ inst_multiple -o $i
+ done
# some helper tools for debugging
[[ $DEBUGTOOLS ]] && inst_multiple $DEBUGTOOLS
inst /lib/modules/$kernel/modules.order
inst /lib/modules/$kernel/modules.builtin
# generate module dependencies
- if [[ -d $initdir/lib/modules/$kernel ]] && \
- ! depmod -a -b "$initdir" $kernel; then
+ if [[ -d $initdir/lib/modules/$kernel ]] \
+ && ! depmod -a -b "$initdir" $kernel; then
dfatal "\"depmod -a $kernel\" failed."
exit 1
fi
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
- --nomdadmconf \
- --nohardlink \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
+ --nomdadmconf \
+ --nohardlink \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
rm -rf -- $TESTDIR/overlay
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
if ! grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/result; then
echo "Could not create root filesystem"
return 1
[ -e /etc/machine-info ] && EXTRA_MACHINE+=" /etc/machine-info"
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -a "debug systemd i18n qemu" \
- ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
- -o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules rngd" \
- -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -a "debug systemd i18n qemu" \
+ ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
+ -o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules rngd" \
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
}
udevadm control --reload
udevadm settle
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,4M
,41M
,41M
# randomly.
mdadm -W /dev/md0
set -e
-printf test >keyfile
+printf test > keyfile
cryptsetup -q luksFormat /dev/md0 /keyfile
echo "The passphrase is test"
-cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile
-lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
+cryptsetup luksOpen /dev/md0 dracut_crypt_test < /keyfile
+lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
lvm vgcreate dracut /dev/mapper/dracut_crypt_test
-lvm lvcreate -l 100%FREE -n root dracut && \
-lvm vgchange -ay
+lvm lvcreate -l 100%FREE -n root dracut \
+ && lvm vgchange -ay
mke2fs /dev/dracut/root
mkdir -p /sysroot
mount /dev/dracut/root /sysroot
udevadm settle
cryptsetup luksClose /dev/mapper/dracut_crypt_test
udevadm settle
-eval $(udevadm info --query=env --name=/dev/md0|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
-{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } | dd oflag=direct,dsync of=/dev/sda1
+eval $(udevadm info --query=env --name=/dev/md0 | while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done)
+{
+ echo "dracut-root-block-created"
+ echo "ID_FS_UUID=$ID_FS_UUID"
+} | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
#!/bin/sh
[ -b "/dev/mapper/$2" ] && exit 0
-printf test >/keyfile
-/sbin/cryptsetup luksOpen "$1" "$2" </keyfile
+printf test > /keyfile
+/sbin/cryptsetup luksOpen "$1" "$2" < /keyfile
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
-command -v plymouth >/dev/null && plymouth --quit
-exec >/dev/console 2>&1
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
+command -v plymouth > /dev/null && plymouth --quit
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient dd
+ mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_multiple -o /lib/systemd/systemd-shutdown
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-append "root=/dev/cannotreach rw rootfstype=ext2 console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
eval $(grep -F -a -m 1 ID_FS_UUID $DISKIMAGE)
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
udevadm control --reload
udevadm settle
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,2M
,20M
,20M
EOF
udevadm settle
for i in sda2 sda3 sda4; do
-lvm pvcreate -ff -y /dev/$i ;
-done && \
-lvm vgcreate dracut /dev/sda[234] && \
-lvm lvcreate -l 100%FREE -n root dracut && \
-lvm vgchange -ay && \
-mke2fs /dev/dracut/root && \
-mkdir -p /sysroot && \
-mount /dev/dracut/root /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-sleep 1 && \
-lvm lvchange -a n /dev/dracut/root && \
-sleep 1 && \
-echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
+ lvm pvcreate -ff -y /dev/$i
+done \
+ && lvm vgcreate dracut /dev/sda[234] \
+ && lvm lvcreate -l 100%FREE -n root dracut \
+ && lvm vgchange -ay \
+ && mke2fs /dev/dracut/root \
+ && mkdir -p /sysroot \
+ && mount /dev/dracut/root /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && sleep 1 \
+ && lvm lvchange -a n /dev/dracut/root \
+ && sleep 1 \
+ && echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient dd
+ mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir -p $initdir/run
ldconfig -r "$initdir"
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
- -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
(
export initdir=$TESTDIR/overlay
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
-printf test >keyfile
+printf test > keyfile
cryptsetup -q luksFormat /dev/md0 /keyfile
echo "The passphrase is test"
set -e
set -x
-cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile
-lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
+cryptsetup luksOpen /dev/md0 dracut_crypt_test < /keyfile
+lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
lvm vgcreate dracut /dev/mapper/dracut_crypt_test
lvm lvcreate -l 100%FREE -n root dracut
lvm vgchange -ay
udevadm settle
mdadm -W /dev/md0 || :
udevadm settle
-mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
+mdadm --detail --export /dev/md0 | grep -F MD_UUID > /tmp/mduuid
. /tmp/mduuid
udevadm settle
-eval $(udevadm info --query=env --name=/dev/md0|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
-{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; echo "ID_FS_UUID=$ID_FS_UUID";} | dd oflag=direct,dsync of=/dev/sda
+eval $(udevadm info --query=env --name=/dev/md0 | while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done)
+{
+ echo "dracut-root-block-created"
+ echo MD_UUID=$MD_UUID
+ echo "ID_FS_UUID=$ID_FS_UUID"
+} | dd oflag=direct,dsync of=/dev/sda
sync
poweroff -f
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
-printf test >/keyfile
-/sbin/cryptsetup luksOpen $1 $2 </keyfile
-
+printf test > /keyfile
+/sbin/cryptsetup luksOpen $1 $2 < /keyfile
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
-command -v plymouth >/dev/null && plymouth --quit
-exec >/dev/console 2>&1
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
+command -v plymouth > /dev/null && plymouth --quit
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda
export TERM=linux
export PS1='initramfs-test:\w\$ '
-initrd $TESTDIR/initramfs.testing
if ! grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success $TESTDIR/marker.img; then
echo "CLIENT TEST END: $@ [FAIL]"
- return 1;
+ return 1
fi
rm -f -- $TESTDIR/marker.img
dd if=/dev/zero of=$TESTDIR/marker.img bs=1M count=40
client_run failme && return 1
client_run rd.auto || return 1
-
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.md.conf=0 rd.lvm.vg=dracut || return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=failme rd.md.conf=0 rd.lvm.vg=dracut failme && return 1
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient dd
+ mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/marker.img || return 1
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/marker.img)
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
udevadm control --reload
udevadm settle
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,4M
,43M
,43M
,43M
EOF
udevadm settle
-printf test >keyfile
+printf test > keyfile
cryptsetup -q luksFormat /dev/sda2 /keyfile
cryptsetup -q luksFormat /dev/sda3 /keyfile
cryptsetup -q luksFormat /dev/sda4 /keyfile
-cryptsetup luksOpen /dev/sda2 dracut_sda2 </keyfile
-cryptsetup luksOpen /dev/sda3 dracut_sda3 </keyfile
-cryptsetup luksOpen /dev/sda4 dracut_sda4 </keyfile
+cryptsetup luksOpen /dev/sda2 dracut_sda2 < /keyfile
+cryptsetup luksOpen /dev/sda3 dracut_sda3 < /keyfile
+cryptsetup luksOpen /dev/sda4 dracut_sda4 < /keyfile
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/mapper/dracut_sda2 /dev/mapper/dracut_sda3 /dev/mapper/dracut_sda4
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
-lvm pvcreate -ff -y /dev/md0 && \
-lvm vgcreate dracut /dev/md0 && \
-lvm lvcreate -l 100%FREE -n root dracut && \
-lvm vgchange -ay && \
-mke2fs /dev/dracut/root && \
-mkdir -p /sysroot && \
-mount /dev/dracut/root /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-sleep 2 && \
-lvm lvchange -a n /dev/dracut/root && \
-sleep 2 && \
-lvm vgchange -a n dracut && \
-{
-lvm vgdisplay && \
-{ mdadm -W /dev/md0 || :;} && \
-mdadm --stop /dev/md0 && \
-cryptsetup luksClose /dev/mapper/dracut_sda2 && \
-cryptsetup luksClose /dev/mapper/dracut_sda3 && \
-cryptsetup luksClose /dev/mapper/dracut_sda4 && \
-:; :;} && \
-{
- echo "dracut-root-block-created"
- for i in /dev/sda[234]; do
- udevadm info --query=env --name=$i|grep -F 'ID_FS_UUID='
- done
-} | dd oflag=direct,dsync of=/dev/sda1
+lvm pvcreate -ff -y /dev/md0 \
+ && lvm vgcreate dracut /dev/md0 \
+ && lvm lvcreate -l 100%FREE -n root dracut \
+ && lvm vgchange -ay \
+ && mke2fs /dev/dracut/root \
+ && mkdir -p /sysroot \
+ && mount /dev/dracut/root /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && sleep 2 \
+ && lvm lvchange -a n /dev/dracut/root \
+ && sleep 2 \
+ && lvm vgchange -a n dracut \
+ && {
+ lvm vgdisplay \
+ && { mdadm -W /dev/md0 || :; } \
+ && mdadm --stop /dev/md0 \
+ && cryptsetup luksClose /dev/mapper/dracut_sda2 \
+ && cryptsetup luksClose /dev/mapper/dracut_sda3 \
+ && cryptsetup luksClose /dev/mapper/dracut_sda4 \
+ && :
+ :
+ } \
+ && {
+ echo "dracut-root-block-created"
+ for i in /dev/sda[234]; do
+ udevadm info --query=env --name=$i | grep -F 'ID_FS_UUID='
+ done
+ } | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
-printf test >/keyfile
-/sbin/cryptsetup luksOpen $1 $2 </keyfile
-
+printf test > /keyfile
+/sbin/cryptsetup luksOpen $1 $2 < /keyfile
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient dd
+ mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
- -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
- cryptoUUIDS=$(grep -F --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2)
+ cryptoUUIDS=$(grep -F --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2)
for uuid in $cryptoUUIDS; do
eval $uuid
printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID
done > $TESTDIR/luks.txt
-
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
for uuid in $cryptoUUIDS; do
eval $uuid
printf 'luks-%s /dev/sda%s /etc/key timeout=0\n' $ID_FS_UUID $i
- ((i+=1))
+ ((i += 1))
done > $initdir/etc/crypttab
echo -n test > $initdir/etc/key
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
udevadm settle
# dmraid does not want symlinks in --disk "..."
-if [ -e /dev/hda ] ; then
- echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/hdb /dev/hdc"
+if [ -e /dev/hda ]; then
+ echo y | dmraid -f isw -C Test0 --type 1 --disk "/dev/hdb /dev/hdc"
else
- echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/sdb /dev/sdc"
+ echo y | dmraid -f isw -C Test0 --type 1 --disk "/dev/sdb /dev/sdc"
fi
udevadm settle
SETS=$(dmraid -c -s)
# scan and activate all DM RAIDS
for s in $SETS; do
- dmraid -ay -i -p --rm_partitions "$s"
- [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s"
+ dmraid -ay -i -p --rm_partitions "$s"
+ [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s"
done
udevadm settle
sfdisk -g /dev/mapper/isw*Test0
# save a partition at the beginning for future flagging purposes
-sfdisk --no-reread /dev/mapper/isw*Test0 <<EOF
+sfdisk --no-reread /dev/mapper/isw*Test0 << EOF
,4M
,28M
,28M
SETS=$(dmraid -c -s -i)
# scan and activate all DM RAIDS
for s in $SETS; do
- dmraid -ay -i -p --rm_partitions "$s"
- [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s"
+ dmraid -ay -i -p --rm_partitions "$s"
+ [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s"
done
udevadm settle
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 \
- /dev/mapper/isw*p2 \
- /dev/mapper/isw*p3 \
- /dev/mapper/isw*p4
+ /dev/mapper/isw*p2 \
+ /dev/mapper/isw*p3 \
+ /dev/mapper/isw*p4
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
set -e
-lvm pvcreate -ff -y /dev/md0
+lvm pvcreate -ff -y /dev/md0
lvm vgcreate dracut /dev/md0
lvm lvcreate -l 100%FREE -n root dracut
lvm vgchange -ay
umount /sysroot
lvm lvchange -a n /dev/dracut/root
udevadm settle
-mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
+mdadm --detail --export /dev/md0 | grep -F MD_UUID > /tmp/mduuid
. /tmp/mduuid
echo "MD_UUID=$MD_UUID"
-{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID;} | dd oflag=direct,dsync of=/dev/sda
+{
+ echo "dracut-root-block-created"
+ echo MD_UUID=$MD_UUID
+} | dd oflag=direct,dsync of=/dev/sda
mdadm --wait-clean /dev/md0
sync
poweroff -f
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
-printf test >/keyfile
-/sbin/cryptsetup luksOpen $1 $2 </keyfile
-
+printf test > /keyfile
+/sbin/cryptsetup luksOpen $1 $2 < /keyfile
#!/bin/sh
-getargbool 0 rd.shell || poweroff -f
-getargbool 0 failme && poweroff -f
+getargbool 0 rd.shell || poweroff -f
+getargbool 0 failme && poweroff -f
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda
export TERM=linux
export PS1='initramfs-test:\w\$ '
if ! grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success $TESTDIR/marker.img; then
echo "CLIENT TEST END: $@ [FAIL]"
- return 1;
+ return 1
fi
echo "CLIENT TEST END: $@ [OK]"
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient dd
+ mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir -p $initdir/run
ldconfig -r "$initdir"
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash lvm mdraid dmraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash lvm mdraid dmraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/marker.img || return 1
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/marker.img)
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
udevadm control --reload
udevadm settle
# save a partition at the beginning for future flagging purposes
-sfdisk -X gpt /dev/sda <<EOF
+sfdisk -X gpt /dev/sda << EOF
,10M
,200M
,200M
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda
sync
export TERM=linux
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient sync dd
+ mount dmesg dhclient mkdir cp ping dhclient sync dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst ./test-init.sh /sbin/init
inst_simple /etc/os-release
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash btrfs udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash btrfs udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
dd if=$DISKIMAGE bs=512 count=4 skip=2048 | grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created || return 1
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
#DEBUGFAIL="rd.shell rd.break rd.debug systemd.log_level=debug systemd.log_target=console"
test_check() {
- for pdir in $(python -c "import site; print(site.getsitepackages())" | sed -e 's/\[\(.*\)\]/\1/' -e "s/', /' /g") ; do
+ for pdir in $(python -c "import site; print(site.getsitepackages())" | sed -e 's/\[\(.*\)\]/\1/' -e "s/', /' /g"); do
pdir1=$(echo $pdir | sed "s/^'\(.*\)'$/\1/")
if [[ -d $pdir1/imgcreate ]]; then
return 0
test_run() {
"$testdir"/run-qemu \
- -boot order=d \
- -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
- -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
- -append "panic=1 systemd.crash_reboot root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
- -initrd "$TESTDIR"/initramfs.testing
+ -boot order=d \
+ -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
+ -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
+ -append "panic=1 systemd.crash_reboot root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
+ -initrd "$TESTDIR"/initramfs.testing
# mediacheck test with qemu GUI
# "$testdir"/run-qemu \
- # -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
- # -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
- # -m 512M -smp 2 \
- # -net none \
- # -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
- # -initrd "$TESTDIR"/initramfs.testing
+ # -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
+ # -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
+ # -m 512M -smp 2 \
+ # -net none \
+ # -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
+ # -initrd "$TESTDIR"/initramfs.testing
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/root.img || return 1
}
dd if=/dev/zero of="$TESTDIR"/root.img count=100
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
- -a "debug dmsquash-live qemu" \
- -o "rngd" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
+ -a "debug dmsquash-live qemu" \
+ -o "rngd" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
mkdir -p -- "$TESTDIR"/root-source
kernel="$KVERSION"
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient \
- umount strace less dd
+ mount dmesg dhclient mkdir cp ping dhclient \
+ umount strace less dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
done
VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
if ! [[ -e $VMLINUZ ]]; then
- if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
+ if [[ $MACHINE_ID ]] && ([[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]); then
VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
fi
fi
[[ -e $VMLINUZ ]] || VMLINUZ="/boot/vmlinuz-${KVERSION}"
inst "$VMLINUZ" "/boot/vmlinuz-${KVERSION}"
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a -- /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
)
udevadm control --reload
udevadm settle
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,4M
,29M
,29M
EOF
udevadm settle
for i in sda2 sda3 sda4; do
-lvm pvcreate -ff -y /dev/$i ;
-done && \
-lvm vgcreate dracut /dev/sda[234] && \
-lvm lvcreate -l 17 -T dracut/mythinpool && \
-lvm lvcreate -V1G -T dracut/mythinpool -n root && \
-lvm vgchange -ay && \
-mke2fs /dev/dracut/root && \
-mkdir -p /sysroot && \
-mount /dev/dracut/root /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-sleep 1 && \
-lvm lvchange -a n /dev/dracut/root && \
-sleep 1
-dmsetup status |grep out_of_data_space || \
- echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
+ lvm pvcreate -ff -y /dev/$i
+done \
+ && lvm vgcreate dracut /dev/sda[234] \
+ && lvm lvcreate -l 17 -T dracut/mythinpool \
+ && lvm lvcreate -V1G -T dracut/mythinpool -n root \
+ && lvm vgchange -ay \
+ && mke2fs /dev/dracut/root \
+ && mkdir -p /sysroot \
+ && mount /dev/dracut/root /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && sleep 1 \
+ && lvm lvchange -a n /dev/dracut/root \
+ && sleep 1
+dmsetup status | grep out_of_data_space \
+ || echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
plymouth --quit
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg dhclient mkdir cp ping dhclient dd
+ mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir -p $initdir/run
ldconfig -r "$initdir"
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
- -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
(
export initdir=$TESTDIR/overlay
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth network kernel-network-modules" \
- -a "debug" -I lvs \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth network kernel-network-modules" \
+ -a "debug" -I lvs \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
export TERM=linux
export PS1='initramfs-test:\w\$ '
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
stty sane
if getargbool 0 rd.shell; then
[ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
echo "made it to the rootfs! Powering down."
echo "nfs-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/sda
break
done < /proc/mounts
->/dev/watchdog
+> /dev/watchdog
poweroff -f
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
-
#!/bin/sh
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
local cnt=0
local li
while [ $cnt -lt 600 ]; do
- li=$(ip -o link show dev $1 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $1 2> /dev/null)
+ [ -n "$li" ] && return 0
if [[ $2 ]]; then
- li=$(ip -o link show dev $2 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $2 2> /dev/null)
+ [ -n "$li" ] && return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
linkup() {
- wait_for_if_link $1 2>/dev/null\
- && ip link set $1 up 2>/dev/null\
- && wait_for_if_up $1 2>/dev/null
+ wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
}
wait_for_if_link eth0 ens2
exportfs -r
echo > /dev/watchdog
mkdir -p /var/lib/dhcpd
->/var/lib/dhcpd/dhcpd.leases
+> /var/lib/dhcpd/dhcpd.leases
echo > /dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
echo > /dev/watchdog
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
echo "Serving NFS mounts"
while :; do
- [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
- sleep 10
+ [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
+ sleep 10
done
mount -n -o remount,ro /
poweroff -f
tty -s && stty sane
if ! [[ $SERIAL ]]; then
- while : ; do
+ while :; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
sleep 1
echo "CLIENT TEST START: $test_name"
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
- if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1 &>/dev/null; then
+ if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1 &> /dev/null; then
echo "Unable to make client sda image" 1>&2
return 1
fi
# NFSv4: last octect starts at 0x80 and works up
client_test "NFSv3 root=dhcp DHCP path only" 52:54:00:12:34:00 \
- "root=dhcp" 192.168.50.1 -wsize=4096 || return 1
+ "root=dhcp" 192.168.50.1 -wsize=4096 || return 1
- if [[ "$(systemctl --version)" != *"systemd 230"* ]] 2>/dev/null; then
+ if [[ "$(systemctl --version)" != *"systemd 230"* ]] 2> /dev/null; then
client_test "NFSv3 Legacy root=/dev/nfs nfsroot=IP:path" 52:54:00:12:34:01 \
- "root=/dev/nfs nfsroot=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
+ "root=/dev/nfs nfsroot=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 Legacy root=/dev/nfs DHCP path only" 52:54:00:12:34:00 \
- "root=/dev/nfs" 192.168.50.1 -wsize=4096 || return 1
+ "root=/dev/nfs" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 Legacy root=/dev/nfs DHCP IP:path" 52:54:00:12:34:01 \
- "root=/dev/nfs" 192.168.50.2 -wsize=4096 || return 1
+ "root=/dev/nfs" 192.168.50.2 -wsize=4096 || return 1
fi
client_test "NFSv3 root=dhcp DHCP IP:path" 52:54:00:12:34:01 \
- "root=dhcp" 192.168.50.2 -wsize=4096 || return 1
+ "root=dhcp" 192.168.50.2 -wsize=4096 || return 1
client_test "NFSv3 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:02 \
- "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
+ "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
client_test "NFSv3 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:03 \
- "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+ "root=dhcp" 192.168.50.3 wsize=4096 || return 1
client_test "NFSv3 root=nfs:..." 52:54:00:12:34:04 \
- "root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
+ "root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 Bridge root=nfs:..." 52:54:00:12:34:04 \
- "root=nfs:192.168.50.1:/nfs/client bridge net.ifnames=0" 192.168.50.1 -wsize=4096 || return 1
+ "root=nfs:192.168.50.1:/nfs/client bridge net.ifnames=0" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 Legacy root=IP:path" 52:54:00:12:34:04 \
- "root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
+ "root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
# This test must fail: nfsroot= requires root=/dev/nfs
client_test "NFSv3 Invalid root=dhcp nfsroot=/nfs/client" 52:54:00:12:34:04 \
- "root=dhcp nfsroot=/nfs/client failme rd.debug" 192.168.50.1 -wsize=4096 && return 1
+ "root=dhcp nfsroot=/nfs/client failme rd.debug" 192.168.50.1 -wsize=4096 && return 1
client_test "NFSv3 root=dhcp DHCP path,options" \
- 52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1
+ 52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1
client_test "NFSv3 Bridge Customized root=dhcp DHCP path,options" \
- 52:54:00:12:34:05 "root=dhcp bridge=foobr0:ens2" 192.168.50.1 wsize=4096 || return 1
+ 52:54:00:12:34:05 "root=dhcp bridge=foobr0:ens2" 192.168.50.1 wsize=4096 || return 1
client_test "NFSv3 root=dhcp DHCP IP:path,options" \
- 52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1
+ 52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1
client_test "NFSv3 root=dhcp DHCP proto:IP:path,options" \
- 52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+ 52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
return 0
}
# switch_root
client_test "NFSv4 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
- "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
+ "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
client_test "NFSv4 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:83 \
- "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+ "root=dhcp" 192.168.50.3 wsize=4096 || return 1
client_test "NFSv4 root=nfs4:..." 52:54:00:12:34:84 \
- "root=nfs4:192.168.50.1:/client" 192.168.50.1 \
- -wsize=4096 || return 1
+ "root=nfs4:192.168.50.1:/client" 192.168.50.1 \
+ -wsize=4096 || return 1
client_test "NFSv4 root=dhcp DHCP proto:IP:path,options" \
- 52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+ 52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
return 0
}
return 1
fi
- test_nfsv3 && \
- test_nfsv4
+ test_nfsv3 \
+ && test_nfsv4
ret=$?
done
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping exportfs \
- modprobe rpc.nfsd rpc.mountd showmount tcpdump \
- /etc/services sleep mount chmod rm
+ dmesg mkdir cp ping exportfs \
+ modprobe rpc.nfsd rpc.mountd showmount tcpdump \
+ /etc/services sleep mount chmod rm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
- type -P portmap >/dev/null && inst_multiple portmap
- type -P rpcbind >/dev/null && inst_multiple rpcbind
+ type -P portmap > /dev/null && inst_multiple portmap
+ type -P rpcbind > /dev/null && inst_multiple rpcbind
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
- type -P dhcpd >/dev/null && inst_multiple dhcpd
+ type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
instmods nfsd sunrpc ipv6 lockd af_packet
inst ./server-init.sh /sbin/init
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
(
- cd "$initdir";
+ cd "$initdir"
mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 var/lib/rpcbind var/lib/nfs
)
-
# Make client root inside server root
(
export initdir=$TESTDIR/server/overlay/source/nfs/client
. $basedir/dracut-init.sh
inst_multiple sh shutdown poweroff stty cat ps ln ip dd \
- mount dmesg mkdir cp ping grep setsid ls vi /etc/virc less cat
+ mount dmesg mkdir cp ping grep setsid ls vi /etc/virc less cat
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/server/overlay / \
- -m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/server
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/server.ext3 || return 1
-
-
# Make an overlay with needed tools for the test harness
(
export initdir=$TESTDIR/overlay
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.server $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.server $KVERSION || return 1
# Make client's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth dash ${OMIT_NETWORK}" \
- -a "debug watchdog ${USE_NETWORK}" \
- -d "af_packet piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc i6300esb" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth dash ${OMIT_NETWORK}" \
+ -a "debug watchdog ${USE_NETWORK}" \
+ -d "af_packet piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc i6300esb" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
test_cleanup() {
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
done < /proc/mounts
#sh -i
if getargbool 0 rd.shell; then
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
poweroff -f
udevadm control --reload
udevadm settle
-mkfs.ext3 -j -L singleroot -F /dev/sda && \
-mkdir -p /sysroot && \
-mount /dev/sda /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/sdc /dev/sdd && \
-mdadm -W /dev/md0 || : && \
-lvm pvcreate -ff -y /dev/md0 && \
-lvm vgcreate dracut /dev/md0 && \
-lvm lvcreate -l 100%FREE -n root dracut && \
-lvm vgchange -ay && \
-mkfs.ext3 -j -L sysroot /dev/dracut/root && \
-mount /dev/dracut/root /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-lvm lvchange -a n /dev/dracut/root && \
-echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdb
+mkfs.ext3 -j -L singleroot -F /dev/sda \
+ && mkdir -p /sysroot \
+ && mount /dev/sda /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/sdc /dev/sdd \
+ && mdadm -W /dev/md0 || : \
+ && lvm pvcreate -ff -y /dev/md0 \
+ && lvm vgcreate dracut /dev/md0 \
+ && lvm lvcreate -l 100%FREE -n root dracut \
+ && lvm vgchange -ay \
+ && mkfs.ext3 -j -L sysroot /dev/dracut/root \
+ && mount /dev/dracut/root /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && lvm lvchange -a n /dev/dracut/root \
+ && echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdb
sync
poweroff -f
udevadm settle
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
#!/bin/sh
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
local cnt=0
local li
while [ $cnt -lt 600 ]; do
- li=$(ip -o link show dev $1 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $1 2> /dev/null)
+ [ -n "$li" ] && return 0
if [[ $2 ]]; then
- li=$(ip -o link show dev $2 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $2 2> /dev/null)
+ [ -n "$li" ] && return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
ip link set dev eth1 name ens3
ip addr add 192.168.51.1/24 dev ens3
ip link set ens3 up
->/var/lib/dhcpd/dhcpd.leases
+> /var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
tgtadm --lld iscsi --mode target --op bind --tid 2 -I 192.168.51.101
tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101
-
# Wait forever for the VM to die
while :; do
- echo "Serving iSCSI"
- [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
- sleep 10
+ echo "Serving iSCSI"
+ [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
+ sleep 10
done
mount -n -o remount,ro /
poweroff -f
if ! [[ $SERIAL ]]; then
echo "Waiting for the server to startup"
- while : ; do
+ while :; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
sleep 1
}
run_client() {
- local test_name=$1; shift
+ local test_name=$1
+ shift
echo "CLIENT TEST START: $test_name"
dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1
initiator=$(iscsi-iname)
run_client "root=dhcp" \
- "root=/dev/root netroot=dhcp ip=ens2:dhcp" \
- "rd.iscsi.initiator=$initiator" \
+ "root=/dev/root netroot=dhcp ip=ens2:dhcp" \
+ "rd.iscsi.initiator=$initiator" \
|| return 1
- run_client "netroot=iscsi target0"\
- "root=LABEL=singleroot netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0" \
- "ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens2:off" \
- "rd.iscsi.initiator=$initiator" \
+ run_client "netroot=iscsi target0" \
+ "root=LABEL=singleroot netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0" \
+ "ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens2:off" \
+ "rd.iscsi.initiator=$initiator" \
|| return 1
run_client "netroot=iscsi target1 target2" \
- "root=LABEL=sysroot" \
- "ip=dhcp" \
- "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
- "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
- "rd.iscsi.initiator=$initiator" \
+ "root=LABEL=sysroot" \
+ "ip=dhcp" \
+ "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
+ "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
+ "rd.iscsi.initiator=$initiator" \
|| return 1
run_client "root=ibft" \
- "root=LABEL=singleroot" \
- "rd.iscsi.ibft=1" \
- "rd.iscsi.firmware=1" \
+ "root=LABEL=singleroot" \
+ "rd.iscsi.ibft=1" \
+ "rd.iscsi.firmware=1" \
|| return 1
echo "All tests passed [OK]"
}
test_setup() {
- if ! command -v tgtd &>/dev/null || ! command -v tgtadm &>/dev/null; then
+ if ! command -v tgtd &> /dev/null || ! command -v tgtadm &> /dev/null; then
echo "Need tgtd and tgtadm from scsi-target-utils"
return 1
fi
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
- mount dmesg mkdir cp ping grep setsid dd
+ mount dmesg mkdir cp ping grep setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm -- $TESTDIR/client.img
rm -rf -- $TESTDIR/overlay
-
# Make server root
dd if=/dev/zero of=$TESTDIR/server.ext3 bs=1M count=120
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
- cd "$initdir";
+ cd "$initdir"
mkdir -p dev sys proc etc var/run tmp var/lib/dhcpd /etc/iscsi
)
inst /etc/passwd /etc/passwd
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping \
- modprobe tcpdump setsid \
- /etc/services sleep mount chmod
+ dmesg mkdir cp ping \
+ modprobe tcpdump setsid \
+ /etc/services sleep mount chmod
inst_multiple tgtd tgtadm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
inst_multiple -o ${_terminfodir}/l/linux
instmods iscsi_tcp crc32c ipv6
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
- type -P dhcpd >/dev/null && inst_multiple dhcpd
+ type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst_simple /etc/os-release
inst ./server-init.sh /sbin/init
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/server.ext3 || return 1
rm -rf -- $TESTDIR/overlay
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.server $KVERSION || return 1
+ -a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.server $KVERSION || return 1
# Make client dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
- -a "debug ${USE_NETWORK}" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
+ -a "debug ${USE_NETWORK}" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
}
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
done < /proc/mounts
#sh -i
if getargbool 0 rd.shell; then
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY sh -i
+ strstr "$(setsid --help)" "control" && CTTY="-c"
+ setsid $CTTY sh -i
fi
poweroff -f
udevadm control --reload
udevadm settle
-mkfs.ext3 -j -L singleroot -F /dev/sda && \
-mkdir -p /sysroot && \
-mount /dev/sda /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/sdc /dev/sdd && \
-mdadm -W /dev/md0 || : && \
-lvm pvcreate -ff -y /dev/md0 && \
-lvm vgcreate dracut /dev/md0 && \
-lvm lvcreate -l 100%FREE -n root dracut && \
-lvm vgchange -ay && \
-mkfs.ext3 -j -L sysroot /dev/dracut/root && \
-mount /dev/dracut/root /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot && \
-lvm lvchange -a n /dev/dracut/root && \
-echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdb
+mkfs.ext3 -j -L singleroot -F /dev/sda \
+ && mkdir -p /sysroot \
+ && mount /dev/sda /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/sdc /dev/sdd \
+ && mdadm -W /dev/md0 || : \
+ && lvm pvcreate -ff -y /dev/md0 \
+ && lvm vgcreate dracut /dev/md0 \
+ && lvm lvcreate -l 100%FREE -n root dracut \
+ && lvm vgchange -ay \
+ && mkfs.ext3 -j -L sysroot /dev/dracut/root \
+ && mount /dev/dracut/root /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot \
+ && lvm lvchange -a n /dev/dracut/root \
+ && echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdb
sync
poweroff -f
udevadm settle
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f
-
#!/bin/sh
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
local cnt=0
local li
while [ $cnt -lt 600 ]; do
- li=$(ip -o link show dev $1 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $1 2> /dev/null)
+ [ -n "$li" ] && return 0
if [[ $2 ]]; then
- li=$(ip -o link show dev $2 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $2 2> /dev/null)
+ [ -n "$li" ] && return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
linkup() {
- wait_for_if_link $1 2>/dev/null\
- && ip link set $1 up 2>/dev/null\
- && wait_for_if_up $1 2>/dev/null
+ wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
}
wait_for_if_link eth0 ens2
ip addr add 192.168.51.1/24 dev ens3
linkup ens3
->/var/lib/dhcpd/dhcpd.leases
+> /var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
tgtadm --lld iscsi --mode target --op bind --tid 2 -I 192.168.51.101
tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101
-
# Wait forever for the VM to die
echo "Serving iSCSI"
while :; do
- [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
- sleep 10
+ [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
+ sleep 10
done
mount -n -o remount,ro /
poweroff -f
tty -s && stty sane
if ! [[ $SERIAL ]]; then
- while : ; do
+ while :; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
tail "$TESTDIR"/server.log
}
run_client() {
- local test_name=$1; shift
+ local test_name=$1
+ shift
echo "CLIENT TEST START: $test_name"
dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1
do_test_run() {
initiator=$(iscsi-iname)
run_client "netroot=iscsi target1 target2" \
- "root=LABEL=sysroot" \
- "ip=192.168.50.101:::255.255.255.0::ens2:off" \
- "ip=192.168.51.101:::255.255.255.0::ens3:off" \
- "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
- "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
- "rd.iscsi.initiator=$initiator" \
+ "root=LABEL=sysroot" \
+ "ip=192.168.50.101:::255.255.255.0::ens2:off" \
+ "ip=192.168.51.101:::255.255.255.0::ens3:off" \
+ "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
+ "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
+ "rd.iscsi.initiator=$initiator" \
|| return 1
run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0" \
- "root=LABEL=sysroot" \
- "ip=192.168.50.101:::255.255.255.0::ens2:off" \
- "ip=192.168.51.101:::255.255.255.0::ens3:off" \
- "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
- "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
- "rd.iscsi.firmware" \
- "rd.iscsi.initiator=$initiator" \
- "rd.iscsi.waitnet=0" \
+ "root=LABEL=sysroot" \
+ "ip=192.168.50.101:::255.255.255.0::ens2:off" \
+ "ip=192.168.51.101:::255.255.255.0::ens3:off" \
+ "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
+ "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
+ "rd.iscsi.firmware" \
+ "rd.iscsi.initiator=$initiator" \
+ "rd.iscsi.waitnet=0" \
|| return 1
run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
- "root=LABEL=sysroot" \
- "ip=192.168.50.101:::255.255.255.0::ens2:off" \
- "ip=192.168.51.101:::255.255.255.0::ens3:off" \
- "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
- "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
- "rd.iscsi.firmware" \
- "rd.iscsi.initiator=$initiator" \
- "rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
+ "root=LABEL=sysroot" \
+ "ip=192.168.50.101:::255.255.255.0::ens2:off" \
+ "ip=192.168.51.101:::255.255.255.0::ens3:off" \
+ "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
+ "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
+ "rd.iscsi.firmware" \
+ "rd.iscsi.initiator=$initiator" \
+ "rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
|| return 1
run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0 default GW" \
- "root=LABEL=sysroot" \
- "ip=192.168.50.101::192.168.50.1:255.255.255.0::ens2:off" \
- "ip=192.168.51.101::192.168.51.1:255.255.255.0::ens3:off" \
- "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
- "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
- "rd.iscsi.firmware" \
- "rd.iscsi.initiator=$initiator" \
- "rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
+ "root=LABEL=sysroot" \
+ "ip=192.168.50.101::192.168.50.1:255.255.255.0::ens2:off" \
+ "ip=192.168.51.101::192.168.51.1:255.255.255.0::ens3:off" \
+ "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
+ "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
+ "rd.iscsi.firmware" \
+ "rd.iscsi.initiator=$initiator" \
+ "rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
|| return 1
echo "All tests passed [OK]"
}
test_setup() {
- if ! command -v tgtd &>/dev/null || ! command -v tgtadm &>/dev/null; then
+ if ! command -v tgtd &> /dev/null || ! command -v tgtadm &> /dev/null; then
echo "Need tgtd and tgtadm from scsi-target-utils"
return 1
fi
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
- mount dmesg mkdir cp ping grep setsid dd
+ mount dmesg mkdir cp ping grep setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
-
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
echo "Unable to make client sdb image" 1>&2
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm -- $TESTDIR/client.img
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
- cd "$initdir";
+ cd "$initdir"
mkdir -p dev sys proc etc var/run tmp var/lib/dhcpd /etc/iscsi
)
inst /etc/passwd /etc/passwd
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping \
- modprobe tcpdump setsid \
- /etc/services sleep mount chmod
+ dmesg mkdir cp ping \
+ modprobe tcpdump setsid \
+ /etc/services sleep mount chmod
inst_multiple tgtd tgtadm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
inst_multiple -o ${_terminfodir}/l/linux
instmods iscsi_tcp crc32c ipv6
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
- type -P dhcpd >/dev/null && inst_multiple dhcpd
+ type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst_simple /etc/os-release
inst ./server-init.sh /sbin/init
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/server.ext3 || return 1
rm -rf -- $TESTDIR/overlay
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.server $KVERSION || return 1
+ -a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.server $KVERSION || return 1
# Make client's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
- -a "debug ${USE_NETWORK}" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
+ -a "debug ${USE_NETWORK}" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
}
#!/bin/sh
->/dev/watchdog
+> /dev/watchdog
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
while read dev fs fstype opts rest || [ -n "$dev" ]; do
[ "$dev" = "rootfs" ] && continue
[ "$fs" != "/" ] && continue
echo "nbd-OK $fstype $opts" | dd oflag=direct,dsync of=/dev/sda
- echo "nbd-OK $fstype $opts"
+ echo "nbd-OK $fstype $opts"
break
done < /proc/mounts
export TERM=linux
stty sane
echo "made it to the rootfs! Powering down."
#sh -i
->/dev/watchdog
+> /dev/watchdog
mount -n -o remount,ro / &> /dev/null
->/dev/watchdog
+> /dev/watchdog
poweroff -f
cp -a -t /root /source/*
mkdir -p /root/run
umount /root
-{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } | dd oflag=direct,dsync of=/dev/sdb
+{
+ echo "dracut-root-block-created"
+ echo "ID_FS_UUID=$ID_FS_UUID"
+} | dd oflag=direct,dsync of=/dev/sdb
sync
poweroff -f
udevadm control --reload
udevadm settle
-printf test >keyfile
+printf test > keyfile
cryptsetup -q luksFormat /dev/sda /keyfile
echo "The passphrase is test"
-cryptsetup luksOpen /dev/sda dracut_crypt_test </keyfile && \
-lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test && \
-lvm vgcreate dracut /dev/mapper/dracut_crypt_test && \
-lvm lvcreate -l 100%FREE -n root dracut && \
-lvm vgchange -ay && \
-mkfs.ext3 -L dracut -j /dev/dracut/root && \
-mkdir -p /sysroot && \
-mount /dev/dracut/root /sysroot && \
-cp -a -t /sysroot /source/* && \
-umount /sysroot
+cryptsetup luksOpen /dev/sda dracut_crypt_test < /keyfile \
+ && lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test \
+ && lvm vgcreate dracut /dev/mapper/dracut_crypt_test \
+ && lvm lvcreate -l 100%FREE -n root dracut \
+ && lvm vgchange -ay \
+ && mkfs.ext3 -L dracut -j /dev/dracut/root \
+ && mkdir -p /sysroot \
+ && mount /dev/dracut/root /sysroot \
+ && cp -a -t /sysroot /source/* \
+ && umount /sysroot
sleep 1
lvm lvchange -a n /dev/dracut/root
udevadm settle
cryptsetup luksClose /dev/mapper/dracut_crypt_test
udevadm settle
sleep 1
-eval $(udevadm info --query=env --name=/dev/sda|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
-{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } | dd oflag=direct,dsync of=/dev/sdb
+eval $(udevadm info --query=env --name=/dev/sda | while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done)
+{
+ echo "dracut-root-block-created"
+ echo "ID_FS_UUID=$ID_FS_UUID"
+} | dd oflag=direct,dsync of=/dev/sdb
sync
poweroff -f
cp -a -t /root /source/*
mkdir -p /root/run
umount /root
-{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } | dd oflag=direct,dsync of=/dev/sdb
+{
+ echo "dracut-root-block-created"
+ echo "ID_FS_UUID=$ID_FS_UUID"
+} | dd oflag=direct,dsync of=/dev/sdb
sync
poweroff -f
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
-printf test >/keyfile
-/sbin/cryptsetup luksOpen $1 $2 </keyfile
-
+printf test > /keyfile
+/sbin/cryptsetup luksOpen $1 $2 < /keyfile
#!/bin/sh
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
local cnt=0
local li
while [ $cnt -lt 600 ]; do
- li=$(ip -o link show dev $1 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $1 2> /dev/null)
+ [ -n "$li" ] && return 0
if [[ $2 ]]; then
- li=$(ip -o link show dev $2 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $2 2> /dev/null)
+ [ -n "$li" ] && return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
linkup() {
- wait_for_if_link $1 2>/dev/null\
- && ip link set $1 up 2>/dev/null\
- && wait_for_if_up $1 2>/dev/null
+ wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
}
wait_for_if_link eth0 ens3
modprobe af_packet
nbd-server
->/var/lib/dhcpd/dhcpd.leases
+> /var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
echo "Serving NBD disks"
while :; do
- [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
- sleep 10
+ [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
+ sleep 10
done
mount -n -o remount,ro /
poweroff -f
# NBD is still too flaky and hangs hard sometimes
return 1
- if ! type -p nbd-server 2>/dev/null; then
+ if ! type -p nbd-server 2> /dev/null; then
echo "Test needs nbd-server... Skipping"
return 1
fi
- if ! modinfo -k $KVERSION nbd &>/dev/null; then
+ if ! modinfo -k $KVERSION nbd &> /dev/null; then
echo "Kernel module nbd does not exist"
return 1
fi
if ! [[ $SERIAL ]]; then
echo "Waiting for the server to startup"
- while : ; do
+ while :; do
grep Serving "$TESTDIR"/server.log && break
tail "$TESTDIR"/server.log
sleep 1
# The default is ext3,errors=continue so use that to determine
# if our options were parsed and used
client_test "NBD root=nbd:IP:port" 52:54:00:12:34:00 \
- "root=nbd:192.168.50.1:raw rd.luks=0" || return 1
+ "root=nbd:192.168.50.1:raw rd.luks=0" || return 1
client_test "NBD root=nbd:IP:port::fsopts" 52:54:00:12:34:00 \
- "root=nbd:192.168.50.1:raw::errors=panic rd.luks=0" \
- ext3 errors=panic || return 1
+ "root=nbd:192.168.50.1:raw::errors=panic rd.luks=0" \
+ ext3 errors=panic || return 1
client_test "NBD root=nbd:IP:port:fstype" 52:54:00:12:34:00 \
- "root=nbd:192.168.50.1:raw:ext3 rd.luks=0" ext3 || return 1
+ "root=nbd:192.168.50.1:raw:ext3 rd.luks=0" ext3 || return 1
client_test "NBD root=nbd:IP:port:fstype:fsopts" 52:54:00:12:34:00 \
- "root=nbd:192.168.50.1:raw:ext3:errors=panic rd.luks=0" \
- ext3 errors=panic || return 1
+ "root=nbd:192.168.50.1:raw:ext3:errors=panic rd.luks=0" \
+ ext3 errors=panic || return 1
-#
-# FIXME! These fail, but probably shouldn't
-#
+ #
+ # FIXME! These fail, but probably shouldn't
+ #
# There doesn't seem to be a good way to validate the NBD options, so
# just check that we don't screw up the other options
-#
-# client_test "NBD root=nbd:IP:port:::NBD opts" 52:54:00:12:34:00 \
-# "root=nbd:192.168.50.1:raw:::bs=2048 rd.luks=0" || return 1
-#
-# client_test "NBD root=nbd:IP:port:fstype::NBD opts" 52:54:00:12:34:00 \
-# "root=nbd:192.168.50.1:raw:ext3::bs=2048 rd.luks=0" ext3 || return 1
-#
-# client_test "NBD root=nbd:IP:port:fstype:fsopts:NBD opts" \
-# 52:54:00:12:34:00 \
-# "root=nbd:192.168.50.1:raw:ext3:errors=panic:bs=2048 rd.luks=0" \
-# ext3 errors=panic || return 1
+ #
+ # client_test "NBD root=nbd:IP:port:::NBD opts" 52:54:00:12:34:00 \
+ # "root=nbd:192.168.50.1:raw:::bs=2048 rd.luks=0" || return 1
+ #
+ # client_test "NBD root=nbd:IP:port:fstype::NBD opts" 52:54:00:12:34:00 \
+ # "root=nbd:192.168.50.1:raw:ext3::bs=2048 rd.luks=0" ext3 || return 1
+ #
+ # client_test "NBD root=nbd:IP:port:fstype:fsopts:NBD opts" \
+ # 52:54:00:12:34:00 \
+ # "root=nbd:192.168.50.1:raw:ext3:errors=panic:bs=2048 rd.luks=0" \
+ # ext3 errors=panic || return 1
# DHCP root-path parsing
client_test "NBD root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
- "root=dhcp rd.luks=0" || return 1
+ "root=dhcp rd.luks=0" || return 1
client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype" \
- 52:54:00:12:34:02 "root=dhcp rd.luks=0" ext3 || return 1
+ 52:54:00:12:34:02 "root=dhcp rd.luks=0" ext3 || return 1
client_test "NBD root=dhcp DHCP root-path nbd:srv:port::fsopts" \
- 52:54:00:12:34:03 "root=dhcp rd.luks=0" ext3 errors=panic || return 1
+ 52:54:00:12:34:03 "root=dhcp rd.luks=0" ext3 errors=panic || return 1
client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
- 52:54:00:12:34:04 "root=dhcp rd.luks=0" ext3 errors=panic || return 1
+ 52:54:00:12:34:04 "root=dhcp rd.luks=0" ext3 errors=panic || return 1
# netroot handling
client_test "NBD netroot=nbd:IP:port" 52:54:00:12:34:00 \
- "netroot=nbd:192.168.50.1:raw rd.luks=0" || return 1
+ "netroot=nbd:192.168.50.1:raw rd.luks=0" || return 1
client_test "NBD netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
- 52:54:00:12:34:04 "netroot=dhcp rd.luks=0" ext3 errors=panic || return 1
+ 52:54:00:12:34:04 "netroot=dhcp rd.luks=0" ext3 errors=panic || return 1
# Encrypted root handling via LVM/LUKS over NBD
. $TESTDIR/luks.uuid
client_test "NBD root=LABEL=dracut netroot=nbd:IP:port" \
- 52:54:00:12:34:00 \
- "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=nbd:192.168.50.1:encrypted" || return 1
+ 52:54:00:12:34:00 \
+ "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=nbd:192.168.50.1:encrypted" || return 1
# XXX This should be ext3,errors=panic but that doesn't currently
# XXX work when you have a real root= line in addition to netroot=
# XXX How we should work here needs clarification
-# client_test "NBD root=LABEL=dracut netroot=dhcp (w/ fstype and opts)" \
-# 52:54:00:12:34:05 \
-# "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=dhcp" || return 1
+ # client_test "NBD root=LABEL=dracut netroot=dhcp (w/ fstype and opts)" \
+ # 52:54:00:12:34:05 \
+ # "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=dhcp" || return 1
if [[ -s server.pid ]]; then
kill -TERM $(cat $TESTDIR/server.pid)
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
- mount dmesg mkdir cp ping dd
+ mount dmesg mkdir cp ping dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst ./client-init.sh /sbin/init
inst_simple /etc/os-release
- find_binary plymouth >/dev/null && inst_multiple plymouth
+ find_binary plymouth > /dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
- -d "piix ide-gd_mod ata_piix ext3 ext3 sd_mod" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 ext3 sd_mod" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
-drive format=raw,index=0,media=disk,file=$TESTDIR/encrypted.ext3 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/flag.img \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1
grep -F -a -m 1 ID_FS_UUID $TESTDIR/flag.img > $TESTDIR/luks.uuid
}
done
)
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping dd
+ dmesg mkdir cp ping dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
- for i in /usr/lib*/libnss_files* /lib*/libnss_files*;do
+ for i in /usr/lib*/libnss_files* /lib*/libnss_files*; do
[ -e "$i" ] || continue
inst $i
done
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/nbd.ext3 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/flag.img \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1
rm -fr "$TESTDIR"/overlay
}
. "$basedir"/dracut-init.sh
mkdir -p "$initdir"
(
- cd "$initdir";
+ cd "$initdir"
mkdir -p run dev sys proc etc var var/lib/dhcpd tmp etc/nbd-server
ln -s ../run var/run
)
- cat > "$initdir/etc/nbd-server/config" <<EOF
+ cat > "$initdir/etc/nbd-server/config" << EOF
[generic]
[raw]
exportname = /dev/sdb
bs = 4096
EOF
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping grep \
- sleep nbd-server chmod modprobe vi
+ dmesg mkdir cp ping grep \
+ sleep nbd-server chmod modprobe vi
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
instmods af_packet
- type -P dhcpd >/dev/null && inst_multiple dhcpd
+ type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst ./server-init.sh /sbin/init
inst_simple /etc/os-release
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
- for i in /usr/lib*/libnss_files* /lib*/libnss_files*;do
+ for i in /usr/lib*/libnss_files* /lib*/libnss_files*; do
[ -e "$i" ] || continue
inst $i
done
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/flag.img \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1
rm -fr "$TESTDIR"/overlay
}
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "dash udev-rules rootfs-block fs-lib base debug kernel-modules" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 ext3 sd_mod e1000" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.server $KVERSION || return 1
+ -m "dash udev-rules rootfs-block fs-lib base debug kernel-modules" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 ext3 sd_mod e1000" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.server $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -o "plymouth" \
- -a "debug watchdog" \
- -d "af_packet piix ide-gd_mod ata_piix ext3 ext3 sd_mod e1000 i6300esb ib700wdt" \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth" \
+ -a "debug watchdog" \
+ -d "af_packet piix ide-gd_mod ata_piix ext3 ext3 sd_mod e1000 i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
}
kill_server() {
getcmdline() {
while read -r _line || [ -n "$_line" ]; do
printf "%s" "$_line"
- done </proc/cmdline;
+ done < /proc/cmdline
}
_dogetarg() {
if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
# if $1 has a "=<value>", we want the exact match
if [ "$_o" = "$1" ]; then
- _val="1";
+ _val="1"
unset _doecho
fi
continue
if [ "${_o#*=}" = "$_o" ]; then
# if cmdline argument has no "=<value>", we assume "=1"
- _val="1";
+ _val="1"
unset _doecho
continue
fi
fi
done
if [ -n "$_val" ]; then
- [ "x$_doecho" != "x" ] && echo "$_val";
- return 0;
+ [ "x$_doecho" != "x" ] && echo "$_val"
+ return 0
fi
- return 1;
+ return 1
}
getarg() {
local _deprecated _newoption
while [ $# -gt 0 ]; do
case $1 in
- -d) _deprecated=1; shift;;
- -y) if _dogetarg $2 >/dev/null; then
+ -d)
+ _deprecated=1
+ shift
+ ;;
+ -y)
+ if _dogetarg $2 > /dev/null; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
fi
return 0
fi
_deprecated=0
- shift 2;;
- -n) if _dogetarg $2 >/dev/null; then
- echo 0;
+ shift 2
+ ;;
+ -n)
+ if _dogetarg $2 > /dev/null; then
+ echo 0
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
fi
return 1
fi
_deprecated=0
- shift 2;;
- *) if [ -z "$_newoption" ]; then
+ shift 2
+ ;;
+ *)
+ if [ -z "$_newoption" ]; then
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
fi
- return 0;
+ return 0
fi
_deprecated=0
- shift;;
+ shift
+ ;;
esac
done
return 1
local _b
unset _b
local _default
- _default="$1"; shift
+ _default="$1"
+ shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
return 0
}
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1##*"$2"*}" != "$1" ]; }
strglobin() { [ -n "$1" -a -z "${1##*$2*}" ]; }
-CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line || [ -n "$line" ]; do echo $line; done < /proc/cmdline)
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
echo "made it to the rootfs! Powering down."
-for i in /sys/class/net/*
-do
+for i in /sys/class/net/*; do
# booting with network-manager module
state=/run/NetworkManager/devices/$(cat $i/ifindex)
- grep -q connection-uuid= $state 2>/dev/null || continue
+ grep -q connection-uuid= $state 2> /dev/null || continue
i=${i##*/}
- ip link show $i |grep -q master && continue
+ ip link show $i | grep -q master && continue
IFACES+="$i "
done
for i in /run/initramfs/net.*.did-setup; do
udevadm settle
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
#!/bin/sh
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
local cnt=0
local li
while [ $cnt -lt 600 ]; do
- li=$(ip -o link show dev $1 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $1 2> /dev/null)
+ [ -n "$li" ] && return 0
if [[ $2 ]]; then
- li=$(ip -o link show dev $2 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $2 2> /dev/null)
+ [ -n "$li" ] && return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
linkup() {
- wait_for_if_link $1 2>/dev/null\
- && ip link set $1 up 2>/dev/null\
- && wait_for_if_up $1 2>/dev/null
+ wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
}
wait_for_if_link eth0 ens2
->/dev/watchdog
+> /dev/watchdog
ip addr add 127.0.0.1/8 dev lo
linkup lo
ip link set dev eth0 name ens2
ip addr add 192.168.50.1/24 dev ens2
linkup ens2
->/dev/watchdog
+> /dev/watchdog
modprobe af_packet
> /dev/watchdog
modprobe sunrpc
->/dev/watchdog
+> /dev/watchdog
mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
->/dev/watchdog
+> /dev/watchdog
[ -x /sbin/portmap ] && portmap
->/dev/watchdog
+> /dev/watchdog
mkdir -p /run/rpcbind
[ -x /sbin/rpcbind ] && rpcbind
->/dev/watchdog
+> /dev/watchdog
modprobe nfsd
->/dev/watchdog
+> /dev/watchdog
mount -t nfsd nfsd /proc/fs/nfsd
->/dev/watchdog
+> /dev/watchdog
exportfs -r
->/dev/watchdog
+> /dev/watchdog
rpc.nfsd
->/dev/watchdog
+> /dev/watchdog
rpc.mountd
->/dev/watchdog
+> /dev/watchdog
rpc.idmapd -S
->/dev/watchdog
+> /dev/watchdog
exportfs -r
->/dev/watchdog
->/var/lib/dhcpd/dhcpd.leases
->/dev/watchdog
+> /dev/watchdog
+> /var/lib/dhcpd/dhcpd.leases
+> /dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
->/dev/watchdog
+> /dev/watchdog
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
echo "Serving NFS mounts"
while :; do
- [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
- sleep 10
+ [ -n "$(jobs -rp)" ] && echo > /dev/watchdog
+ sleep 10
done
mount -n -o remount,ro /
poweroff -f
#DEBUGFAIL="rd.shell rd.break"
#SERIAL="tcp:127.0.0.1:9999"
-
-
run_server() {
# Start server first
echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
tty -s && stty sane
if ! [[ $SERIAL ]]; then
- while : ; do
+ while :; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
tail "$TESTDIR"/server.log
fi
$testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img \
- -net socket,connect=127.0.0.1:12350 \
- -net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \
- -net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
- -net nic,macaddr=52:54:00:12:34:$mac3,model=e1000 \
- -netdev hubport,id=n1,hubid=1 \
- -netdev hubport,id=n2,hubid=2 \
- -device e1000,netdev=n1,mac=52:54:00:12:34:98 \
- -device e1000,netdev=n2,mac=52:54:00:12:34:99 \
- -watchdog i6300esb -watchdog-action poweroff \
- -append "quiet rd.net.timeout.dhcp=3 panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console" \
- -initrd "$TESTDIR"/initramfs.testing
-
- { read OK; read IFACES; } < "$TESTDIR"/client.img
+ -net socket,connect=127.0.0.1:12350 \
+ -net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \
+ -net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
+ -net nic,macaddr=52:54:00:12:34:$mac3,model=e1000 \
+ -netdev hubport,id=n1,hubid=1 \
+ -netdev hubport,id=n2,hubid=2 \
+ -device e1000,netdev=n1,mac=52:54:00:12:34:98 \
+ -device e1000,netdev=n2,mac=52:54:00:12:34:99 \
+ -watchdog i6300esb -watchdog-action poweroff \
+ -append "quiet rd.net.timeout.dhcp=3 panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console" \
+ -initrd "$TESTDIR"/initramfs.testing
+
+ {
+ read OK
+ read IFACES
+ } < "$TESTDIR"/client.img
if [[ "$OK" != "OK" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 0
}
-
test_run() {
if ! run_server; then
echo "Failed to start server" 1>&2
# PXE Style BOOTIF=
client_test "MULTINIC root=nfs BOOTIF=" \
- 00 01 02 \
- "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
- "ens2" || return 1
+ 00 01 02 \
+ "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
+ "ens2" || return 1
client_test "MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
- 00 01 02 \
- "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens3:dhcp" \
- "ens2 ens3" || return 1
+ 00 01 02 \
+ "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens3:dhcp" \
+ "ens2 ens3" || return 1
# PXE Style BOOTIF= with dhcp root-path
client_test "MULTINIC root=dhcp BOOTIF=" \
- 00 01 02 \
- "root=dhcp BOOTIF=52-54-00-12-34-02" \
- "ens4" || return 1
+ 00 01 02 \
+ "root=dhcp BOOTIF=52-54-00-12-34-02" \
+ "ens4" || return 1
# Multinic case, where only one nic works
client_test "MULTINIC root=nfs ip=dhcp" \
- FF 00 FE \
- "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
- "ens3" || return 1
+ FF 00 FE \
+ "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
+ "ens3" || return 1
# Require two interfaces
client_test "MULTINIC root=nfs ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
- 00 01 02 \
- "root=nfs:192.168.50.1:/nfs/client ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
- "ens3 ens4" || return 1
+ 00 01 02 \
+ "root=nfs:192.168.50.1:/nfs/client ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
+ "ens3 ens4" || return 1
# Require three interfaces with dhcp root-path
client_test "MULTINIC root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
- 00 01 02 \
- "root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
- "ens2 ens3 ens4" || return 1
+ 00 01 02 \
+ "root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
+ "ens2 ens3 ens4" || return 1
client_test "MULTINIC bonding" \
- 00 01 02 \
- "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens2,ens3,ens4:mode=balance-rr" \
- "bond0" || return 1
+ 00 01 02 \
+ "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens2,ens3,ens4:mode=balance-rr" \
+ "bond0" || return 1
# bridge, where only one interface is actually connected
client_test "MULTINIC bridging" \
- 00 01 02 \
- "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens2,ens6,ens7" \
- "bridge0" || return 1
+ 00 01 02 \
+ "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens2,ens6,ens7" \
+ "bridge0" || return 1
return 0
}
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
-
(
- cd "$initdir";
+ cd "$initdir"
mkdir -p -- dev sys proc run var/run etc tmp var/lib/{dhcpd,rpcbind}
mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 -- var/lib/rpcbind var/lib/nfs
done
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping exportfs \
- modprobe rpc.nfsd rpc.mountd showmount tcpdump \
- /etc/services sleep mount chmod
+ dmesg mkdir cp ping exportfs \
+ modprobe rpc.nfsd rpc.mountd showmount tcpdump \
+ /etc/services sleep mount chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f "${_terminfodir}"/l/linux ] && break
done
inst_multiple -o "${_terminfodir}"/l/linux
- type -P portmap >/dev/null && inst_multiple portmap
- type -P rpcbind >/dev/null && inst_multiple rpcbind
+ type -P portmap > /dev/null && inst_multiple portmap
+ type -P rpcbind > /dev/null && inst_multiple rpcbind
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
- type -P dhcpd >/dev/null && inst_multiple dhcpd
+ type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
instmods nfsd sunrpc ipv6 lockd af_packet
inst_simple /etc/os-release
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
done
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
- mount dmesg mkdir cp ping grep ls dd
+ mount dmesg mkdir cp ping grep ls dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
done
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/server.ext3 || return 1
rm -fr "$TESTDIR"/overlay
#!/bin/sh
-exec >/dev/console 2>&1
+exec > /dev/console 2>&1
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
-CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
+CMDLINE=$(while read line; do echo $line; done < /proc/cmdline)
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
(
echo OK
- ip -o -4 address show scope global | while read n if rest; do echo $if;done | sort
+ ip -o -4 address show scope global | while read n if rest; do echo $if; done | sort
for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
- echo $i
- grep -v 'UUID=' $i
+ echo $i
+ grep -v 'UUID=' $i
done
echo EOF
) | dd oflag=direct,dsync of=/dev/sda
udevadm settle
set -e
# save a partition at the beginning for future flagging purposes
-sfdisk /dev/sda <<EOF
+sfdisk /dev/sda << EOF
,1M
,
EOF
#!/bin/sh
-exec </dev/console >/dev/console 2>&1
+exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
local li
while [ $cnt -lt 600 ]; do
-ip link show
+ ip link show
- li=$(ip -o link show dev $1 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $1 2> /dev/null)
+ [ -n "$li" ] && return 0
if [[ $2 ]]; then
- li=$(ip -o link show dev $2 2>/dev/null)
- [ -n "$li" ] && return 0
+ li=$(ip -o link show dev $2 2> /dev/null)
+ [ -n "$li" ] && return 0
fi
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
- cnt=$(($cnt+1))
+ cnt=$(($cnt + 1))
done
return 1
}
linkup() {
- wait_for_if_link $1 2>/dev/null\
- && ip link set $1 up 2>/dev/null\
- && wait_for_if_up $1 2>/dev/null
+ wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
}
udevadm settle
wait_for_if_link eth3 ens6
modprobe --all -b -q 8021q ipvlan macvlan
->/dev/watchdog
+> /dev/watchdog
ip addr add 127.0.0.1/8 dev lo
linkup lo
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
linkup ens3
->/dev/watchdog
+> /dev/watchdog
ip link set dev eth1 name ens4
ip link add dev ens4.1 link ens4 type vlan id 1
ip link add dev ens4.2 link ens4 type vlan id 2
linkup ens5
ip link set dev eth3 name ens6
linkup ens6
->/dev/watchdog
+> /dev/watchdog
modprobe af_packet
> /dev/watchdog
modprobe sunrpc
->/dev/watchdog
+> /dev/watchdog
mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
->/dev/watchdog
+> /dev/watchdog
[ -x /sbin/portmap ] && portmap
->/dev/watchdog
+> /dev/watchdog
mkdir -p /run/rpcbind
[ -x /sbin/rpcbind ] && rpcbind
->/dev/watchdog
+> /dev/watchdog
modprobe nfsd
->/dev/watchdog
+> /dev/watchdog
mount -t nfsd nfsd /proc/fs/nfsd
->/dev/watchdog
+> /dev/watchdog
exportfs -r
->/dev/watchdog
+> /dev/watchdog
rpc.nfsd
->/dev/watchdog
+> /dev/watchdog
rpc.mountd
->/dev/watchdog
+> /dev/watchdog
rpc.idmapd -S
->/dev/watchdog
+> /dev/watchdog
exportfs -r
->/dev/watchdog
->/var/lib/dhcpd/dhcpd.leases
->/dev/watchdog
+> /dev/watchdog
+> /var/lib/dhcpd/dhcpd.leases
+> /dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
->/dev/watchdog
+> /dev/watchdog
dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
#echo -n 'V' > /dev/watchdog
#sh -i
# Wait forever for the VM to die
echo "Serving"
while :; do
- sleep 10
- >/dev/watchdog
+ sleep 10
+ > /dev/watchdog
done
mount -n -o remount,ro /
poweroff -f
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
-
if [[ $NM ]]; then
USE_NETWORK="network-manager"
OMIT_NETWORK="network-legacy"
if ! [[ $SERIAL ]]; then
echo "Waiting for the server to startup"
- while : ; do
+ while :; do
grep Serving "$TESTDIR"/server.log && break
tail "$TESTDIR"/server.log
sleep 1
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,mac=52:54:00:12:34:01,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device e1000,mac=52:54:00:12:34:02,netdev=h3 \
- $nic1 -device e1000,mac=52:54:00:12:34:03,netdev=n1 \
+ $nic1 -device e1000,mac=52:54:00:12:34:03,netdev=n1 \
-netdev socket,connect=127.0.0.1:12372,id=n2 -device e1000,mac=52:54:00:12:34:04,netdev=n2 \
$nic3 -device e1000,mac=52:54:00:12:34:05,netdev=n3 \
-watchdog i6300esb -watchdog-action poweroff \
return 0
}
-
test_run() {
if ! run_server; then
echo "Failed to start server" 1>&2
return 1
fi
- test_client || { kill_server; return 1; }
+ test_client || {
+ kill_server
+ return 1
+ }
}
test_client() {
fi
client_test "Multiple VLAN" \
- "yes" \
- "
+ "yes" \
+ "
vlan=vlan0001:ens5
vlan=vlan2:ens5
vlan=ens5.3:ens5
rd.neednet=1
root=nfs:192.168.50.1:/nfs/client bootdev=ens3
" \
- "$EXPECT" \
+ "$EXPECT" \
|| return 1
if [[ $NM ]]; then
fi
client_test "Multiple Bonds" \
- "yes" \
- "
+ "yes" \
+ "
bond=bond0:ens3,ens4
bond=bond1:ens6,ens7
ip=bond0:dhcp
rd.neednet=1
root=nfs:192.168.50.1:/nfs/client bootdev=bond0
" \
- "$EXPECT" \
+ "$EXPECT" \
|| return 1
if [[ $NM ]]; then
fi
client_test "Multiple Bridges" \
- "no" \
- "
+ "no" \
+ "
bridge=br0:ens3,ens4
bridge=br1:ens6,ens7
ip=br0:dhcp
rd.neednet=1
root=nfs:192.168.50.1:/nfs/client bootdev=br0
" \
- "$EXPECT" \
+ "$EXPECT" \
|| return 1
kill_server
return 0
. "$basedir"/dracut-init.sh
(
- cd "$initdir";
+ cd "$initdir"
mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 -- var/lib/rpcbind var/lib/nfs
done
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping exportfs \
- modprobe rpc.nfsd rpc.mountd showmount tcpdump \
- /etc/services sleep mount chmod
+ dmesg mkdir cp ping exportfs \
+ modprobe rpc.nfsd rpc.mountd showmount tcpdump \
+ /etc/services sleep mount chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f "${_terminfodir}"/l/linux ] && break
done
inst_multiple -o "${_terminfodir}"/l/linux
- type -P portmap >/dev/null && inst_multiple portmap
- type -P rpcbind >/dev/null && inst_multiple rpcbind
+ type -P portmap > /dev/null && inst_multiple portmap
+ type -P rpcbind > /dev/null && inst_multiple rpcbind
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
- type -P dhcpd >/dev/null && inst_multiple dhcpd
+ type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
instmods nfsd sunrpc ipv6 lockd af_packet 8021q ipvlan macvlan
inst_simple /etc/os-release
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
export initdir=$TESTDIR/overlay/source/nfs/client
. $basedir/dracut-init.sh
inst_multiple sh shutdown poweroff stty cat ps ln ip \
- mount dmesg mkdir cp ping grep ls sort dd
+ mount dmesg mkdir cp ping grep ls sort dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
done
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
- | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
- -m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
- -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
- --nomdadmconf \
- --no-hostonly-cmdline -N \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "bash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
+ -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
+ --nomdadmconf \
+ --no-hostonly-cmdline -N \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created $TESTDIR/server.ext3 || return 1
rm -fr "$TESTDIR"/overlay
# Make server's dracut image
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
- --no-early-microcode \
- -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
- -d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
- --no-hostonly-cmdline -N \
- -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
+ --no-early-microcode \
+ -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
+ -d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
# Make client's dracut image
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
- --no-early-microcode \
- -o "plymouth ${OMIT_NETWORK}" \
- -a "debug ${USE_NETWORK}" \
- -d "ipvlan macvlan af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
- --no-hostonly-cmdline -N \
- -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
+ --no-early-microcode \
+ -o "plymouth ${OMIT_NETWORK}" \
+ -a "debug ${USE_NETWORK}" \
+ -d "ipvlan macvlan af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
+ --no-hostonly-cmdline -N \
+ -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
}
kill_server() {
for key in "${!TEST[@]}"; do
if ! val=$(./dracut-getarg "${key}="); then
echo "'$key' == '${TEST[$key]}', but not found" >&2
- ret=$((ret+1))
+ ret=$((ret + 1))
else
if [[ $val != "${TEST[$key]}" ]]; then
echo "'$key' != '${TEST[$key]}' but '$val'" >&2
- ret=$((ret+1))
+ ret=$((ret + 1))
fi
fi
done
declare -a INVALIDKEYS
- INVALIDKEYS=( "key" "4" "5" "6" "key8" "9" "\"" "baz")
+ INVALIDKEYS=("key" "4" "5" "6" "key8" "9" "\"" "baz")
for key in "${INVALIDKEYS[@]}"; do
val=$(./dracut-getarg "$key")
- if (( $? == 0 )); then
+ if (($? == 0)); then
echo "key '$key' should not be found"
- ret=$((ret+1))
+ ret=$((ret + 1))
fi
# must have no output
- [[ $val ]] && ret=$((ret+1))
+ [[ $val ]] && ret=$((ret + 1))
done
RESULT=("val" "val2")
readarray -t args < <(./dracut-getargs "key2=")
- (( ${#RESULT[@]} == ${#args[@]} )) || ret=$((ret+1))
- for ((i=0; i < ${#RESULT[@]}; i++)); do
- [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret+1))
+ ((${#RESULT[@]} == ${#args[@]})) || ret=$((ret + 1))
+ for ((i = 0; i < ${#RESULT[@]}; i++)); do
+ [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret + 1))
done
- val=$(./dracut-getarg "key1") || ret=$((ret+1))
- [[ $val == "0" ]] || ret=$((ret+1))
+ val=$(./dracut-getarg "key1") || ret=$((ret + 1))
+ [[ $val == "0" ]] || ret=$((ret + 1))
- val=$(./dracut-getarg "key2=val") && ret=$((ret+1))
+ val=$(./dracut-getarg "key2=val") && ret=$((ret + 1))
# must have no output
- [[ $val ]] && ret=$((ret+1))
- val=$(./dracut-getarg "key2=val2") || ret=$((ret+1))
+ [[ $val ]] && ret=$((ret + 1))
+ val=$(./dracut-getarg "key2=val2") || ret=$((ret + 1))
# must have no output
- [[ $val ]] && ret=$((ret+1))
+ [[ $val ]] && ret=$((ret + 1))
export PATH=".:$PATH"
echo "rdbreak=cmdline rd.lvm rd.auto rd.retry=10"
}
RDRETRY=$(getarg rd.retry -d 'rd_retry=')
- [[ $RDRETRY == "10" ]] || ret=$((ret+1))
- getarg rd.break=cmdline -d rdbreak=cmdline || ret=$((ret+1))
- getargbool 1 rd.lvm -d -n rd_NO_LVM || ret=$((ret+1))
- getargbool 0 rd.auto || ret=$((ret+1))
+ [[ $RDRETRY == "10" ]] || ret=$((ret + 1))
+ getarg rd.break=cmdline -d rdbreak=cmdline || ret=$((ret + 1))
+ getargbool 1 rd.lvm -d -n rd_NO_LVM || ret=$((ret + 1))
+ getargbool 0 rd.auto || ret=$((ret + 1))
getcmdline() {
echo "rd.break=cmdlined rd.lvm=0 rd.auto=0"
}
- getarg rd.break=cmdline -d rdbreak=cmdline && ret=$((ret+1))
- getargbool 1 rd.lvm -d -n rd_NO_LVM && ret=$((ret+1))
- getargbool 0 rd.auto && ret=$((ret+1))
+ getarg rd.break=cmdline -d rdbreak=cmdline && ret=$((ret + 1))
+ getargbool 1 rd.lvm -d -n rd_NO_LVM && ret=$((ret + 1))
+ getargbool 0 rd.auto && ret=$((ret + 1))
getcmdline() {
echo "ip=a ip=b ip=dhcp6"
}
- getargs "ip=dhcp6" &>/dev/null || ret=$((ret+1))
+ getargs "ip=dhcp6" &> /dev/null || ret=$((ret + 1))
readarray -t args < <(getargs "ip=")
RESULT=("a" "b" "dhcp6")
- (( ${#RESULT[@]} || ${#args[@]} )) || ret=$((ret+1))
- for ((i=0; i < ${#RESULT[@]}; i++)); do
- [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret+1))
+ ((${#RESULT[@]} || ${#args[@]})) || ret=$((ret + 1))
+ for ((i = 0; i < ${#RESULT[@]}; i++)); do
+ [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret + 1))
done
getcmdline() {
}
readarray -t args < <(getargs bridge=)
RESULT=("bridge" "val")
- (( ${#RESULT[@]} == ${#args[@]} )) || ret=$((ret+1))
- for ((i=0; i < ${#RESULT[@]}; i++)); do
- [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret+1))
+ ((${#RESULT[@]} == ${#args[@]})) || ret=$((ret + 1))
+ for ((i = 0; i < ${#RESULT[@]}; i++)); do
+ [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret + 1))
done
-
getcmdline() {
echo "rd.break rd.md.uuid=bf96e457:230c9ad4:1f3e59d6:745cf942 rd.md.uuid=bf96e457:230c9ad4:1f3e59d6:745cf943 rd.shell"
}
readarray -t args < <(getargs rd.md.uuid -d rd_MD_UUID=)
RESULT=("bf96e457:230c9ad4:1f3e59d6:745cf942" "bf96e457:230c9ad4:1f3e59d6:745cf943")
- (( ${#RESULT[@]} == ${#args[@]} )) || ret=$((ret+1))
- for ((i=0; i < ${#RESULT[@]}; i++)); do
- [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret+1))
+ ((${#RESULT[@]} == ${#args[@]})) || ret=$((ret + 1))
+ for ((i = 0; i < ${#RESULT[@]}; i++)); do
+ [[ ${args[$i]} == "${RESULT[$i]}" ]] || ret=$((ret + 1))
done
return $ret
test_check() {
# disable for now
return 1
- command -v rpm &>/dev/null && ( command -v yum || command -v dnf ) &>/dev/null
+ command -v rpm &> /dev/null && (command -v yum || command -v dnf) &> /dev/null
}
test_run() {
mkdir -p "$rootdir/$TESTDIR"
cp --reflink=auto -a \
- "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \
- "$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \
- "$rootdir/$TESTDIR/"
+ "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \
+ "$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \
+ "$rootdir/$TESTDIR/"
. /etc/os-release
dnf_or_yum=yum
dnf_or_yum_cmd=yum
- command -v dnf >/dev/null && { dnf_or_yum="dnf"; dnf_or_yum_cmd="dnf --allowerasing"; }
- for (( i=0; i < 5 ; i++)); do
+ command -v dnf > /dev/null && {
+ dnf_or_yum="dnf"
+ dnf_or_yum_cmd="dnf --allowerasing"
+ }
+ for ((i = 0; i < 5; i++)); do
$dnf_or_yum_cmd -v --nogpgcheck --installroot "$rootdir"/ --releasever "$VERSION_ID" --disablerepo='*' \
- --enablerepo=fedora --enablerepo=updates --setopt=install_weak_deps=False \
- install -y \
- $dnf_or_yum \
- passwd \
- rootfiles \
- systemd \
- systemd-udev \
- kernel \
- kernel-core \
- redhat-release \
- device-mapper-multipath \
- lvm2 \
- mdadm \
- bash \
- iscsi-initiator-utils \
- "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \
- ${NULL} && break
+ --enablerepo=fedora --enablerepo=updates --setopt=install_weak_deps=False \
+ install -y \
+ $dnf_or_yum \
+ passwd \
+ rootfiles \
+ systemd \
+ systemd-udev \
+ kernel \
+ kernel-core \
+ redhat-release \
+ device-mapper-multipath \
+ lvm2 \
+ mdadm \
+ bash \
+ iscsi-initiator-utils \
+ "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \
+ ${NULL} && break
#"$TESTDIR"/dracut-config-rescue-[0-9]*.$(uname -m).rpm \
- #"$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \
- # ${NULL}
+ #"$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \
+ # ${NULL}
done
- (( i < 5 ))
+ ((i < 5))
- cat >"$rootdir"/test.sh <<EOF
+ cat > "$rootdir"/test.sh << EOF
#!/bin/bash
set -x
export LC_MESSAGES=C
[[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-enable-kvm -cpu host"
[[ $BIN ]] || {
- echo "Could not find a working KVM or QEMU to test with!" >&2
- echo "Please install kvm or qemu." >&2
- exit 1
+ echo "Could not find a working KVM or QEMU to test with!" >&2
+ echo "Please install kvm or qemu." >&2
+ exit 1
}
# Provide rng device sourcing the hosts /dev/urandom and other standard parameters
if ! [ -f "$VMLINUZ" ]; then
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
- if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
+ if [[ $MACHINE_ID ]] && ([[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]); then
VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
else
VMLINUZ="/boot/vmlinuz-${KVERSION}"
echo "TESTDIR=\"$TESTDIR\"" > .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
export TESTDIR
-command -v test_check &>/dev/null || test_check() {
- :
- }
+command -v test_check &> /dev/null || test_check() {
+ :
+}
# terminal sequence to set color to a 'success' color (currently: green)
function SETCOLOR_SUCCESS() { echo -en '\033[0;32m'; }
COLOR_NORMAL='\033[0;39m'
check_root() {
- if (( $EUID != 0 )); then
- SETCOLOR_FAILURE; echo "Tests must be run as root! Please use 'sudo'."; SETCOLOR_NORMAL
+ if (($EUID != 0)); then
+ SETCOLOR_FAILURE
+ echo "Tests must be run as root! Please use 'sudo'."
+ SETCOLOR_NORMAL
exit 1
fi
}
check_root
echo "TEST RUN: $TEST_DESCRIPTION"
test_check && test_run
- exit $?;;
+ exit $?
+ ;;
--setup)
check_root
echo "TEST SETUP: $TEST_DESCRIPTION"
test_check && test_setup
- exit $?;;
+ exit $?
+ ;;
--clean)
echo "TEST CLEANUP: $TEST_DESCRIPTION"
test_cleanup
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
- exit $?;;
+ exit $?
+ ;;
--all)
check_root
- if ! test_check 2&>test${TEST_RUN_ID:+-$TEST_RUN_ID}.log ; then
+ if ! test_check 2 &> test${TEST_RUN_ID:+-$TEST_RUN_ID}.log; then
echo -e "TEST: $TEST_DESCRIPTION " $COLOR_WARNING "[SKIPPED]" $COLOR_NORMAL
- exit 0;
+ exit 0
else
- echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[STARTED]" $COLOR_NORMAL;
+ echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[STARTED]" $COLOR_NORMAL
fi
if [[ "$V" == "1" ]]; then
set -o pipefail
test_setup && test_run
ret=$?
test_cleanup
- if ((ret!=0)) && [[ -f "$TESTDIR"/server.log ]]; then
+ if ((ret != 0)) && [[ -f "$TESTDIR"/server.log ]]; then
mv "$TESTDIR"/server.log ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log
fi
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
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
set -o pipefail
(
test_setup && test_run
ret=$?
test_cleanup
- if ((ret!=0)) && [[ -f "$TESTDIR"/server.log ]]; then
+ if ((ret != 0)) && [[ -f "$TESTDIR"/server.log ]]; then
mv "$TESTDIR"/server.log ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log
fi
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $ret
- ) </dev/null 2>&1 | $basedir/logtee test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
+ ) < /dev/null 2>&1 | $basedir/logtee test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
else
(
test_setup && test_run
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $ret
- ) </dev/null >test${TEST_RUN_ID:+-$TEST_RUN_ID}.log 2>&1
+ ) < /dev/null > test${TEST_RUN_ID:+-$TEST_RUN_ID}.log 2>&1
fi
ret=$?
set +o pipefail
echo "see $(pwd)/test${TEST_RUN_ID:+-$TEST_RUN_ID}.log"
fi
fi
- exit $ret;;
+ exit $ret
+ ;;
*) break ;;
esac
shift