Browse Source

style: shfmt reformat

reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w .
```
master
Harald Hoyer 3 years ago committed by Harald Hoyer
parent
commit
9a52c3fdb0
  1. 2
      configure
  2. 18
      dracut-bash-completion.sh
  3. 44
      dracut-catimages.sh
  4. 165
      dracut-functions.sh
  5. 44
      dracut-init.sh
  6. 31
      dracut-logger.sh
  7. 400
      dracut.sh
  8. 8
      lsinitrd-bash-completion.sh
  9. 57
      lsinitrd.sh
  10. 42
      mkinitrd-dracut.sh
  11. 65
      mkinitrd-suse.sh
  12. 1
      modules.d/00bash/module-setup.sh
  13. 1
      modules.d/00dash/module-setup.sh
  14. 1
      modules.d/00mksh/module-setup.sh
  15. 14
      modules.d/00systemd/module-setup.sh
  16. 26
      modules.d/01fips/fips.sh
  17. 3
      modules.d/01systemd-coredump/module-setup.sh
  18. 1
      modules.d/02caps/caps.sh
  19. 1
      modules.d/02caps/module-setup.sh
  20. 2
      modules.d/02systemd-networkd/module-setup.sh
  21. 1
      modules.d/03rescue/module-setup.sh
  22. 1
      modules.d/05busybox/module-setup.sh
  23. 1
      modules.d/06dbus-broker/module-setup.sh
  24. 2
      modules.d/09dbus/module-setup.sh
  25. 9
      modules.d/10i18n/console_init.sh
  26. 38
      modules.d/10i18n/module-setup.sh
  27. 9
      modules.d/10i18n/parse-i18n.sh
  28. 1
      modules.d/30convertfs/convertfs.sh
  29. 1
      modules.d/30convertfs/module-setup.sh
  30. 18
      modules.d/35network-legacy/dhclient-script.sh
  31. 45
      modules.d/35network-legacy/ifup.sh
  32. 4
      modules.d/35network-legacy/kill-dhclient.sh
  33. 1
      modules.d/35network-legacy/module-setup.sh
  34. 28
      modules.d/35network-legacy/parse-bond.sh
  35. 10
      modules.d/35network-legacy/parse-bridge.sh
  36. 23
      modules.d/35network-legacy/parse-ip-opts.sh
  37. 25
      modules.d/35network-legacy/parse-team.sh
  38. 5
      modules.d/35network-legacy/parse-vlan.sh
  39. 3
      modules.d/35network-manager/nm-lib.sh
  40. 7
      modules.d/35network-manager/nm-run.sh
  41. 2
      modules.d/40network/module-setup.sh
  42. 175
      modules.d/40network/net-lib.sh
  43. 4
      modules.d/40network/netroot.sh
  44. 1
      modules.d/45ifcfg/module-setup.sh
  45. 3
      modules.d/45ifcfg/write-ifcfg.sh
  46. 1
      modules.d/45url-lib/module-setup.sh
  47. 13
      modules.d/45url-lib/url-lib.sh
  48. 1
      modules.d/50plymouth/module-setup.sh
  49. 8
      modules.d/50plymouth/plymouth-populate-initrd.sh
  50. 23
      modules.d/80cms/cms-write-ifcfg.sh
  51. 20
      modules.d/80cms/cmsifup.sh
  52. 36
      modules.d/80cms/cmssetup.sh
  53. 5
      modules.d/80lvmmerge/lvmmerge.sh
  54. 2
      modules.d/81cio_ignore/module-setup.sh
  55. 6
      modules.d/90btrfs/module-setup.sh
  56. 84
      modules.d/90crypt/crypt-lib.sh
  57. 12
      modules.d/90crypt/module-setup.sh
  58. 7
      modules.d/90crypt/parse-crypt.sh
  59. 4
      modules.d/90crypt/parse-keydev.sh
  60. 5
      modules.d/90crypt/probe-keydev.sh
  61. 4
      modules.d/90dm/dm-shutdown.sh
  62. 5
      modules.d/90dm/module-setup.sh
  63. 4
      modules.d/90dmsquash-live/apply-live-updates.sh
  64. 15
      modules.d/90dmsquash-live/dmsquash-generator.sh
  65. 19
      modules.d/90dmsquash-live/dmsquash-live-root.sh
  66. 15
      modules.d/90dmsquash-live/parse-dmsquash-live.sh
  67. 23
      modules.d/90kernel-modules-extra/module-setup.sh
  68. 5
      modules.d/90kernel-modules/module-setup.sh
  69. 1
      modules.d/90kernel-modules/parse-kernel.sh
  70. 1
      modules.d/90kernel-network-modules/module-setup.sh
  71. 30
      modules.d/90livenet/livenet-generator.sh
  72. 3
      modules.d/90livenet/livenetroot.sh
  73. 32
      modules.d/90lvm/lvm_scan.sh
  74. 3
      modules.d/90lvm/module-setup.sh
  75. 1
      modules.d/90lvm/parse-lvm.sh
  76. 5
      modules.d/90mdraid/parse-md.sh
  77. 1
      modules.d/90multipath/module-setup.sh
  78. 1
      modules.d/90multipath/multipathd-stop.sh
  79. 1
      modules.d/90multipath/multipathd.sh
  80. 4
      modules.d/90nvdimm/module-setup.sh
  81. 10
      modules.d/91crypt-gpg/module-setup.sh
  82. 2
      modules.d/91zipl/install_zipl_cmdline.sh
  83. 14
      modules.d/91zipl/parse-zipl.sh
  84. 3
      modules.d/95cifs/cifs-lib.sh
  85. 2
      modules.d/95cifs/parse-cifsroot.sh
  86. 1
      modules.d/95dasd/module-setup.sh
  87. 1
      modules.d/95dasd_mod/module-setup.sh
  88. 10
      modules.d/95dasd_rules/module-setup.sh
  89. 2
      modules.d/95dasd_rules/parse-dasd.sh
  90. 1
      modules.d/95debug/module-setup.sh
  91. 3
      modules.d/95fcoe-uefi/parse-uefifcoe.sh
  92. 1
      modules.d/95fcoe/fcoe-up.sh
  93. 6
      modules.d/95fcoe/module-setup.sh
  94. 28
      modules.d/95iscsi/iscsiroot.sh
  95. 8
      modules.d/95iscsi/module-setup.sh
  96. 4
      modules.d/95iscsi/parse-iscsiroot.sh
  97. 5
      modules.d/95lunmask/module-setup.sh
  98. 1
      modules.d/95nbd/module-setup.sh
  99. 11
      modules.d/95nbd/nbd-generator.sh
  100. 15
      modules.d/95nbd/nbdroot.sh
  101. Some files were not shown because too many files have changed in this diff Show More

2
configure vendored

@ -92,7 +92,7 @@ for lib in "-lc" "-lfts"; do @@ -92,7 +92,7 @@ for lib in "-lc" "-lfts"; do
if test $ret -eq 0; then
FTS_LIBS="$lib"
found=yes
break;
break
fi
done
rm -f conftest.c a.out

18
dracut-bash-completion.sh

@ -16,7 +16,8 @@ @@ -16,7 +16,8 @@
#

__contains_word() {
local word="$1"; shift
local word="$1"
shift
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
return 1
}
@ -56,10 +57,16 @@ _dracut() { @@ -56,10 +57,16 @@ _dracut() {
comps=$(dracut --list-modules 2> /dev/null)
;;
--persistent-policy)
comps=$(cd /dev/disk/ || return 0; printf -- "%s " *)
comps=$(
cd /dev/disk/ || return 0
printf -- "%s " *
)
;;
--kver)
comps=$(cd /lib/modules || return 0; echo [0-9]*)
comps=$(
cd /lib/modules || return 0
echo [0-9]*
)
;;
*)
return 0
@ -85,7 +92,10 @@ _dracut() { @@ -85,7 +92,10 @@ _dracut() {
return 0
elif [[ $args -eq 2 ]]; then
# shellcheck disable=SC2034
comps=$(cd /lib/modules || return 0; echo [0-9]*)
comps=$(
cd /lib/modules || return 0
echo [0-9]*
)
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=($(compgen -W '$comps' -- "$cur"))

44
dracut-catimages.sh

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#


dwarning() {
echo "Warning: $*" >&2
}
@ -49,27 +48,46 @@ line and /boot/dracut/ @@ -49,27 +48,46 @@ line and /boot/dracut/
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 ;;
-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;;
-*)
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."
@ -77,7 +95,8 @@ if [[ -z $outfile ]]; then @@ -77,7 +95,8 @@ if [[ -z $outfile ]]; then
exit 1
fi

baseimage=$1; shift
baseimage=$1
shift

if [[ -z $baseimage ]]; then
derror "No base image specified."
@ -104,7 +123,10 @@ if [[ ! $no_overlay ]]; then @@ -104,7 +123,10 @@ 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"; )
(
cd "$overlay" || return 1
find . | cpio --quiet -H newc -o | $gzip -9 > "$ofile"
)
fi

if [[ ! $no_imagedir ]]; then

165
dracut-functions.sh

@ -25,7 +25,6 @@ is_func() { @@ -25,7 +25,6 @@ is_func() {
[[ "$(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
@ -81,8 +80,7 @@ find_binary() { @@ -81,8 +80,7 @@ find_binary() {
type -P "${1##*/}"
}

ldconfig_paths()
{
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
}

@ -98,12 +96,15 @@ vercmp() { @@ -98,12 +96,15 @@ vercmp() {
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
@ -130,8 +131,7 @@ mksubdirs() { @@ -130,8 +131,7 @@ mksubdirs() {
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
@ -163,10 +163,16 @@ convert_abs_rel() { @@ -163,10 +163,16 @@ convert_abs_rel() {
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"
@ -174,28 +180,22 @@ convert_abs_rel() { @@ -174,28 +180,22 @@ convert_abs_rel() {
__abssize=${#__absolute[@]}
__cursize=${#__current[@]}

while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]
do
while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]; do
((__level++))
if (( __level > __abssize || __level > __cursize ))
then
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]}
@ -204,7 +204,6 @@ convert_abs_rel() { @@ -204,7 +204,6 @@ convert_abs_rel() {
printf -- "%s\n" "$__newpath"
}


# get_fs_env <device>
# Get and the ID_FS_TYPE variable from udev for a device.
# Example:
@ -216,8 +215,8 @@ get_fs_env() { @@ -216,8 +215,8 @@ get_fs_env() {
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)
if [[ $ID_FS_TYPE ]]; then
@ -238,7 +237,6 @@ get_maj_min() { @@ -238,7 +237,6 @@ get_maj_min() {
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))"
}


# get_devpath_block <device>
# get the DEVPATH in /sys of a block device
get_devpath_block() {
@ -276,8 +274,7 @@ get_persistent_dev() { @@ -276,8 +274,7 @@ get_persistent_dev() {
/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
@ -318,15 +315,20 @@ shorten_persistent_dev() { @@ -318,15 +315,20 @@ shorten_persistent_dev() {
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
}

@ -346,7 +348,7 @@ find_block_device() { @@ -346,7 +348,7 @@ find_block_device() {

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
@ -363,11 +365,13 @@ find_block_device() { @@ -363,11 +365,13 @@ find_block_device() {
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"
@ -386,7 +390,9 @@ find_block_device() { @@ -386,7 +390,9 @@ find_block_device() {
printf "%s\n" "$_dev"
return 0
fi
done; return 1; } && return 0
done
return 1
} && return 0

return 1
}
@ -403,22 +409,26 @@ find_mp_fstype() { @@ -403,22 +409,26 @@ find_mp_fstype() {
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
}
@ -439,22 +449,26 @@ find_dev_fstype() { @@ -439,22 +449,26 @@ find_dev_fstype() {
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
}
@ -498,30 +512,26 @@ find_dev_fsopts() { @@ -498,30 +512,26 @@ find_dev_fsopts() {
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[@]}"
}

@ -565,8 +575,7 @@ check_block_and_slaves_all() { @@ -565,8 +575,7 @@ check_block_and_slaves_all() {
# 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
@ -582,8 +591,7 @@ for_each_host_dev_and_slaves_all() @@ -582,8 +591,7 @@ for_each_host_dev_and_slaves_all()
return $_ret
}

for_each_host_dev_and_slaves()
{
for_each_host_dev_and_slaves() {
local _func="$1"
local _dev

@ -612,8 +620,7 @@ check_vol_slaves() { @@ -612,8 +620,7 @@ check_vol_slaves() {
# 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
@ -636,8 +643,7 @@ check_vol_slaves_all() { @@ -636,8 +643,7 @@ check_vol_slaves_all() {
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
@ -645,8 +651,6 @@ check_vol_slaves_all() { @@ -645,8 +651,6 @@ check_vol_slaves_all() {
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
@ -662,13 +666,13 @@ fs_get_option() { @@ -662,13 +666,13 @@ fs_get_option() {
$_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 ]] \
@ -691,8 +695,7 @@ check_kernel_module() { @@ -691,8 +695,7 @@ check_kernel_module() {

# 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
@ -703,11 +706,10 @@ get_cpu_vendor () @@ -703,11 +706,10 @@ get_cpu_vendor ()

# 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
@ -759,8 +761,8 @@ peer_for_addr() { @@ -759,8 +761,8 @@ peer_for_addr() {

# 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() {
@ -780,8 +782,8 @@ gateway_for_iface() { @@ -780,8 +782,8 @@ gateway_for_iface() {
*:*) 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!
@ -828,12 +830,15 @@ ip_params_for_remote_addr() { @@ -828,12 +830,15 @@ ip_params_for_remote_addr() {
case $bootproto in
dhcp | dhcp6 | auto6) ;;
dhcp4)
bootproto=dhcp;;
bootproto=dhcp
;;
static* | "")
bootproto=;;
bootproto=
;;
*)
derror "bootproto \"$bootproto\" is unsupported by dracut, trying static configuration"
bootproto=;;
bootproto=
;;
esac
if [[ $bootproto ]]; then
printf 'ip=%s:%s ' "${ifname}" "${bootproto}"

44
dracut-init.sh

@ -272,8 +272,8 @@ dracut_install() { @@ -272,8 +272,8 @@ dracut_install() {
}

dracut_instmods() {
local _silent=0;
local i;
local _silent=0
local i
# shellcheck disable=SC2154
[[ $no_kernel = yes ]] && return
for i in "$@"; do
@ -385,7 +385,7 @@ inst_rule_programs() { @@ -385,7 +385,7 @@ inst_rule_programs() {
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

@ -400,7 +400,7 @@ inst_rule_programs() { @@ -400,7 +400,7 @@ inst_rule_programs() {
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

@ -415,7 +415,7 @@ inst_rule_programs() { @@ -415,7 +415,7 @@ inst_rule_programs() {
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

@ -588,7 +588,6 @@ inst_any() { @@ -588,7 +588,6 @@ inst_any() {
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
@ -836,7 +835,8 @@ check_mount() { @@ -836,7 +835,8 @@ check_mount() {
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
@ -869,8 +869,8 @@ check_mount() { @@ -869,8 +869,8 @@ check_mount() {
fi
done

[[ " $mods_to_load " == *\ $_mod\ * ]] || \
mods_to_load+=" $_mod "
[[ " $mods_to_load " == *\ $_mod\ * ]] \
|| mods_to_load+=" $_mod "

return 0
}
@ -902,9 +902,11 @@ check_module() { @@ -902,9 +902,11 @@ check_module() {

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
@ -912,7 +914,8 @@ check_module() { @@ -912,7 +914,8 @@ check_module() {
# 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
@ -941,8 +944,8 @@ check_module() { @@ -941,8 +944,8 @@ check_module() {
fi
done

[[ " $mods_to_load " == *\ $_mod\ * ]] || \
mods_to_load+=" $_mod "
[[ " $mods_to_load " == *\ $_mod\ * ]] \
|| mods_to_load+=" $_mod "

return 0
}
@ -956,10 +959,11 @@ for_each_module_dir() { @@ -956,10 +959,11 @@ for_each_module_dir() {
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

@ -987,8 +991,8 @@ dracut_kernel_post() { @@ -987,8 +991,8 @@ dracut_kernel_post() {
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

31
dracut-logger.sh

@ -17,10 +17,8 @@ @@ -17,10 +17,8 @@
# 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
@ -86,7 +84,6 @@ export __DRACUT_LOGGER__=1 @@ -86,7 +84,6 @@ export __DRACUT_LOGGER__=1
#
# @see dlog_init()


## @brief Initializes dracut Logger.
#
# @retval 1 if something has gone wrong
@ -105,7 +102,8 @@ export __DRACUT_LOGGER__=1 @@ -105,7 +102,8 @@ export __DRACUT_LOGGER__=1
# 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
@ -171,44 +169,44 @@ dlog_init() { @@ -171,44 +169,44 @@ dlog_init() {
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
done
readonly maxloglvl=$maxloglvl_l
export maxloglvl


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"
@ -318,7 +316,8 @@ _dlvl2syslvl() { @@ -318,7 +316,8 @@ _dlvl2syslvl() {
# - @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: $*"
@ -337,8 +336,8 @@ _do_dlog() { @@ -337,8 +336,8 @@ _do_dlog() {
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()

400
dracut.sh

@ -295,17 +295,16 @@ read_arg() { @@ -295,17 +295,16 @@ read_arg() {
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

@ -329,8 +328,7 @@ dropindirs_sort() @@ -329,8 +328,7 @@ dropindirs_sort()
}
}

rearrange_params()
{
rearrange_params() {
# Workaround -i, --include taking 2 arguments
newat=()
for i in "$@"; do
@ -342,7 +340,9 @@ rearrange_params() @@ -342,7 +340,9 @@ rearrange_params()
done
set -- "${newat[@]}" # Set new $@

TEMP=$(unset POSIXLY_CORRECT; getopt \
TEMP=$(
unset POSIXLY_CORRECT
getopt \
-o "a:m:o:d:I:k:c:r:L:fvqlHhMN" \
--long kver: \
--long add: \
@ -435,7 +435,8 @@ rearrange_params() @@ -435,7 +435,8 @@ rearrange_params()
--long hostonly-nics: \
--long no-machineid \
--long version \
-- "$@")
-- "$@"
)

# shellcheck disable=SC2181
if (($? != 0)); then
@ -454,10 +455,10 @@ eval set -- "$TEMP" @@ -454,10 +455,10 @@ eval set -- "$TEMP"
# 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"
@ -467,7 +468,8 @@ do @@ -467,7 +468,8 @@ do
exit 1
fi
abs_rebuild_file=$(readlink -f "$rebuild_file") && rebuild_file="$abs_rebuild_file"
shift; continue
shift
continue
fi
shift
done
@ -476,7 +478,8 @@ done @@ -476,7 +478,8 @@ done
while (($# > 0)); do
case ${1%%=*} in
++include)
shift 2;;
shift 2
;;
*)
if ! [[ ${outfile+x} ]]; then
outfile=$1
@ -484,7 +487,8 @@ while (($# > 0)); do @@ -484,7 +487,8 @@ while (($# > 0)); do
kernel=$1
else
printf "\nUnknown arguments: %s\n\n" "$*" >&2
usage; exit 1;
usage
exit 1
fi
;;
esac
@ -520,53 +524,178 @@ eval set -- "$TEMP" @@ -520,53 +524,178 @@ eval set -- "$TEMP"

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;;
--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
-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";;
--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";;
early_microcode_l="no"
;;
--strip) do_strip_l="yes" ;;
--nostrip) do_strip_l="no" ;;
--hardlink) do_hardlink_l="yes" ;;
@ -578,8 +707,15 @@ while :; do @@ -578,8 +707,15 @@ while :; do
--nolvmconf) lvmconf_l="no" ;;
--debug) debug="yes" ;;
--profile) profile="yes" ;;
--sshkey) sshkey="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--logfile) logfile_l="$2"; shift;;
--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)
@ -588,27 +724,46 @@ while :; do @@ -588,27 +724,46 @@ while :; do
&& dracutbasedir="$(readlink -f "${0%/*}")"
;;
-H | --hostonly | --host-only)
hostonly_l="yes" ;;
hostonly_l="yes"
;;
-N | --no-hostonly | --no-host-only)
hostonly_l="no" ;;
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;;
persistent_policy_l="$2"
PARMS_TO_STORE+=" '$2'"
shift
;;
--fstab) use_fstab_l="yes" ;;
-h|--help) long_usage; exit 1 ;;
-h | --help)
long_usage
exit 1
;;
--bzip2) compress_l="bzip2" ;;
--lzma) compress_l="lzma" ;;
--xz) compress_l="xz" ;;
@ -630,18 +785,37 @@ while :; do @@ -630,18 +785,37 @@ while :; do
--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;;
printf "\n!Unknown option: '%s'\n\n" "$1" >&2
usage
exit 1
;;
esac
shift
done
@ -675,8 +849,8 @@ if [[ $regenerate_all == "yes" ]]; then @@ -675,8 +849,8 @@ if [[ $regenerate_all == "yes" ]]; then

((len = ${#dracut_args[@]}))
for ((i = 0; i < len; i++)); do
[[ ${dracut_args[$i]} == "--regenerate-all" ]] && \
unset "dracut_args[$i]"
[[ ${dracut_args[$i]} == "--regenerate-all" ]] \
&& unset "dracut_args[$i]"
done

cd "$dracutsysrootdir"/lib/modules || exit 1
@ -703,12 +877,12 @@ unset GREP_OPTIONS @@ -703,12 +877,12 @@ unset GREP_OPTIONS
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
}
@ -816,8 +990,8 @@ stdloglvl=$((stdloglvl + verbosity_mod_l)) @@ -816,8 +990,8 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $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"
@ -845,8 +1019,8 @@ if ! [[ $outfile ]]; then @@ -845,8 +1019,8 @@ if ! [[ $outfile ]]; then
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; \
| 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
@ -910,7 +1084,8 @@ fi @@ -910,7 +1084,8 @@ fi

case $hostonly_mode in
'')
[[ $hostonly ]] && hostonly_mode="sloppy" ;;
[[ $hostonly ]] && hostonly_mode="sloppy"
;;
sloppy | strict)
if [[ ! $hostonly ]]; then
unset hostonly_mode
@ -919,6 +1094,7 @@ case $hostonly_mode in @@ -919,6 +1094,7 @@ case $hostonly_mode in
*)
printf "%s\n" "dracut: Invalid hostonly mode '$hostonly_mode'." >&2
exit 1
;;
esac

[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
@ -1045,8 +1221,8 @@ unset omit_drivers_corrected @@ -1045,8 +1221,8 @@ 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]}\""
[[ "${dracut_args[$i]}" == *\ * ]] \
&& dracut_args[$i]="\"${dracut_args[$i]}\""
#" keep vim happy
done

@ -1054,9 +1230,9 @@ dinfo "Executing: $dracut_cmd ${dracut_args[*]}" @@ -1054,9 +1230,9 @@ 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
@ -1069,7 +1245,6 @@ esac @@ -1069,7 +1245,6 @@ esac

abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"


[[ -d $dracutsysrootdir$systemdutildir ]] \
|| systemdutildir=$(pkg-config systemd --variable=systemdutildir 2> /dev/null)

@ -1146,9 +1321,11 @@ if [[ ! $print_cmdline ]]; then @@ -1146,9 +1321,11 @@ if [[ ! $print_cmdline ]]; then
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
@ -1287,9 +1464,7 @@ if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then @@ -1287,9 +1464,7 @@ if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
"/usr/lib64" \
"/boot" \
"/boot/efi" \
"/boot/zipl" \
;
do
"/boot/zipl"; do
mp=$(readlink -f "$dracutsysrootdir$mp")
mountpoint "$mp" > /dev/null 2>&1 || continue
_dev=$(find_block_device "$mp")
@ -1587,8 +1762,7 @@ for_each_module_dir check_mount @@ -1587,8 +1762,7 @@ for_each_module_dir check_mount

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
@ -1596,7 +1770,8 @@ do_print_cmdline() @@ -1596,7 +1770,8 @@ do_print_cmdline()

# 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
@ -1614,7 +1789,7 @@ fi @@ -1614,7 +1789,7 @@ fi
[[ $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
@ -1680,7 +1855,8 @@ _isize=0 #initramfs size @@ -1680,7 +1855,8 @@ _isize=0 #initramfs size
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"
@ -1706,7 +1882,10 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do @@ -1706,7 +1882,10 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do

#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
@ -1732,7 +1911,7 @@ if [[ $no_kernel != yes ]]; then @@ -1732,7 +1911,7 @@ if [[ $no_kernel != yes ]]; then
hostonly='' instmods $drivers
fi

if [[ -n "${add_drivers// }" ]]; then
if [[ -n "${add_drivers// /}" ]]; then
# shellcheck disable=SC2086
hostonly='' instmods -c $add_drivers
fi
@ -1754,8 +1933,8 @@ if [[ $no_kernel != yes ]]; then @@ -1754,8 +1933,8 @@ if [[ $no_kernel != yes ]]; 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
@ -1836,7 +2015,7 @@ for ((i=0; i < ${#include_src[@]}; i++)); do @@ -1836,7 +2015,7 @@ for ((i=0; i < ${#include_src[@]}; i++)); do
# 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/}
@ -1925,8 +2104,8 @@ if [[ $early_microcode = yes ]]; then @@ -1925,8 +2104,8 @@ 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 \
[[ -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' ***"
@ -2088,7 +2267,8 @@ if [[ $create_early_cpio = yes ]]; then @@ -2088,7 +2267,8 @@ if [[ $create_early_cpio = yes ]]; then

# The microcode blob is _before_ the initramfs blob, not after
if ! (
umask 077; cd "$early_cpio_dir/d"
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"
@ -2146,7 +2326,8 @@ case $compress in @@ -2146,7 +2326,8 @@ case $compress in
esac

if ! (
umask 077; cd "$initdir"
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"
@ -2200,7 +2381,7 @@ if [[ $uefi = yes ]]; then @@ -2200,7 +2381,7 @@ if [[ $uefi = yes ]]; then
--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 [[ -n "${uefi_secureboot_key}" && -n "${uefi_secureboot_cert}" ]]; then
if sbsign \
--key "${uefi_secureboot_key}" \
--cert "${uefi_secureboot_cert}" \
@ -2258,11 +2439,14 @@ freeze_ok_for_fstype() { @@ -2258,11 +2439,14 @@ freeze_ok_for_fstype() {
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
}


8
lsinitrd-bash-completion.sh

@ -16,7 +16,8 @@ @@ -16,7 +16,8 @@
#

__contains_word() {
local word="$1"; shift
local word="$1"
shift
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
return 1
}
@ -36,7 +37,10 @@ _lsinitrd() { @@ -36,7 +37,10 @@ _lsinitrd() {
compopt -o filenames
;;
--kver | -k)
comps=$(cd /lib/modules || return 1; echo [0-9]*)
comps=$(
cd /lib/modules || return 1
echo [0-9]*
)
;;
*)
return 0

57
lsinitrd.sh

@ -17,8 +17,7 @@ @@ -17,8 +17,7 @@
# 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>"
@ -38,7 +37,6 @@ usage() @@ -38,7 +37,6 @@ usage()
} >&2
}


[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut

sorted=0
@ -68,16 +66,31 @@ eval set -- "$TEMP" @@ -68,16 +66,31 @@ eval set -- "$TEMP"

while (($# > 0)); do
case $1 in
-k|--kver) KERNEL_VERSION="$2"; shift;;
-f|--file) filenames[${2#/}]=1; shift;;
-k | --kver)
KERNEL_VERSION="$2"
shift
;;
-f | --file)
filenames[${2#/}]=1
shift
;;
-s | --size) sorted=1 ;;
-h|--help) usage; exit 0;;
-h | --help)
usage
exit 0
;;
-m | --mod) modules=1 ;;
-v | --verbose) verbose="--verbose" ;;
--unpack) unpack=1 ;;
--unpackearly) unpackearly=1 ;;
--) shift;break;;
*) usage; exit 1;;
--)
shift
break
;;
*)
usage
exit 1
;;
esac
shift
done
@ -112,7 +125,7 @@ fi @@ -112,7 +125,7 @@ fi

shift
while (($# > 0)); do
filenames[${1#/}]=1;
filenames[${1#/}]=1
shift
done

@ -134,8 +147,7 @@ dracutlibdirs() { @@ -134,8 +147,7 @@ dracutlibdirs() {
done
}

extract_files()
{
extract_files() {
((${#filenames[@]} == 1)) && nofileinfo=1
for f in "${!filenames[@]}"; do
[[ $nofileinfo ]] || echo "initramfs:/$f"
@ -147,16 +159,14 @@ extract_files() @@ -147,16 +159,14 @@ extract_files()
done
}

list_modules()
{
list_modules() {
echo "dracut modules:"
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
$(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
@ -167,8 +177,7 @@ list_files() @@ -167,8 +177,7 @@ list_files()
echo "========================================================================"
}

list_squash_content()
{
list_squash_content() {
SQUASH_IMG="squash-root.img"
SQUASH_TMPFILE="$TMPDIR/initrd.root.sqsh"

@ -182,8 +191,7 @@ list_squash_content() @@ -182,8 +191,7 @@ list_squash_content()
fi
}

unpack_files()
{
unpack_files() {
if ((${#filenames[@]} > 0)); then
for f in "${!filenames[@]}"; do
$CAT "$image" 2> /dev/null | cpio -id --quiet $verbose $f
@ -197,7 +205,10 @@ unpack_files() @@ -197,7 +205,10 @@ unpack_files()

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" \
@ -302,8 +313,7 @@ case $bin in @@ -302,8 +313,7 @@ case $bin in
;;
esac

skipcpio()
{
skipcpio() {
$SKIP "$@" | $ORIG_CAT
}

@ -315,8 +325,7 @@ fi @@ -315,8 +325,7 @@ fi
if ((${#filenames[@]} > 1)); then
TMPFILE="$TMPDIR/initrd.cpio"
$CAT "$image" 2> /dev/null > $TMPFILE
pre_decompress()
{
pre_decompress() {
cat $TMPFILE
}
CAT=pre_decompress

42
mkinitrd-dracut.sh

@ -69,7 +69,8 @@ default_kernel_images() { @@ -69,7 +69,8 @@ default_kernel_images() {
aarch64 | riscv64)
regex='Image'
;;
*) regex='vmlinu.'
*)
regex='vmlinu.'
;;
esac

@ -112,23 +113,34 @@ default_kernel_images() { @@ -112,23 +113,34 @@ default_kernel_images() {

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;;
exit 0
;;
-v | --verbose) dracut_args="${dracut_args} -v" ;;
-f | --force) force=1 ;;
--preload) read_arg modname "$@" || shift $?
basicmodules="$basicmodules $modname";;
--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";;
--rootfs | -d)
read_arg rootfs "$@" || shift $?
dracut_args="${dracut_args} --filesystems $rootfs"
;;
--nocompress) dracut_args="$dracut_args --no-compress" ;;
--help) usage -n ;;
--builtin) ;;
@ -155,7 +167,8 @@ while (($# > 0)); do @@ -155,7 +167,8 @@ while (($# > 0)); do
--dsdt*) ;;
-s) ;;
--quiet | -q) quiet=1 ;;
-b) read_arg boot_dir "$@" || shift $?
-b)
read_arg boot_dir "$@" || shift $?
if [ ! -d $boot_dir ]; then
error "Boot directory $boot_dir does not exist"
exit 1
@ -169,7 +182,8 @@ while (($# > 0)); do @@ -169,7 +182,8 @@ while (($# > 0)); do
host_only=1
force=1
;;
-i) read_arg initrd_images "$@" || shift $?
-i)
read_arg initrd_images "$@" || shift $?
for initrd_image in $initrd_images; do
targets="$targets $boot_dir/$initrd_image"
done

65
mkinitrd-suse.sh

@ -109,7 +109,7 @@ calc_netmask() { @@ -109,7 +109,7 @@ calc_netmask() {
byte2=$((mask >> 16))
byte3=$((mask >> 8))
byte4=$((mask & 0xff))
netmask=$(printf "%d.%d.%d.%d" $(( byte1 & 0xff )) $(( byte2 & 0xff )) $(( byte3 & 0xff )) $byte4);
netmask=$(printf "%d.%d.%d.%d" $((byte1 & 0xff)) $((byte2 & 0xff)) $((byte3 & 0xff)) $byte4)

echo $netmask
}
@ -135,8 +135,7 @@ is_xen_kernel() { @@ -135,8 +135,7 @@ is_xen_kernel() {
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
@ -180,7 +179,8 @@ default_kernel_images() { @@ -180,7 +179,8 @@ default_kernel_images() {
aarch64 | riscv64)
regex='Image'
;;
*) regex='vmlinu.'
*)
regex='vmlinu.'
;;
esac

@ -217,7 +217,8 @@ default_kernel_images() { @@ -217,7 +217,8 @@ default_kernel_images() {

while (($# > 0)); do
case ${1%%=*} in
-f) read_arg feature_list "$@" || shift $?
-f)
read_arg feature_list "$@" || shift $?
# Could be several features
;;
-k) # Would be nice to get a list of images here
@ -227,29 +228,33 @@ while (($# > 0)); do @@ -227,29 +228,33 @@ while (($# > 0)); do
kernels="$kernels ${kernel_image#*-}"
done
;;
-i) read_arg initrd_images "$@" || shift $?
-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`
dname=$(dirname $initrd_image)
if [ "$dname" == "." ]; then
targets="$targets $boot_dir/$initrd_image";
targets="$targets $boot_dir/$initrd_image"
else
targets="$targets $initrd_image";
targets="$targets $initrd_image"
fi
done
;;
-b) read_arg boot_dir "$@" || shift $?
-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 $?
-t)
read_arg tmp_dir "$@" || shift $?
dracut_args="${dracut_args} --tmpdir $tmp_dir"
;;
-M) read_arg map_file "$@" || shift $?
-M)
read_arg map_file "$@" || shift $?
;;
-A) dracut_args="${dracut_args} --no-host-only" ;;
-B) skip_update_bootloader=1 ;;
@ -257,31 +262,43 @@ while (($# > 0)); do @@ -257,31 +262,43 @@ while (($# > 0)); do
-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 $?
-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 $?
-I)
read_arg static_if "$@" || shift $?
dracut_cmdline="${dracut_cmdline} ip=$(ipconfig $static_if)":
;;
-a) read_arg acpi_dsdt "$@" || shift $?
-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 $?
-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;;
-V)
echo "mkinitrd: vendor scipts are no longer supported"
exit 1
;;
--dracut)
read_arg dracut_cmd "$@" || shift $? ;;
read_arg dracut_cmd "$@" || shift $?
;;
--version | -R)
echo "mkinitrd: dracut compatibility wrapper"
exit 0;;
exit 0
;;
--quiet | -q) quiet=1 ;;
*) if [[ ! $targets ]]; then
targets=$1

1
modules.d/00bash/module-setup.sh

@ -18,4 +18,3 @@ install() { @@ -18,4 +18,3 @@ install() {
# Prefer bash as /bin/sh if it is available.
inst /bin/bash && ln -sf bash "${initdir}/bin/sh"
}


1
modules.d/00dash/module-setup.sh

@ -18,4 +18,3 @@ install() { @@ -18,4 +18,3 @@ install() {
# Prefer dash as /bin/sh if it is available.
inst /bin/dash && ln -sf dash "${initdir}/bin/sh"
}


1
modules.d/00mksh/module-setup.sh

@ -18,4 +18,3 @@ install() { @@ -18,4 +18,3 @@ install() {
# Prefer mksh as /bin/sh if it is available.
inst /bin/mksh && ln -sf mksh "${initdir}/bin/sh"
}


14
modules.d/00systemd/module-setup.sh

@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
#!/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)"
@ -170,12 +173,13 @@ install() { @@ -170,12 +173,13 @@ install() {
[[ -f $i ]] || continue
while read -r _line || [ -n "$_line" ]; do
case $_line in
\#*)
;;
\;*)
;;
\#*) ;;

\;*) ;;

*)
echo "$_line"
;;
esac
done < "$i"
done

26
modules.d/01fips/fips.sh

@ -12,8 +12,7 @@ else @@ -12,8 +12,7 @@ else
}
fi

mount_boot()
{
mount_boot() {
boot=$(getarg boot=)

if [ -n "$boot" ]; then
@ -21,10 +20,11 @@ mount_boot() @@ -21,10 +20,11 @@ mount_boot()
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
boot="$(label_uuid_to_dev "$boot")"
;;
/dev/*)
;;
/dev/*) ;;

*)
die "You have to specify boot=<boot device> as a boot option for fips=1" ;;
die "You have to specify boot=<boot device> as a boot option for fips=1"
;;
esac

if ! [ -e "$boot" ]; then
@ -55,8 +55,7 @@ mount_boot() @@ -55,8 +55,7 @@ mount_boot()
fi
}

do_rhevh_check()
{
do_rhevh_check() {
KERNEL=$(uname -r)
kpath=${1}

@ -71,16 +70,14 @@ do_rhevh_check() @@ -71,16 +70,14 @@ do_rhevh_check()
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"
@ -107,8 +104,7 @@ fips_load_crypto() @@ -107,8 +104,7 @@ fips_load_crypto()
rmmod tcrypt
}

do_fips()
{
do_fips() {
local _v
local _s
local _v

3
modules.d/01systemd-coredump/module-setup.sh

@ -33,8 +33,7 @@ install() { @@ -33,8 +33,7 @@ install() {
$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.

1
modules.d/02caps/caps.sh

@ -32,4 +32,3 @@ if [ "$capsmode" = "1" ]; then @@ -32,4 +32,3 @@ if [ "$capsmode" = "1" ]; then
echo "CAPS_INIT_DROP=\"$CAPS_INIT_DROP\"" > /etc/capsdrop
info "Will drop capabilities $CAPS_INIT_DROP from init."
fi


1
modules.d/02caps/module-setup.sh

@ -22,4 +22,3 @@ install() { @@ -22,4 +22,3 @@ install() {
dwarning "caps: does not work with systemd in the initramfs"
fi
}


2
modules.d/02systemd-networkd/module-setup.sh

@ -40,7 +40,6 @@ install() { @@ -40,7 +40,6 @@ install() {
# $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"
@ -64,4 +63,3 @@ install() { @@ -64,4 +63,3 @@ install() {
$SYSTEMCTL -q --root "$initdir" enable "$i"
done
}


1
modules.d/03rescue/module-setup.sh

@ -17,4 +17,3 @@ install() { @@ -17,4 +17,3 @@ install() {
ping netstat rpcinfo vi scp ping6 ssh \
fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck
}


1
modules.d/05busybox/module-setup.sh

@ -29,4 +29,3 @@ install() { @@ -29,4 +29,3 @@ install() {
ln_r /usr/bin/busybox $_path
done
}


1
modules.d/06dbus-broker/module-setup.sh

@ -65,7 +65,6 @@ install() { @@ -65,7 +65,6 @@ install() {
/^\[Socket\]/aRemoveOnStop=yes' \
"$initdir$systemdsystemunitdir/dbus.socket"


# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \

2
modules.d/09dbus/module-setup.sh

@ -17,7 +17,7 @@ depends() { @@ -17,7 +17,7 @@ depends() {
echo "$_module"
return 0
fi
done;
done

if find_binary dbus-broker &> /dev/null; then
echo "dbus-broker"

9
modules.d/10i18n/console_init.sh

@ -45,7 +45,9 @@ set_keymap() { @@ -45,7 +45,9 @@ set_keymap() {
}

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}"
@ -62,8 +64,8 @@ dev_close() { @@ -62,8 +64,8 @@ dev_close() {
dev_open() {
local dev=$1

exec 6<${dev} && \
exec 7>>${dev}
exec 6< ${dev} \
&& exec 7>> ${dev}
}

dev=/dev/${1#/dev/}
@ -90,4 +92,3 @@ set_font ${dev} @@ -90,4 +92,3 @@ set_font ${dev}
set_keymap

dev_close


38
modules.d/10i18n/module-setup.sh

@ -32,8 +32,8 @@ install() { @@ -32,8 +32,8 @@ install() {
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 "
@ -84,11 +84,9 @@ install() { @@ -84,11 +84,9 @@ install() {

# 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]}")
@ -146,20 +144,16 @@ install() { @@ -146,20 +144,16 @@ install() {
[ -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
@ -191,8 +185,7 @@ install() { @@ -191,8 +185,7 @@ install() {

findkeymap ${KEYMAP}

for map in ${EXT_KEYMAPS}
do
for map in ${EXT_KEYMAPS}; do
ddebug "Adding extra map: ${map}"
findkeymap ${map}
done
@ -203,14 +196,12 @@ install() { @@ -203,14 +196,12 @@ install() {

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} \
@ -219,8 +210,7 @@ install() { @@ -219,8 +210,7 @@ install() {
|| 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
@ -251,8 +241,8 @@ install() { @@ -251,8 +241,8 @@ install() {
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.'
}

9
modules.d/10i18n/parse-i18n.sh

@ -4,9 +4,12 @@ inst_key_val() { @@ -4,9 +4,12 @@ inst_key_val() {
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

1
modules.d/30convertfs/convertfs.sh

@ -47,7 +47,6 @@ if ! [ -e "$ROOT/usr/bin" ]; then @@ -47,7 +47,6 @@ if ! [ -e "$ROOT/usr/bin" ]; then
exit 1
fi


if ! needconvert; then
echo "Your system is already converted."
exit 0

1
modules.d/30convertfs/module-setup.sh

@ -17,4 +17,3 @@ install() { @@ -17,4 +17,3 @@ install() {
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
inst_script "$moddir/convertfs.sh" /usr/bin/convertfs
}


18
modules.d/35network-legacy/dhclient-script.sh

@ -119,13 +119,19 @@ parse_option_121() { @@ -119,13 +119,19 @@ parse_option_121() {
# 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
@ -135,7 +141,10 @@ parse_option_121() { @@ -135,7 +141,10 @@ parse_option_121() {

# 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
@ -150,7 +159,6 @@ parse_option_121() { @@ -150,7 +159,6 @@ parse_option_121() {
done
}


case $reason in
PREINIT)
echo "dhcp: PREINIT $netif up"

45
modules.d/35network-legacy/ifup.sh

@ -38,7 +38,7 @@ do_dhcp_parallel() { @@ -38,7 +38,7 @@ do_dhcp_parallel() {
bootintf=$(readlink $IFNETFILE)
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
@ -230,7 +230,6 @@ if ! [ -e /tmp/vlan.${netif}.phy ]; then @@ -230,7 +230,6 @@ if ! [ -e /tmp/vlan.${netif}.phy ]; then
done
fi


# bridge this interface?
if [ -z "$NO_BRIDGE_MASTER" ]; then
for i in /tmp/bridge.*.info; do
@ -286,16 +285,16 @@ if [ -z "$NO_BOND_MASTER" ]; then @@ -286,16 +285,16 @@ if [ -z "$NO_BOND_MASTER" ]; then
# Stolen from ifup-eth
# add the bits to setup driver parameters here
for arg in $bondoptions; do
key=${arg%%=*};
value=${arg##*=};
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
@ -315,8 +314,8 @@ if [ -z "$NO_BOND_MASTER" ]; then @@ -315,8 +314,8 @@ if [ -z "$NO_BOND_MASTER" ]; then

# add the bits to setup the needed post enslavement parameters
for arg in $bondoptions; do
key=${arg%%=*};
value=${arg##*=};
key=${arg%%=*}
value=${arg##*=}
if [ "${key}" = "primary" ]; then
echo $value > /sys/class/net/${bondname}/bonding/$key
fi
@ -412,12 +411,11 @@ if [ -n "$manualup" ]; then @@ -412,12 +411,11 @@ if [ -n "$manualup" ]; then
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
@ -451,21 +449,28 @@ for p in $(getargs ip=); do @@ -451,21 +449,28 @@ for p in $(getargs ip=); do
for autoopt in $(str_replace "$autoconf" "," " "); do
case $autoopt in
dhcp | on | any)
do_dhcp -4 ;;
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=$?

4
modules.d/35network-legacy/kill-dhclient.sh

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@

for f in /tmp/dhclient.*.pid; do
[ -e $f ] || continue
read PID < $f;
read PID < $f
kill $PID > /dev/null 2>&1
done

@ -10,6 +10,6 @@ sleep 0.1 @@ -10,6 +10,6 @@ sleep 0.1

for f in /tmp/dhclient.*.pid; do
[ -e $f ] || continue
read PID < $f;
read PID < $f
kill -9 $PID > /dev/null 2>&1
done

1
modules.d/35network-legacy/module-setup.sh

@ -90,4 +90,3 @@ install() { @@ -90,4 +90,3 @@ install() {

dracut_need_initqueue
}


28
modules.d/35network-legacy/parse-bond.sh

@ -23,11 +23,29 @@ parsebond() { @@ -23,11 +23,29 @@ parsebond() {
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;;
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
}

10
modules.d/35network-legacy/parse-bridge.sh

@ -15,9 +15,15 @@ parsebridge() { @@ -15,9 +15,15 @@ parsebridge() {
v=${v#*:}
done
case $# in
0) bridgename=br0; bridgeslaves=$iface ;;
0)
bridgename=br0
bridgeslaves=$iface
;;
1) die "bridge= requires two parameters" ;;
2) bridgename=$1; bridgeslaves=$(str_replace "$2" "," " ") ;;
2)
bridgename=$1
bridgeslaves=$(str_replace "$2" "," " ")
;;
*) die "bridge= requires two parameters" ;;
esac
}

23
modules.d/35network-legacy/parse-ip-opts.sh

@ -16,7 +16,7 @@ command -v getarg >/dev/null || . /lib/dracut-lib.sh @@ -16,7 +16,7 @@ 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
@ -25,7 +25,8 @@ if [ -z "$NEEDBOOTDEV" ] ; then @@ -25,7 +25,8 @@ if [ -z "$NEEDBOOTDEV" ] ; then
for p in $(getargs ip=); do
case "$p" in
ibft)
continue;;
continue
;;
esac
count=$(($count + 1))
done
@ -70,18 +71,18 @@ for p in $(getargs ip=); do @@ -70,18 +71,18 @@ for p in $(getargs ip=); do
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"
[ -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'"
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'" ;;
esac

25
modules.d/35network-legacy/parse-team.sh

@ -18,10 +18,26 @@ parseteam() { @@ -18,10 +18,26 @@ parseteam() {
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 ;;
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
@ -46,4 +62,3 @@ for team in $(getargs team); do @@ -46,4 +62,3 @@ for team in $(getargs team); do
printf -- "%s" "{\"runner\": {\"name\": \"$teamrunner\"}, \"link_watch\": {\"name\": \"ethtool\"}}" > "/tmp/${teammaster}.conf"
fi
done


5
modules.d/35network-legacy/parse-vlan.sh

@ -14,7 +14,10 @@ parsevlan() { @@ -14,7 +14,10 @@ parsevlan() {

unset vlanname phydevice
case $# in
2) vlanname=$1; phydevice=$2 ;;
2)
vlanname=$1
phydevice=$2
;;
*) die "vlan= requires two parameters" ;;
esac
}

3
modules.d/35network-manager/nm-lib.sh

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@

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)


7
modules.d/35network-manager/nm-run.sh

@ -6,8 +6,8 @@ if [ -e /tmp/nm.done ]; then @@ -6,8 +6,8 @@ if [ -e /tmp/nm.done ]; then
return
fi

[ -z "$DRACUT_SYSTEMD" ] && \
for i in /usr/lib/NetworkManager/system-connections/* \
[ -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
@ -20,8 +20,7 @@ if [ -s /run/NetworkManager/initrd/hostname ]; then @@ -20,8 +20,7 @@ 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
ifname=${_i##*/}

2
modules.d/40network/module-setup.sh

@ -14,7 +14,7 @@ depends() { @@ -14,7 +14,7 @@ depends() {
network_handler="$module"
break
fi
done;
done

if [ -z "$network_handler" ]; then
if find_binary wicked &> /dev/null; then

175
modules.d/40network/net-lib.sh

@ -87,7 +87,10 @@ get_netroot_ip() { @@ -87,7 +87,10 @@ get_netroot_ip() {
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
}
@ -103,9 +106,9 @@ ifdown() { @@ -103,9 +106,9 @@ 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?
}

@ -113,9 +116,9 @@ setup_net() { @@ -113,9 +116,9 @@ setup_net() {
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
@ -123,8 +126,8 @@ setup_net() { @@ -123,8 +126,8 @@ setup_net() {
[ -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.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
@ -182,9 +185,9 @@ setup_net() { @@ -182,9 +185,9 @@ setup_net() {
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() {
@ -211,7 +214,7 @@ set_ifname() { @@ -211,7 +214,7 @@ set_ifname() {
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
@ -244,22 +247,37 @@ ibft_to_cmdline() { @@ -244,22 +247,37 @@ ibft_to_cmdline() {
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
# Skip interfaces not used for booting unless using multipath
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)
[ -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
@ -280,15 +298,33 @@ ibft_to_cmdline() { @@ -280,15 +298,33 @@ ibft_to_cmdline() {
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)
[ -e ${iface}/hostname ] && hostname=$(
read a < ${iface}/hostname
echo $a
)
if [ "$family" = "ipv6" ]; then
if [ -n "$ip" ]; then
ip="[$ip]"
@ -315,7 +351,10 @@ ibft_to_cmdline() { @@ -315,7 +351,10 @@ ibft_to_cmdline() {
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]*)
@ -338,8 +377,7 @@ ibft_to_cmdline() { @@ -338,8 +377,7 @@ ibft_to_cmdline() {
) >> /etc/cmdline.d/40-ibft.conf
}

parse_iscsi_root()
{
parse_iscsi_root() {
local v
v=${1#iscsi:}

@ -406,17 +444,22 @@ parse_iscsi_root() @@ -406,17 +444,22 @@ parse_iscsi_root()
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
@ -424,15 +467,17 @@ parse_iscsi_root() @@ -424,15 +467,17 @@ parse_iscsi_root()
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
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%:}
@ -555,10 +600,17 @@ route_to_var() { @@ -555,10 +600,17 @@ route_to_var() {

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;;
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
}
@ -623,11 +675,14 @@ wait_for_if_up() { @@ -623,11 +675,14 @@ wait_for_if_up() {
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" \
@ -710,13 +765,11 @@ wait_for_ipv6_auto() { @@ -710,13 +765,11 @@ wait_for_ipv6_auto() {
}

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() {
type hostname > /dev/null 2>&1 \
|| hostname() {
cat /proc/sys/kernel/hostname
}

@ -791,21 +844,22 @@ is_persistent_ethernet_name() { @@ -791,21 +844,22 @@ is_persistent_ethernet_name() {

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]*)
;;
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]*)
;;
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
}
@ -838,6 +892,7 @@ is_kernel_ethernet_name() { @@ -838,6 +892,7 @@ is_kernel_ethernet_name() {
;;
*)
return 1
;;
esac

}

4
modules.d/40network/netroot.sh

@ -32,7 +32,7 @@ case "$netif" in @@ -32,7 +32,7 @@ case "$netif" in
netif=${i##*/}
break
fi
done
done ;;
esac

# Figure out the handler for root=dhcp by recalling all netroot cmdline
@ -58,7 +58,7 @@ if [ -z "$2" ]; then @@ -58,7 +58,7 @@ if [ -z "$2" ]; then
# FIXME!
unset rootok
for f in $hookdir/cmdline/90*.sh; do
[ -f "$f" ] && . "$f";
[ -f "$f" ] && . "$f"
done
else
rootok="1"

1
modules.d/45ifcfg/module-setup.sh

@ -17,4 +17,3 @@ install() { @@ -17,4 +17,3 @@ install() {
inst_binary awk
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"
}


3
modules.d/45ifcfg/write-ifcfg.sh

@ -8,8 +8,7 @@ udevadm settle --timeout=30 @@ -8,8 +8,7 @@ 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


1
modules.d/45url-lib/module-setup.sh

@ -77,4 +77,3 @@ install() { @@ -77,4 +77,3 @@ install() {
fi
[[ $_found ]] || dwarn "Couldn't find SSL CA cert bundle or libnssckbi.so; HTTPS won't work."
}


13
modules.d/45url-lib/url-lib.sh

@ -39,7 +39,8 @@ get_url_handler() { @@ -39,7 +39,8 @@ get_url_handler() {
# 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
@ -67,7 +68,10 @@ curl_fetch_url() { @@ -67,7 +68,10 @@ curl_fetch_url() {
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
@ -95,7 +99,10 @@ ctorrent_fetch_url() { @@ -95,7 +99,10 @@ ctorrent_fetch_url() {
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

1
modules.d/50plymouth/module-setup.sh

@ -48,4 +48,3 @@ install() { @@ -48,4 +48,3 @@ install() {
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
fi
}


8
modules.d/50plymouth/plymouth-populate-initrd.sh

@ -15,7 +15,7 @@ inst_libdir_file "plymouth/text.so" "plymouth/details.so" @@ -15,7 +15,7 @@ inst_libdir_file "plymouth/text.so" "plymouth/details.so"
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
@ -27,7 +27,7 @@ if [[ $hostonly ]]; then @@ -27,7 +27,7 @@ if [[ $hostonly ]]; then
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
@ -38,7 +38,7 @@ else @@ -38,7 +38,7 @@ else
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

23
modules.d/80cms/cms-write-ifcfg.sh

@ -4,8 +4,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh @@ -4,8 +4,7 @@ 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
@ -62,11 +61,23 @@ GATEWAY=$GATEWAY @@ -62,11 +61,23 @@ GATEWAY=$GATEWAY
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
[ "$DNS1" != "" ] && echo "DNS1=$DNS1" >> $IFCFGFILE

20
modules.d/80cms/cmsifup.sh

@ -17,11 +17,23 @@ if [ "$ipv6" ] && ! str_starts "$GATEWAY" "["; then @@ -17,11 +17,23 @@ if [ "$ipv6" ] && ! str_starts "$GATEWAY" "["; then
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

{

36
modules.d/80cms/cmssetup.sh

@ -32,10 +32,12 @@ function dasd_settle() { @@ -32,10 +32,12 @@ function dasd_settle() {
read status < $dasd_status
case $status in
online | unformatted)
return 0 ;;
return 0
;;
*)
sleep 0.1
i=$((i+1)) ;;
i=$((i + 1))
;;
esac
done
return 1
@ -52,8 +54,7 @@ function dasd_settle_all() { @@ -52,8 +54,7 @@ function dasd_settle_all() {
}

# 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}" ;;
@ -63,8 +64,7 @@ function canonicalize_devno() @@ -63,8 +64,7 @@ function canonicalize_devno()
}

# 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
@ -86,9 +86,9 @@ function readcmsfile() # $1=dasdport $2=filename @@ -86,9 +86,9 @@ function readcmsfile() # $1=dasdport $2=filename
numcpus=$(
while read line || [ -n "$line" ]; do
if strstr "$line" "# processors"; then
echo ${line##*:};
break;
fi;
echo ${line##*:}
break
fi
done < /proc/cpuinfo
)

@ -108,7 +108,11 @@ function readcmsfile() # $1=dasdport $2=filename @@ -108,7 +108,11 @@ function readcmsfile() # $1=dasdport $2=filename

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
@ -128,7 +132,10 @@ function readcmsfile() # $1=dasdport $2=filename @@ -128,7 +132,10 @@ function readcmsfile() # $1=dasdport $2=filename
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
@ -139,8 +146,7 @@ function readcmsfile() # $1=dasdport $2=filename @@ -139,8 +146,7 @@ function readcmsfile() # $1=dasdport $2=filename
return $ret
}

processcmsfile()
{
processcmsfile() {
source /tmp/cms.conf
SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"

@ -183,8 +189,8 @@ processcmsfile() @@ -183,8 +189,8 @@ processcmsfile()
for i in ${!FCP_*}; do
echo "${!i}" | while read port rest || [ -n "$port" ]; do
case $port in
*.*.*)
;;
*.*.*) ;;

*.*)
port="0.$port"
;;

5
modules.d/80lvmmerge/lvmmerge.sh

@ -11,8 +11,8 @@ do_merge() { @@ -11,8 +11,8 @@ do_merge() {
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")
@ -93,4 +93,3 @@ do_merge() { @@ -93,4 +93,3 @@ do_merge() {
if getarg rd.lvm.mergetags; then
do_merge
fi


2
modules.d/81cio_ignore/module-setup.sh

@ -15,7 +15,7 @@ cmdline() { @@ -15,7 +15,7 @@ cmdline() {

if [ -e /boot/zipl/active_devices.txt ]; then
while read dev etc; do
[ "$dev" = "#" -o "$dev" = "" ] && continue;
[ "$dev" = "#" -o "$dev" = "" ] && continue
if [ -z "$cio_accept" ]; then
cio_accept="$dev"
else

6
modules.d/90btrfs/module-setup.sh

@ -34,9 +34,11 @@ install() { @@ -34,9 +34,11 @@ install() {
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


84
modules.d/90crypt/crypt-lib.sh

@ -49,28 +49,65 @@ crypttab_contains() { @@ -49,28 +49,65 @@ 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;;
--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
plymouth ask-for-password \
@ -85,8 +122,8 @@ ask_for_password() { @@ -85,8 +122,8 @@ ask_for_password() {

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))
@ -107,8 +144,11 @@ ask_for_password() { @@ -107,8 +144,11 @@ ask_for_password() {
# 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
@ -139,7 +179,8 @@ test_dev() { @@ -139,7 +179,8 @@ test_dev() {
# 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
@ -162,8 +203,11 @@ $dev @@ -162,8 +203,11 @@ $dev
# 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

12
modules.d/90crypt/module-setup.sh

@ -95,14 +95,14 @@ install() { @@ -95,14 +95,14 @@ install() {
[[ $_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"


7
modules.d/90crypt/parse-crypt.sh

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@

type crypttab_contains > /dev/null 2>&1 || . /lib/dracut-crypt-lib.sh


_cryptgetargsname() {
debug_off
local _o _found _key
@ -12,15 +11,15 @@ _cryptgetargsname() { @@ -12,15 +11,15 @@ _cryptgetargsname() {
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

4
modules.d/90crypt/parse-keydev.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh

if getargbool 1 rd.luks -n rd_NO_LUKS && \
[ -n "$(getarg rd.luks.key)" ]; then
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

5
modules.d/90crypt/probe-keydev.sh

@ -2,8 +2,9 @@ @@ -2,8 +2,9 @@

. /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='*'

4
modules.d/90dm/dm-shutdown.sh

@ -45,8 +45,8 @@ _do_dm_shutdown() { @@ -45,8 +45,8 @@ _do_dm_shutdown() {
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
:

5
modules.d/90dm/module-setup.sh

@ -18,8 +18,8 @@ installkernel() { @@ -18,8 +18,8 @@ installkernel() {

# 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
@ -40,4 +40,3 @@ install() { @@ -40,4 +40,3 @@ install() {

inst_hook shutdown 25 "$moddir/dm-shutdown.sh"
}


4
modules.d/90dmsquash-live/apply-live-updates.sh

@ -15,8 +15,8 @@ if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then @@ -15,8 +15,8 @@ if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then
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

15
modules.d/90dmsquash-live/dmsquash-generator.sh

@ -18,20 +18,25 @@ fi @@ -18,20 +18,25 @@ fi
case "$liveroot" in
live:LABEL=* | LABEL=* | live:UUID=* | UUID=* | live:PARTUUID=* | PARTUUID=* | live:PARTLABEL=* | PARTLABEL=*)
root="live:$(label_uuid_to_dev "${root#live:}")"
rootok=1 ;;
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 ;;
rootok=1
;;
live:/*.[Ii][Ss][Oo] | /*.[Ii][Ss][Oo])
root="${root#live:}"
root="liveiso:${root}"
rootok=1 ;;
rootok=1
;;
live:/dev/*)
rootok=1 ;;
rootok=1
;;
live:/*.[Ii][Mm][Gg] | /*.[Ii][Mm][Gg])
[ -f "${root#live:}" ] && rootok=1 ;;
[ -f "${root#live:}" ] && rootok=1
;;
esac

[ "$rootok" != "1" ] && exit 0

19
modules.d/90dmsquash-live/dmsquash-live-root.sh

@ -151,8 +151,8 @@ do_live_overlay() { @@ -151,8 +151,8 @@ do_live_overlay() {
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
@ -162,8 +162,8 @@ do_live_overlay() { @@ -162,8 +162,8 @@ do_live_overlay() {
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
@ -191,8 +191,8 @@ do_live_overlay() { @@ -191,8 +191,8 @@ do_live_overlay() {
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
@ -341,9 +341,9 @@ if [ -n "$FSIMG" ]; then @@ -341,9 +341,9 @@ if [ -n "$FSIMG" ]; then
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
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
@ -403,4 +403,3 @@ ln -s null /dev/root @@ -403,4 +403,3 @@ ln -s null /dev/root
need_shutdown

exit 0


15
modules.d/90dmsquash-live/parse-dmsquash-live.sh

@ -20,20 +20,25 @@ modprobe -q loop @@ -20,20 +20,25 @@ modprobe -q loop
case "$liveroot" in
live:LABEL=* | LABEL=* | live:UUID=* | UUID=* | live:PARTUUID=* | PARTUUID=* | live:PARTLABEL=* | PARTLABEL=*)
root="live:$(label_uuid_to_dev "${root#live:}")"
rootok=1 ;;
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 ;;
rootok=1
;;
live:/*.[Ii][Ss][Oo] | /*.[Ii][Ss][Oo])
root="${root#live:}"
root="liveiso:${root}"
rootok=1 ;;
rootok=1
;;
live:/dev/*)
rootok=1 ;;
rootok=1
;;
live:/*.[Ii][Mm][Gg] | /*.[Ii][Mm][Gg])
[ -f "${root#live:}" ] && rootok=1 ;;
[ -f "${root#live:}" ] && rootok=1
;;
esac

[ "$rootok" = "1" ] || return 1

23
modules.d/90kernel-modules-extra/module-setup.sh

@ -21,8 +21,7 @@ @@ -21,8 +21,7 @@
# - "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()
{
installkernel() {
: "${depmod_modules_dep:=$srcmods/modules.dep}"
: "${depmod_module_dir:=$srcmods}"

@ -47,7 +46,6 @@ installkernel() @@ -47,7 +46,6 @@ installkernel()
local external_dirs=()
local e f


## Gathering and sorting configuration file list

[ -n "${depmod_configs[*]-}" ] \
@ -82,7 +80,6 @@ installkernel() @@ -82,7 +80,6 @@ installkernel()
| sort -u -k1,1 -t '/' | cut -f 2- -d '/'))
IFS="$OLDIFS"


## Parse configurations

for cfg in "${cfgs[@]}"; do
@ -99,16 +96,14 @@ installkernel() @@ -99,16 +96,14 @@ installkernel()
override) # module_name kver_pattern dir
read -r mod kverpat path <<< "$v"

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

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

prdebug "$cfg: added override" \
@ -128,9 +123,8 @@ installkernel() @@ -128,9 +123,8 @@ installkernel()
continue
fi

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

prdebug "$cfg: added external" \
@ -157,7 +151,6 @@ installkernel() @@ -157,7 +151,6 @@ installkernel()
# "updates built-in" is the default search list
: "${search_list:=updates}"


## Build a list of regular expressions for grepping modules.dep

local pathlist=()
@ -178,7 +171,6 @@ installkernel() @@ -178,7 +171,6 @@ installkernel()
pathlist+=("$(re_escape "${f%/}")/[^:]+")
done


## Filter modules.dep, canonicalise the resulting filenames and supply
## them to instmods.

@ -187,7 +179,10 @@ installkernel() @@ -187,7 +179,10 @@ installkernel()
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 --) \
| (
cd "$depmod_module_dir" || exit
xargs -r realpath -se --
) \
| instmods || return 1

return 0

5
modules.d/90kernel-modules/module-setup.sh

@ -104,9 +104,8 @@ installkernel() { @@ -104,9 +104,8 @@ installkernel() {

# 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

1
modules.d/90kernel-modules/parse-kernel.sh

@ -18,7 +18,6 @@ for i in $(getargs rd.driver.pre -d rdloaddriver=); do @@ -18,7 +18,6 @@ for i in $(getargs rd.driver.pre -d rdloaddriver=); do
)
done


[ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d

for i in $(getargs rd.driver.blacklist -d rdblacklist=); do

1
modules.d/90kernel-network-modules/module-setup.sh

@ -48,4 +48,3 @@ installkernel() { @@ -48,4 +48,3 @@ installkernel() {
install() {
return 0
}


30
modules.d/90livenet/livenet-generator.sh

@ -16,24 +16,30 @@ fi @@ -16,24 +16,30 @@ 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

3
modules.d/90livenet/livenetroot.sh

@ -19,8 +19,7 @@ info "fetching $liveurl" @@ -19,8 +19,7 @@ info "fetching $liveurl"
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

32
modules.d/90lvm/lvm_scan.sh

@ -22,25 +22,25 @@ lvmdevs=$( @@ -22,25 +22,25 @@ lvmdevs=$(

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
@ -69,13 +69,13 @@ IFS=$OLDIFS @@ -69,13 +69,13 @@ 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"

3
modules.d/90lvm/module-setup.sh

@ -130,7 +130,8 @@ install() { @@ -130,7 +130,8 @@ install() {
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;;
break
;;
esac
done
fi

1
modules.d/90lvm/parse-lvm.sh

@ -15,4 +15,3 @@ else @@ -15,4 +15,3 @@ else
wait_for_dev -n "/dev/$dev"
done
fi


5
modules.d/90mdraid/parse-md.sh

@ -17,11 +17,11 @@ else @@ -17,11 +17,11 @@ 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
@ -37,7 +37,6 @@ else @@ -37,7 +37,6 @@ 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

1
modules.d/90multipath/module-setup.sh

@ -127,4 +127,3 @@ install() { @@ -127,4 +127,3 @@ install() {
66-kpartx.rules 67-kpartx-compat.rules \
11-dm-mpath.rules 11-dm-parts.rules
}


1
modules.d/90multipath/multipathd-stop.sh

@ -9,4 +9,3 @@ if [ -e /etc/multipath.conf ]; then @@ -9,4 +9,3 @@ if [ -e /etc/multipath.conf ]; then
HARD="-9"
done
fi


1
modules.d/90multipath/multipathd.sh

@ -12,4 +12,3 @@ if getargbool 1 rd.multipath -d -n rd_NO_MULTIPATH && [ -e /etc/multipath.conf ] @@ -12,4 +12,3 @@ if getargbool 1 rd.multipath -d -n rd_NO_MULTIPATH && [ -e /etc/multipath.conf ]
else
rm -- /etc/udev/rules.d/??-multipath.rules 2> /dev/null
fi


4
modules.d/90nvdimm/module-setup.sh

@ -5,8 +5,8 @@ check() { @@ -5,8 +5,8 @@ check() {
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
}


10
modules.d/91crypt-gpg/module-setup.sh

@ -42,11 +42,11 @@ sc_public_key() { @@ -42,11 +42,11 @@ sc_public_key() {
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

2
modules.d/91zipl/install_zipl_cmdline.sh

@ -24,7 +24,7 @@ fi @@ -24,7 +24,7 @@ fi

if [ -f ${MNT}/active_devices.txt ]; then
while read dev etc; do
[ "$dev" = "#" -o "$dev" = "" ] && continue;
[ "$dev" = "#" -o "$dev" = "" ] && continue
cio_ignore -r $dev
done < ${MNT}/active_devices.txt
fi

14
modules.d/91zipl/parse-zipl.sh

@ -6,35 +6,35 @@ zipl_arg=$(getarg rd.zipl) @@ -6,35 +6,35 @@ zipl_arg=$(getarg rd.zipl)

if [ -n "$zipl_arg" ]; then
case "$zipl_arg" in
LABEL=*) \
LABEL=*)
zipl_env="ENV{ID_FS_LABEL}"
zipl_val=${zipl_arg#LABEL=}
zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
;;
UUID=*) \
UUID=*)
zipl_env="ENV{ID_FS_UUID}"
zipl_val=${zipl_arg#UUID=}
zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
;;
PARTLABEL=*) \
PARTLABEL=*)
zipl_env="ENV{ID_FS_PARTLABEL}"
zipl_val=${zipl_arg#PARTLABEL=}
zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
;;
PARTUUID=*) \
PARTUUID=*)
zipl_env="ENV{ID_FS_PARTUUID}"
zipl_val=${zipl_arg#PARTUUID=}
zipl_arg="$(label_uuid_to_dev "${zipl_val}")"
;;
/dev/mapper/*) \
/dev/mapper/*)
zipl_env="ENV{DM_NAME}"
zipl_val=${zipl_arg#/dev/mapper/}
;;
/dev/disk/by-*) \
/dev/disk/by-*)
zipl_env="SYMLINK"
zipl_val=${zipl_arg#/dev/}
;;
/dev/*) \
/dev/*)
zipl_env="KERNEL"
zipl_val=${zipl_arg}
;;

3
modules.d/95cifs/cifs-lib.sh

@ -8,7 +8,8 @@ @@ -8,7 +8,8 @@
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%@*}

2
modules.d/95cifs/parse-cifsroot.sh

@ -40,7 +40,7 @@ cifs_to_var $netroot @@ -40,7 +40,7 @@ cifs_to_var $netroot
# If we don't have a server, we need dhcp
if [ -z "$server" ]; then
DHCPORSERVER="1"
fi;
fi

# Done, all good!
rootok=1

1
modules.d/95dasd/module-setup.sh

@ -25,4 +25,3 @@ install() { @@ -25,4 +25,3 @@ install() {
inst_rules 56-dasd.rules
inst_rules 59-dasd.rules
}


1
modules.d/95dasd_mod/module-setup.sh

@ -25,4 +25,3 @@ install() { @@ -25,4 +25,3 @@ install() {
inst_multiple grep sed seq
inst_multiple -o dasd_cio_free
}


10
modules.d/95dasd_rules/module-setup.sh

@ -4,7 +4,10 @@ @@ -4,7 +4,10 @@
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/*}"
@ -28,8 +31,9 @@ check() { @@ -28,8 +31,9 @@ check() {
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

2
modules.d/95dasd_rules/parse-dasd.sh

@ -42,7 +42,7 @@ ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1" @@ -42,7 +42,7 @@ ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1"
EOF
}

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

1
modules.d/95debug/module-setup.sh

@ -20,4 +20,3 @@ install() { @@ -20,4 +20,3 @@ install() {

grep '^tcpdump:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
}


3
modules.d/95fcoe-uefi/parse-uefifcoe.sh

@ -4,8 +4,7 @@ command -v getarg >/dev/null || . /lib/dracut-lib.sh @@ -4,8 +4,7 @@ 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

1
modules.d/95fcoe/fcoe-up.sh

@ -34,7 +34,6 @@ if fcoemon -h|grep syslog|grep -q yes; then @@ -34,7 +34,6 @@ if fcoemon -h|grep syslog|grep -q yes; then
fcoemonyes="$syslogopt=yes"
fi


netdriver=$(readlink -f /sys/class/net/$netif/device/driver)
netdriver=${netdriver##*/}


6
modules.d/95fcoe/module-setup.sh

@ -51,7 +51,10 @@ cmdline() { @@ -51,7 +51,10 @@ cmdline() {
else
mode="fabric"
fi
d=$(cd -P $c; echo $PWD)
d=$(
cd -P $c
echo $PWD
)
i=${d%/*}
ifname=${i##*/}
read mac < ${i}/address
@ -114,4 +117,3 @@ install() { @@ -114,4 +117,3 @@ install() {
inst_hook shutdown 40 "$moddir/stop-fcoe.sh"
dracut_need_initqueue
}


28
modules.d/95iscsi/iscsiroot.sh

@ -37,16 +37,14 @@ iroot=${iroot#:} @@ -37,16 +37,14 @@ iroot=${iroot#:}
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
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
@ -57,7 +55,10 @@ handle_firmware() @@ -57,7 +55,10 @@ handle_firmware()
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
@ -81,9 +82,7 @@ handle_firmware() @@ -81,9 +82,7 @@ handle_firmware()
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
@ -107,8 +106,8 @@ handle_netroot() @@ -107,8 +106,8 @@ handle_netroot()
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
[ "${p%=*}" = node.session.initial_login_retry_max ] \
&& login_retry_max_seen=yes
iscsi_param="$iscsi_param $p"
done

@ -169,7 +168,6 @@ handle_netroot() @@ -169,7 +168,6 @@ handle_netroot()
fi
fi


if [ -z "$iscsi_target_port" ]; then
iscsi_target_port=3260
fi
@ -209,8 +207,8 @@ handle_netroot() @@ -209,8 +207,8 @@ handle_netroot()
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

8
modules.d/95iscsi/module-setup.sh

@ -85,7 +85,7 @@ install_iscsiroot() { @@ -85,7 +85,7 @@ install_iscsiroot() {
# 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

@ -133,7 +133,6 @@ install_iscsiroot() { @@ -133,7 +133,6 @@ install_iscsiroot() {
return 0
}


install_softiscsi() {
[ -d /sys/firmware/ibft ] && return 0

@ -142,7 +141,10 @@ install_softiscsi() { @@ -142,7 +141,10 @@ install_softiscsi() {
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
}


4
modules.d/95iscsi/parse-iscsiroot.sh

@ -69,8 +69,8 @@ if [ -n "$iscsiroot" ] ; then @@ -69,8 +69,8 @@ if [ -n "$iscsiroot" ] ; then
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

5
modules.d/95lunmask/module-setup.sh

@ -6,7 +6,10 @@ @@ -6,7 +6,10 @@
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

1
modules.d/95nbd/module-setup.sh

@ -37,4 +37,3 @@ install() { @@ -37,4 +37,3 @@ install() {
fi
dracut_need_initqueue
}


11
modules.d/95nbd/nbd-generator.sh

@ -14,15 +14,18 @@ GENERATOR_DIR="$2" @@ -14,15 +14,18 @@ GENERATOR_DIR="$2"
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

15
modules.d/95nbd/nbdroot.sh

@ -22,15 +22,18 @@ NEWROOT="$3" @@ -22,15 +22,18 @@ NEWROOT="$3"
[ "${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#*:}

@ -125,8 +128,8 @@ else @@ -125,8 +128,8 @@ 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

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save