diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:33:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:33:11 +0000 |
commit | 203af7302854f453fa4a05ecefd4403b6c8a4f8d (patch) | |
tree | 967fdacafe332baabd12b57725505c138d0f3bbf /modules.d | |
parent | Adding upstream version 102. (diff) | |
download | dracut-upstream/103.tar.xz dracut-upstream/103.zip |
Adding upstream version 103.upstream/103upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
97 files changed, 467 insertions, 280 deletions
diff --git a/modules.d/00systemd/module-setup.sh b/modules.d/00systemd/module-setup.sh index d173c99..ce7bb52 100755 --- a/modules.d/00systemd/module-setup.sh +++ b/modules.d/00systemd/module-setup.sh @@ -158,7 +158,9 @@ EOF emergency.target \ rescue.target; do [[ -f "$systemdsystemunitdir"/$i ]] || continue - $SYSTEMCTL -q --root "$initdir" add-wants "$i" systemd-vconsole-setup.service + if [ -e "$systemdsystemunitdir"/systemd-vconsole-setup.service ]; then + $SYSTEMCTL -q --root "$initdir" add-wants "$i" systemd-vconsole-setup.service + fi done mkdir -p "$initdir/etc/systemd" diff --git a/modules.d/00warpclock/module-setup.sh b/modules.d/00warpclock/module-setup.sh index 44aa177..dd093f3 100755 --- a/modules.d/00warpclock/module-setup.sh +++ b/modules.d/00warpclock/module-setup.sh @@ -7,7 +7,7 @@ check() { # hwclock does not exist on S390(x), bail out silently then local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] && return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] && return 1 # If the binary(s) requirements are not fulfilled the module can't be installed. require_binaries hwclock || return 1 diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh index c81c2a6..2c7b2e3 100755 --- a/modules.d/01fips/fips.sh +++ b/modules.d/01fips/fips.sh @@ -94,16 +94,14 @@ fips_load_crypto() { local _module local _found - read -d '' -r FIPSMODULES < /etc/fipsmodules - fips_info "Loading and integrity checking all crypto modules" - for _module in $FIPSMODULES; do + while read -r _module; do if [ "$_module" != "tcrypt" ]; then if ! nonfatal_modprobe "${_module}" 2> /tmp/fips.modprobe_err; then # check if kernel provides generic algo _found=0 while read -r _k _ _v || [ -n "$_k" ]; do - [ "$_k" != "name" -a "$_k" != "driver" ] && continue + [ "$_k" != "name" ] && [ "$_k" != "driver" ] && continue [ "$_v" != "$_module" ] && continue _found=1 break @@ -111,7 +109,7 @@ fips_load_crypto() { [ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1 fi fi - done + done < /etc/fipsmodules if [ -f /etc/fips.conf ]; then mkdir -p /run/modprobe.d cp /etc/fips.conf /run/modprobe.d/fips.conf diff --git a/modules.d/01fips/module-setup.sh b/modules.d/01fips/module-setup.sh index 83fcd56..1e0c9d0 100755 --- a/modules.d/01fips/module-setup.sh +++ b/modules.d/01fips/module-setup.sh @@ -30,7 +30,7 @@ installkernel() { _fipsmodules+="ecb cbc ctr xts gcm ccm authenc hmac cmac ofb cts " # Compression algs: - _fipsmodules+="deflate lzo zlib " + _fipsmodules+="deflate lzo " # PRNG algs: _fipsmodules+="ansi_cprng " diff --git a/modules.d/01systemd-coredump/module-setup.sh b/modules.d/01systemd-coredump/module-setup.sh index 47666b6..0c5cbcf 100755 --- a/modules.d/01systemd-coredump/module-setup.sh +++ b/modules.d/01systemd-coredump/module-setup.sh @@ -30,6 +30,8 @@ depends() { install() { inst_dir /var/lib/systemd/coredump + inst_sysusers systemd-coredump.conf + inst_multiple -o \ "$sysctld"/50-coredump.conf \ "$systemdutildir"/coredump.conf \ @@ -37,7 +39,6 @@ install() { "$systemdsystemunitdir"/systemd-coredump.socket \ "$systemdsystemunitdir"/systemd-coredump@.service \ "$systemdsystemunitdir"/sockets.target.wants/systemd-coredump.socket \ - "$sysusers"/systemd-coredump.conf \ coredumpctl # Install library file(s) @@ -56,7 +57,6 @@ install() { "$systemdsystemconfdir/systemd-coredump.socket.d/*.conf" \ "$systemdsystemconfdir"/systemd-coredump@.service \ "$systemdsystemconfdir/systemd-coredump@.service.d/*.conf" \ - "$systemdsystemconfdir"/sockets.target.wants/systemd-coredump.socket \ - "$sysusersconfdir"/systemd-coredump.conf + "$systemdsystemconfdir"/sockets.target.wants/systemd-coredump.socket fi } diff --git a/modules.d/01systemd-hostnamed/module-setup.sh b/modules.d/01systemd-hostnamed/module-setup.sh index 2a1fa02..d589061 100755 --- a/modules.d/01systemd-hostnamed/module-setup.sh +++ b/modules.d/01systemd-hostnamed/module-setup.sh @@ -39,6 +39,9 @@ install() { "$systemdutildir"/systemd-hostnamed \ "$systemdsystemunitdir"/systemd-hostnamed.service \ "$systemdsystemunitdir/systemd-hostnamed.service.d/*.conf" \ + "$systemdsystemunitdir"/systemd-hostnamed.socket \ + "$systemdsystemunitdir/systemd-hostnamed.socket.d/*.conf" \ + "$systemdsystemunitdir"/sockets.target.wants/systemd-hostnamed.socket \ "$systemdsystemunitdir"/dbus-org.freedesktop.hostname1.service \ hostnamectl @@ -47,6 +50,9 @@ install() { inst_multiple -H -o \ /etc/hostname \ "$systemdsystemconfdir"/systemd-hostnamed.service \ - "$systemdsystemconfdir/systemd-hostnamed.service.d/*.conf" + "$systemdsystemconfdir/systemd-hostnamed.service.d/*.conf" \ + "$systemdsystemconfdir"/systemd-hostnamed.socket \ + "$systemdsystemconfdir"/sockets.target.wants/systemd-hostnamed.socket \ + "$systemdsystemconfdir/systemd-hostnamed.socket.d/*.conf" fi } diff --git a/modules.d/01systemd-journald/module-setup.sh b/modules.d/01systemd-journald/module-setup.sh index e0944d2..77d6a2e 100755 --- a/modules.d/01systemd-journald/module-setup.sh +++ b/modules.d/01systemd-journald/module-setup.sh @@ -31,6 +31,8 @@ install() { inst_simple "$moddir/initrd.conf" "$systemdutildir/journald.conf.d/initrd.conf" + inst_sysusers systemd-journal.conf + inst_multiple -o \ "$systemdutildir"/journald.conf \ "$systemdutildir/journald.conf.d/*.conf" \ @@ -47,7 +49,6 @@ install() { "$systemdsystemunitdir"/sockets.target.wants/systemd-journald-dev-log.socket \ "$systemdsystemunitdir"/sockets.target.wants/systemd-journald.socket \ "$systemdsystemunitdir"/sysinit.target.wants/systemd-journald.service \ - "$sysusers"/systemd-journal.conf \ journalctl # Install library file(s) @@ -66,8 +67,7 @@ install() { "$systemdsystemconfdir"/systemd-journald.service \ "$systemdsystemconfdir/systemd-journald.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-journal-catalog-update.service \ - "$systemdsystemconfdir/systemd-journal-catalog-update.service.d/*.conf" \ - "$sysusersconfdir"/systemd-journal.conf + "$systemdsystemconfdir/systemd-journal-catalog-update.service.d/*.conf" fi } diff --git a/modules.d/01systemd-networkd/99-default.network b/modules.d/01systemd-networkd/99-default.network new file mode 100644 index 0000000..d4fe15c --- /dev/null +++ b/modules.d/01systemd-networkd/99-default.network @@ -0,0 +1,13 @@ +[Match] +Kind=!* +Type=!loopback + +[Network] +DHCP=yes + +[DHCPv4] +ClientIdentifier=mac +RequestOptions=17 + +[DHCPv6] +RequestOptions=59 60 diff --git a/modules.d/01systemd-networkd/99-wait-online-dracut.conf b/modules.d/01systemd-networkd/99-wait-online-dracut.conf new file mode 100644 index 0000000..da90596 --- /dev/null +++ b/modules.d/01systemd-networkd/99-wait-online-dracut.conf @@ -0,0 +1,9 @@ +[Unit] +Before=dracut-initqueue.service +ConditionPathExists=/run/networkd/initrd/neednet + +[Service] +TimeoutStartSec=120 + +[Install] +WantedBy=initrd.target diff --git a/modules.d/01systemd-networkd/module-setup.sh b/modules.d/01systemd-networkd/module-setup.sh index 3658882..007590b 100755 --- a/modules.d/01systemd-networkd/module-setup.sh +++ b/modules.d/01systemd-networkd/module-setup.sh @@ -22,7 +22,7 @@ check() { depends() { # This module has external dependency on other module(s). - echo kernel-network-modules systemd-sysusers + echo kernel-network-modules systemd-sysusers systemd # Return 0 to include the dependent module(s) in the initramfs. return 0 @@ -31,6 +31,8 @@ depends() { # Install the required file(s) and directories for the module in the initramfs. install() { + inst_sysusers systemd-network.conf + inst_multiple -o \ "$tmpfilesdir"/systemd-network.conf \ "$dbussystem"/org.freedesktop.network1.conf \ @@ -55,8 +57,16 @@ install() { "$systemdsystemunitdir"/systemd-networkd-wait-online.service \ "$systemdsystemunitdir"/systemd-networkd-wait-online@.service \ "$systemdsystemunitdir"/systemd-network-generator.service \ - "$sysusers"/systemd-network.conf \ - ip + ip sed grep + + inst_simple "$moddir"/99-wait-online-dracut.conf \ + "$systemdsystemunitdir"/systemd-networkd-wait-online.service.d/99-dracut.conf + + inst_simple "$moddir"/99-default.network \ + "$systemdnetworkconfdir"/99-dracut-default.network + + inst_hook cmdline 99 "$moddir"/networkd-config.sh + inst_hook initqueue/settled 99 "$moddir"/networkd-run.sh # Enable systemd type units for i in \ @@ -82,7 +92,6 @@ install() { "$systemdsystemconfdir"/systemd-networkd-wait-online.service \ "$systemdsystemconfdir/systemd-networkd-wait-online.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-networkd-wait-online@.service \ - "$systemdsystemconfdir/systemd-networkd-wait-online@.service.d/*.conf" \ - "$sysusersconfdir"/systemd-network.conf + "$systemdsystemconfdir/systemd-networkd-wait-online@.service.d/*.conf" fi } diff --git a/modules.d/01systemd-networkd/networkd-config.sh b/modules.d/01systemd-networkd/networkd-config.sh new file mode 100755 index 0000000..eb450c6 --- /dev/null +++ b/modules.d/01systemd-networkd/networkd-config.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh + +# Just in case we're running before it +systemctl start systemd-network-generator.service + +# Customizations for systemd-network-generator generated networks. +# We need to request certain DHCP options, and there is no way to +# tell the generator to add those. +for f in /run/systemd/network/*.network; do + [ -f "$f" ] || continue + + { + echo "[DHCPv4]" + echo "ClientIdentifier=mac" + echo "RequestOptions=17" + echo "[DHCPv6]" + echo "RequestOptions=59 60" + } >> "$f" + + # Remove the default network if at least one was generated + rm -f "$systemdnetworkconfdir"/99-dracut-default.network +done + +# Just in case networkd was already running +systemctl try-reload-or-restart systemd-networkd.service + +if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then + echo rd.neednet >> /etc/cmdline.d/networkd.conf +fi + +if getargbool 0 rd.neednet; then + mkdir -p /run/networkd/initrd + : > /run/networkd/initrd/neednet +fi diff --git a/modules.d/01systemd-networkd/networkd-run.sh b/modules.d/01systemd-networkd/networkd-run.sh new file mode 100755 index 0000000..5445b46 --- /dev/null +++ b/modules.d/01systemd-networkd/networkd-run.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh + +for ifpath in /sys/class/net/*; do + ifname="$(basename "$ifpath")" + + # shellcheck disable=SC2015 + [ "$ifname" != "lo" ] && [ -e "$ifpath" ] && [ ! -e /tmp/networkd."$ifname".done ] || continue + + if /usr/lib/systemd/systemd-networkd-wait-online --timeout=0.000001 --interface="$ifname" 2> /dev/null; then + leases_file="/run/systemd/netif/leases/$(cat "$ifpath"/ifindex)" + dhcpopts_file="/tmp/dhclient.${ifname}.dhcpopts" + if [ -r "$leases_file" ]; then + grep -E "^(NEXT_SERVER|ROOT_PATH)=" "$leases_file" \ + | sed -e "s/NEXT_SERVER=/new_next_server='/" \ + -e "s/ROOT_PATH=/new_root_path='/" \ + -e "s/$/'/" > "$dhcpopts_file" || true + fi + + source_hook initqueue/online "$ifname" + /sbin/netroot "$ifname" + + : > /tmp/networkd."$ifname".done + fi +done diff --git a/modules.d/01systemd-pcrphase/module-setup.sh b/modules.d/01systemd-pcrphase/module-setup.sh index eb85207..3016d7e 100755 --- a/modules.d/01systemd-pcrphase/module-setup.sh +++ b/modules.d/01systemd-pcrphase/module-setup.sh @@ -4,7 +4,6 @@ # Prerequisite check(s) for module. check() { - # If the binary(s) requirements are not fulfilled the module can't be installed. # systemd-255 renamed the binary, check for old and new location. if ! require_binaries "$systemdutildir"/systemd-pcrphase \ @@ -12,23 +11,34 @@ check() { return 1 fi - return 0 + if [[ $hostonly ]]; then + return 255 + fi + return 0 } # Module dependency requirements. depends() { - # This module has external dependency on other module(s). - echo systemd tpm2-tss + + local deps + deps="systemd" + + # optional dependencies + module="tpm2-tss" + module_check $module > /dev/null 2>&1 + if [[ $? == 255 ]]; then + deps+=" $module" + fi + echo "$deps" + # Return 0 to include the dependent module(s) in the initramfs. return 0 - } # Install the required file(s) and directories for the module in the initramfs. install() { - inst_multiple -o \ "$systemdutildir"/systemd-pcrphase \ "$systemdutildir"/systemd-pcrextend \ @@ -43,5 +53,4 @@ install() { "$systemdsystemconfdir/systemd-pcrphase-initrd.service.d/*.conf" \ "$systemdsystemconfdir"/initrd.target.wants/systemd-pcrphase-initrd.service fi - } diff --git a/modules.d/01systemd-resolved/module-setup.sh b/modules.d/01systemd-resolved/module-setup.sh index 0c2e8c2..b354bc6 100755 --- a/modules.d/01systemd-resolved/module-setup.sh +++ b/modules.d/01systemd-resolved/module-setup.sh @@ -31,6 +31,8 @@ install() { inst_simple "$moddir/resolved-tmpfile-dracut.conf" "$tmpfilesdir/resolved-tmpfile-dracut.conf" + inst_sysusers systemd-resolve.conf + inst_multiple -o \ "$dbussystem"/org.freedesktop.resolve1.conf \ "$dbussystemservices"/org.freedesktop.resolve1.service \ @@ -40,7 +42,6 @@ install() { "$systemdutildir"/systemd-resolved \ "$systemdsystemunitdir"/systemd-resolved.service \ "$systemdsystemunitdir/systemd-resolved.service.d/*.conf" \ - "$sysusers"/systemd-resolve.conf \ resolvectl # Enable systemd type unit(s) @@ -52,7 +53,6 @@ install() { "$systemdutilconfdir"/resolved.conf \ "$systemdutilconfdir/resolved.conf.d/*.conf" \ "$systemdsystemconfdir"/systemd-resolved.service \ - "$systemdsystemconfdir/systemd-resolved.service.d/*.conf" \ - "$sysusersconfdir"/systemd-resolve.conf + "$systemdsystemconfdir/systemd-resolved.service.d/*.conf" fi } diff --git a/modules.d/01systemd-sysusers/module-setup.sh b/modules.d/01systemd-sysusers/module-setup.sh index 4ec48dc..351f45c 100755 --- a/modules.d/01systemd-sysusers/module-setup.sh +++ b/modules.d/01systemd-sysusers/module-setup.sh @@ -26,9 +26,10 @@ install() { inst_simple "$moddir/sysusers-dracut.conf" "$systemdsystemunitdir/systemd-sysusers.service.d/sysusers-dracut.conf" + inst_sysusers basic.conf + inst_sysusers systemd.conf + inst_multiple -o \ - "$sysusers"/basic.conf \ - "$sysusers"/systemd.conf \ "$systemdsystemunitdir"/systemd-sysusers.service \ "$systemdsystemunitdir"/sysinit.target.wants/systemd-sysusers.service \ systemd-sysusers @@ -36,8 +37,6 @@ install() { # Install the hosts local user configurations if enabled. if [[ $hostonly ]]; then inst_multiple -H -o \ - "$sysusersconfdir"/basic.conf \ - "$sysusersconfdir"/systemd.conf \ "$systemdsystemconfdir"/systemd-sysusers.service \ "$systemdsystemconfdir/systemd-sysusers.service.d/*.conf" fi diff --git a/modules.d/01systemd-timesyncd/module-setup.sh b/modules.d/01systemd-timesyncd/module-setup.sh index a2c6754..0c065af 100755 --- a/modules.d/01systemd-timesyncd/module-setup.sh +++ b/modules.d/01systemd-timesyncd/module-setup.sh @@ -32,6 +32,8 @@ install() { # Enable this if networkd ( not the module ) is disabled at build time and you want to use timesyncd # inst_simple "$moddir/timesyncd-tmpfile-dracut.conf" "$tmpfilesdir/timesyncd-tmpfile-dracut.conf" + inst_sysusers systemd-timesync.conf + inst_multiple -o \ "$dbussystem"/org.freedesktop.timesync1.conf \ "$dbussystemservices"/org.freedesktop.timesync1.service \ @@ -42,8 +44,7 @@ install() { "$systemdsystemunitdir"/systemd-timesyncd.service \ "$systemdsystemunitdir/systemd-timesyncd.service.d/*.conf" \ "$systemdsystemunitdir"/systemd-time-wait-sync.service \ - "$systemdsystemunitdir/systemd-time-wait-sync.service.d/*.conf" \ - "$sysusers"/systemd-timesync.conf + "$systemdsystemunitdir/systemd-time-wait-sync.service.d/*.conf" # Enable systemd type unit(s) for i in \ @@ -61,7 +62,6 @@ install() { "$systemdsystemconfdir"/systemd-timesyncd.service \ "$systemdsystemconfdir/systemd-timesyncd.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-time-wait-sync.service \ - "$systemdsystemconfdir/systemd-time-wait-sync.service.d/*.conf" \ - "$sysusersconfdir"/systemd-timesync.conf + "$systemdsystemconfdir/systemd-time-wait-sync.service.d/*.conf" fi } diff --git a/modules.d/01systemd-udevd/module-setup.sh b/modules.d/01systemd-udevd/module-setup.sh index 168167f..8d4a8b9 100755 --- a/modules.d/01systemd-udevd/module-setup.sh +++ b/modules.d/01systemd-udevd/module-setup.sh @@ -30,31 +30,6 @@ depends() { install() { inst_multiple -o \ - /etc/udev/udev.hwdb \ - "$udevdir"/hwdb.bin \ - "$udevdir"/dmi_memory_id \ - "$udevdir"/fido_id \ - "$udevdir"/mtd_probe \ - "$udevdir"/mtp-probe \ - "$udevdir"/v4l_id \ - "$udevrulesdir"/60-autosuspend.rules \ - "$udevrulesdir"/60-drm.rules \ - "$udevrulesdir"/60-evdev.rules \ - "$udevrulesdir"/60-fido-id.rules \ - "$udevrulesdir"/60-input-id.rules \ - "$udevrulesdir"/60-persistent-alsa.rules \ - "$udevrulesdir"/60-persistent-input.rules \ - "$udevrulesdir"/60-persistent-storage-tape.rules \ - "$udevrulesdir"/60-persistent-v4l.rules \ - "$udevrulesdir"/60-sensor.rules \ - "$udevrulesdir"/60-serial.rules \ - "$udevrulesdir"/70-joystick.rules \ - "$udevrulesdir"/70-memory.rules \ - "$udevrulesdir"/70-mouse.rules \ - "$udevrulesdir"/70-touchpad.rules \ - "$udevrulesdir"/75-probe_mtd.rules \ - "$udevrulesdir"/78-sound-card.rules \ - "$udevrulesdir"/81-net-dhcp.rules \ "$udevrulesdir"/99-systemd.rules \ "$systemdutildir"/systemd-udevd \ "$systemdsystemunitdir"/systemd-udevd.service \ @@ -73,9 +48,6 @@ install() { # Install the hosts local user configurations if enabled. if [[ $hostonly ]]; then inst_multiple -H -o \ - "$udevconfdir"/hwdb.bin \ - "$udevrulesconfdir/*.rules" \ - "$systemdutilconfdir"/hwdb/hwdb.bin \ "$systemdsystemconfdir"/systemd-udevd.service \ "$systemdsystemconfdir/systemd-udevd.service.d/*.conf" \ "$systemdsystemconfdir"/systemd-udev-trigger.service \ @@ -90,6 +62,11 @@ install() { "$systemdsystemconfdir"/sockets.target.wants/systemd-udevd-kernel.socket \ "$systemdsystemconfdir"/sysinit.target.wants/systemd-udevd.service \ "$systemdsystemconfdir"/sysinit.target.wants/systemd-udev-trigger.service + + if dracut_module_included "hwdb"; then + inst_multiple -H -o \ + "$systemdutilconfdir"/hwdb/hwdb.bin + fi fi # Install required libraries. diff --git a/modules.d/02caps/caps.sh b/modules.d/02caps/caps.sh index 6c28299..d0997a1 100755 --- a/modules.d/02caps/caps.sh +++ b/modules.d/02caps/caps.sh @@ -12,12 +12,12 @@ if [ "$capsmode" = "1" ]; then info "Loading CAPS_MODULES $CAPS_MODULES" for i in $CAPS_MODULES; do modprobe "$i" 2>&1 > /dev/null | vinfo; done - if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then + if [ "$CAPS_MODULES_DISABLED" = "1" ] && [ -e /proc/sys/kernel/modules_disabled ]; then info "Disabling module loading." echo "$CAPS_MODULES_DISABLED" > /proc/sys/kernel/modules_disabled fi - if [ "$CAPS_KEXEC_DISABLED" = "1" -a -e /proc/sys/kernel/kexec_disabled ]; then + if [ "$CAPS_KEXEC_DISABLED" = "1" ] && [ -e /proc/sys/kernel/kexec_disabled ]; then info "Disabling kexec." echo "$CAPS_KEXEC_DISABLED" > /proc/sys/kernel/kexec_disabled fi diff --git a/modules.d/06dbus-broker/module-setup.sh b/modules.d/06dbus-broker/module-setup.sh index a38fce8..2128c28 100755 --- a/modules.d/06dbus-broker/module-setup.sh +++ b/modules.d/06dbus-broker/module-setup.sh @@ -41,13 +41,14 @@ install() { inst_dir "$dbussystemconfdir" inst_dir "$dbussystemservicesconfdir" + inst_sysusers dbus.conf + inst_multiple -o \ "$dbus"/session.conf \ "$dbus"/system.conf \ "$dbussystem"/org.freedesktop.systemd1.conf \ "$dbusservicesconfdir"/org.freedesktop.systemd1.service \ "$dbussystemservices"/org.freedesktop.systemd1.service \ - "$sysusers"/dbus.conf \ "$systemdcatalog"/dbus-broker.catalog \ "$systemdcatalog"/dbus-broker-launch.catalog \ "$systemdsystemunitdir"/dbus-broker.service \ @@ -75,7 +76,6 @@ install() { inst_multiple -H -o \ "$dbusconfdir"/session.conf \ "$dbusconfdir"/system.conf \ - "$sysusersconfdir"/dbus.conf \ "$systemdsystemconfdir"/dbus.socket \ "$systemdsystemconfdir"/dbus.socket.d/*.conf \ "$systemdsystemconfdir"/dbus-broker.service \ diff --git a/modules.d/06dbus-daemon/module-setup.sh b/modules.d/06dbus-daemon/module-setup.sh index 8345585..e5ad43c 100755 --- a/modules.d/06dbus-daemon/module-setup.sh +++ b/modules.d/06dbus-daemon/module-setup.sh @@ -53,6 +53,8 @@ install() { "$systemdsystemunitdir"/dbus.service \ "$systemdsystemunitdir"/dbus.socket \ "$systemdsystemunitdir"/dbus.target.wants \ + "$systemdsystemunitdir"/multi-user.target.wants/dbus.service \ + "$systemdsystemunitdir"/sockets.target.wants/dbus.socket \ busctl dbus-send dbus-daemon # Adjusting dependencies for initramfs in the dbus service unit. diff --git a/modules.d/09dbus/module-setup.sh b/modules.d/09dbus/module-setup.sh index 679483d..c59995a 100755 --- a/modules.d/09dbus/module-setup.sh +++ b/modules.d/09dbus/module-setup.sh @@ -22,10 +22,7 @@ depends() { if check_module "dbus-broker"; then echo "dbus-broker" return 0 - else - echo "dbus-daemon" - return 0 fi - - return 1 + echo "dbus-daemon" + return 0 } diff --git a/modules.d/30convertfs/convertfs.sh b/modules.d/30convertfs/convertfs.sh index 58fa56d..1052e5c 100755 --- a/modules.d/30convertfs/convertfs.sh +++ b/modules.d/30convertfs/convertfs.sh @@ -21,13 +21,13 @@ while [[ $ROOT != "${ROOT%/}" ]]; do ROOT=${ROOT%/} done -if [ ! -L "$ROOT"/var/run -a -e "$ROOT"/var/run ]; then +if [ ! -L "$ROOT"/var/run ] && [ -e "$ROOT"/var/run ]; then echo "Converting /var/run to symlink" mv -f "$ROOT"/var/run "$ROOT"/var/run.runmove~ ln -sfn ../run "$ROOT"/var/run fi -if [ ! -L "$ROOT"/var/lock -a -e "$ROOT"/var/lock ]; then +if [ ! -L "$ROOT"/var/lock ] && [ -e "$ROOT"/var/lock ]; then echo "Converting /var/lock to symlink" mv -f "$ROOT"/var/lock "$ROOT"/var/lock.lockmove~ ln -sfn ../run/lock "$ROOT"/var/lock @@ -72,16 +72,8 @@ if [[ ! -e $testfile ]]; then fi rm -f -- "$testfile" -find_mount() { - local dev wanted_dev - wanted_dev="$(readlink -e -q "$1")" - while read -r dev _ || [ -n "$dev" ]; do - [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0 - done < /proc/mounts - return 1 -} - # clean up after ourselves no matter how we die. +# shellcheck disable=SC2317 # called via EXIT trap cleanup() { echo "Something failed. Move back to the original state" for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \ @@ -114,7 +106,7 @@ for dir in bin sbin lib lib64; do echo "Merge the copy with \`$ROOT/$dir'." [[ -d "$ROOT/usr/${dir}.usrmove-new" ]] \ || mkdir -p "$ROOT/usr/${dir}.usrmove-new" - cp -axT $CP_HARDLINK --backup --suffix=.usrmove~ "$ROOT/$dir" "$ROOT/usr/${dir}.usrmove-new" + cp -axT ${CP_HARDLINK:+"$CP_HARDLINK"} --backup --suffix=.usrmove~ "$ROOT/$dir" "$ROOT/usr/${dir}.usrmove-new" echo "Clean up duplicates in \`$ROOT/usr/$dir'." # delete all symlinks that have been backed up find "$ROOT/usr/${dir}.usrmove-new" -type l -name '*.usrmove~' -delete || : diff --git a/modules.d/35network-legacy/dhclient-script.sh b/modules.d/35network-legacy/dhclient-script.sh index b3e5e75..6cbc9c2 100755 --- a/modules.d/35network-legacy/dhclient-script.sh +++ b/modules.d/35network-legacy/dhclient-script.sh @@ -114,7 +114,7 @@ parse_option_121() { shift # Is the destination a multicast group? - if [ "$1" -ge 224 -a "$1" -lt 240 ]; then + if [ "$1" -ge 224 ] && [ "$1" -lt 240 ]; then multicast=1 else multicast=0 @@ -153,7 +153,7 @@ parse_option_121() { # Multicast routing on Linux # - If you set a next-hop address for a multicast group, this breaks with Cisco switches # - If you simply leave it link-local and attach it to an interface, it works fine. - if [ $multicast -eq 1 -o "$gateway" = "0.0.0.0" ]; then + if [ $multicast -eq 1 ] || [ "$gateway" = "0.0.0.0" ]; then temp_result="$destination dev $interface" else temp_result="$destination via $gateway dev $interface" diff --git a/modules.d/35network-legacy/ifup.sh b/modules.d/35network-legacy/ifup.sh index 3b54b6c..9827e2e 100755 --- a/modules.d/35network-legacy/ifup.sh +++ b/modules.d/35network-legacy/ifup.sh @@ -301,7 +301,7 @@ if [ -z "$NO_BOND_MASTER" ]; then 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 + if [ "${key}" = "arp_ip_target" ] && [ "${#value}" != "0" ] && [ "+${value%%+*}" != "+" ]; then OLDIFS=$IFS IFS=',' for arp_ip in $value; do @@ -421,7 +421,7 @@ fi # disable manual ifup while netroot is set for simplifying our logic # in netroot case we prefer netroot to bringup $netif automatically -[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2" +[ -n "$2" ] && [ "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2" if [ -n "$manualup" ]; then : > "/tmp/net.$netif.manualup" @@ -536,12 +536,12 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e "/tmp/net.${netif}.up" ]; then # No ip lines, no bootdev -> default to dhcp ip=$(getarg ip) - if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then + if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" ] && [ "$netroot" = "dhcp6" ]; then load_ipv6 do_dhcp -6 ret=$? fi - if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then + if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" ] && [ "$netroot" != "dhcp6" ]; then do_dhcp -4 ret=$? fi diff --git a/modules.d/35network-legacy/module-setup.sh b/modules.d/35network-legacy/module-setup.sh index 42257eb..00e1f36 100755 --- a/modules.d/35network-legacy/module-setup.sh +++ b/modules.d/35network-legacy/module-setup.sh @@ -71,7 +71,7 @@ install() { ( # shellcheck disable=SC1090 . "$i" - if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \ + if ! [ "${ONBOOT}" = "no" ] || [ "${ONBOOT}" = "NO" ] \ && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then mkdir -p "$initdir"/etc/teamd diff --git a/modules.d/35network-legacy/parse-bridge.sh b/modules.d/35network-legacy/parse-bridge.sh index caea1da..d331f9d 100755 --- a/modules.d/35network-legacy/parse-bridge.sh +++ b/modules.d/35network-legacy/parse-bridge.sh @@ -45,5 +45,5 @@ for bridge in $(getargs bridge=); do { echo "bridgename=$bridgename" echo "bridgeslaves=\"$bridgeslaves\"" - } > /tmp/bridge.${bridgename}.info + } > "/tmp/bridge.${bridgename}.info" done diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index 970c252..a72ca54 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -17,12 +17,12 @@ depends() { done if [ -z "$network_handler" ]; then - if check_module "connman"; then - network_handler="connman" - elif check_module "network-manager"; then + if check_module "network-manager"; then network_handler="network-manager" elif check_module "systemd-networkd"; then network_handler="systemd-networkd" + elif check_module "connman"; then + network_handler="connman" else network_handler="network-legacy" fi diff --git a/modules.d/45net-lib/ifname-genrules.sh b/modules.d/45net-lib/ifname-genrules.sh index b9b95c4..34b7a2e 100755 --- a/modules.d/45net-lib/ifname-genrules.sh +++ b/modules.d/45net-lib/ifname-genrules.sh @@ -17,7 +17,7 @@ command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh if [ -f /tmp/ifname-"$ifname_if" ]; then read -r oldmac < /tmp/ifname-"$ifname_if" fi - if [ -n "$oldif" -a -n "$oldmac" -a "$oldif" = "$ifname_if" -a "$oldmac" = "$ifname_mac" ]; then + if [ -n "$oldif" ] && [ -n "$oldmac" ] && [ "$oldif" = "$ifname_if" ] && [ "$oldmac" = "$ifname_mac" ]; then # skip same ifname= declaration continue fi diff --git a/modules.d/45net-lib/module-setup.sh b/modules.d/45net-lib/module-setup.sh index 8053aa6..ed5e5ed 100755 --- a/modules.d/45net-lib/module-setup.sh +++ b/modules.d/45net-lib/module-setup.sh @@ -1,6 +1,7 @@ #!/bin/bash check() { + require_binaries ip awk grep || return 1 return 255 } @@ -14,7 +15,7 @@ install() { inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh" inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" - inst_multiple ip sed awk grep pgrep tr + inst_multiple ip awk grep inst_multiple -o arping arping2 dracut_need_initqueue } diff --git a/modules.d/45net-lib/net-lib.sh b/modules.d/45net-lib/net-lib.sh index 9d88e0d..dc6be88 100755 --- a/modules.d/45net-lib/net-lib.sh +++ b/modules.d/45net-lib/net-lib.sh @@ -319,7 +319,7 @@ ibft_to_cmdline() { gw="[${gw}]" fi fi - if [ -n "$ip" ] && [ -n "$mask" -o -n "$prefix" ]; then + if [ -n "$ip" ] && [ -n "$mask" ] || [ -n "$prefix" ]; then echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}" else warn "${iface} does not contain a valid iBFT configuration" @@ -517,7 +517,7 @@ ip_to_var() { return 0 fi - if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" -o "$2" = "either6" ]; then + if [ "$2" = "dhcp" ] || [ "$2" = "on" ] || [ "$2" = "any" ] || [ "$2" = "dhcp6" ] || [ "$2" = "auto6" ] || [ "$2" = "either6" ]; then # format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]] [ -n "$1" ] && dev="$1" [ -n "$2" ] && autoconf="$2" @@ -546,16 +546,16 @@ ip_to_var() { ;; [0-9]*) mtu="$8" - if [ -n "${9}" -a -z "${10}" ]; then + if [ -n "${9}" ] && [ -z "${10}" ]; then macaddr="${9}" - elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then + elif [ -n "${9}" ] && [ -n "${10}" ] && [ -n "${11}" ] && [ -n "${12}" ] && [ -n "${13}" ] && [ -n "${14}" ]; then macaddr="${9}:${10}:${11}:${12}:${13}:${14}" fi ;; *) - if [ -n "${9}" -a -z "${10}" ]; then + if [ -n "${9}" ] && [ -z "${10}" ]; then macaddr="${9}" - elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then + elif [ -n "${9}" ] && [ -n "${10}" ] && [ -n "${11}" ] && [ -n "${12}" ] && [ -n "${13}" ] && [ -n "${14}" ]; then macaddr="${9}:${10}:${11}:${12}:${13}:${14}" fi ;; diff --git a/modules.d/50plymouth/plymouth-pretrigger.sh b/modules.d/50plymouth/plymouth-pretrigger.sh index 3d11999..a04c791 100755 --- a/modules.d/50plymouth/plymouth-pretrigger.sh +++ b/modules.d/50plymouth/plymouth-pretrigger.sh @@ -18,10 +18,10 @@ if type plymouthd > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then mkdir -m 0755 /run/plymouth read -r consoledev rest < /sys/class/tty/console/active consoledev=${consoledev:-tty0} - [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" + [ -x /lib/udev/console_init ] && [ -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" plymouthd --attach-to-session --pid-file /run/plymouth/pid plymouth --show-splash 2>&1 | vinfo # reset tty after plymouth messed with it - [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" + [ -x /lib/udev/console_init ] && [ -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" fi fi diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index 5e5b926..8050f2b 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -158,7 +158,7 @@ processcmsfile() { [[ $CMSCONFFILE ]] || CMSCONFFILE=$(getarg "CMSCONFFILE=") # Parse configuration -if [ -n "$CMSDASD" -a -n "$CMSCONFFILE" ]; then +if [ -n "$CMSDASD" ] && [ -n "$CMSCONFFILE" ]; then if readcmsfile "$CMSDASD" "$CMSCONFFILE"; then ln -s /run/initramfs/"$CMSCONFFILE" /tmp/"$CMSCONFFILE" ln -s /run/initramfs/"$CMSCONFFILE" /tmp/cms.conf diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 5b33cd1..920f0a0 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 require_binaries chzdev lszdev || return 1 return 255 } @@ -11,7 +11,7 @@ check() { # called by dracut depends() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 echo znet bash return 0 } diff --git a/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh b/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh index 10f4a4b..4a7ccd0 100755 --- a/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh +++ b/modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh @@ -9,7 +9,7 @@ is_lvm2_thinp_device() { _lvm2_thin_device=$(lvm lvs -S 'lv_layout=sparse && lv_layout=thin' \ --nosuffix --noheadings -o vg_name,lv_name "$_device_path" 2> /dev/null) - [ -n "$_lvm2_thin_device" ] && return $? + [ -n "$_lvm2_thin_device" ] } for LV in $LVS; do diff --git a/modules.d/80test-root/module-setup.sh b/modules.d/80test-root/module-setup.sh index 64d618f..c39111c 100755 --- a/modules.d/80test-root/module-setup.sh +++ b/modules.d/80test-root/module-setup.sh @@ -22,9 +22,9 @@ install() { inst_multiple mkdir ln dd stty mount poweroff umount setsid sync for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do - [ -f ${_terminfodir}/l/linux ] && break + [ -f "${_terminfodir}/l/linux" ] && break done - inst_multiple -o ${_terminfodir}/l/linux + inst_multiple -o "${_terminfodir}/l/linux" inst_binary "${dracutbasedir}/dracut-util" "/usr/bin/dracut-util" ln -s dracut-util "${initdir}/usr/bin/dracut-getarg" diff --git a/modules.d/80test-root/test-init.sh b/modules.d/80test-root/test-init.sh index bd6e485..49116fa 100755 --- a/modules.d/80test-root/test-init.sh +++ b/modules.d/80test-root/test-init.sh @@ -18,9 +18,9 @@ grep -q '^tmpfs /run tmpfs' /proc/self/mounts \ exec > /dev/console 2>&1 -if [ -s /failed ]; then +if [ -s /run/failed ]; then echo "**************************FAILED**************************" - cat /failed + cat /run/failed echo "**************************FAILED**************************" else echo "dracut-root-block-success" | dd oflag=direct,dsync status=none of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker @@ -29,8 +29,6 @@ fi export TERM=linux export PS1='initramfs-test:\w\$ ' -[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab -[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab stty sane echo "made it to the rootfs!" @@ -38,12 +36,10 @@ echo "made it to the rootfs!" if getargbool 0 rd.shell; then strstr "$(setsid --help)" "control" && CTTY="-c" - # shellcheck disable=SC2086 - setsid $CTTY sh -i + setsid ${CTTY:+"${CTTY}"} sh -i fi echo "Powering down." -mount -n -o remount,ro / if [ -d /run/initramfs/etc ]; then echo " rd.debug=0 " >> /run/initramfs/etc/cmdline fi diff --git a/modules.d/81cio_ignore/module-setup.sh b/modules.d/81cio_ignore/module-setup.sh index a54fcb9..6c618fb 100755 --- a/modules.d/81cio_ignore/module-setup.sh +++ b/modules.d/81cio_ignore/module-setup.sh @@ -6,7 +6,7 @@ check() { # do not add this module by default local arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 return 0 } @@ -15,7 +15,7 @@ cmdline() { if [ -e /boot/zipl/active_devices.txt ]; then while read -r dev _; do - [ "$dev" = "#" -o "$dev" = "" ] && continue + [ "$dev" = "#" ] || [ "$dev" = "" ] && continue if [ -z "$cio_accept" ]; then cio_accept="$dev" else diff --git a/modules.d/90crypt/crypt-lib.sh b/modules.d/90crypt/crypt-lib.sh index f3ba20d..7669828 100755 --- a/modules.d/90crypt/crypt-lib.sh +++ b/modules.d/90crypt/crypt-lib.sh @@ -148,7 +148,7 @@ test_dev() { local mount_point mount_point=$(mkuniqdir /mnt testdev) - [ -n "$dev" -a -n "$*" ] || return 1 + [ -n "$dev" ] && [ -n "$*" ] || return 1 [ -d "$mount_point" ] || die 'Mount point does not exist!' if mount -r "$dev" "$mount_point" > /dev/null 2>&1; then @@ -175,7 +175,7 @@ test_dev() { # match_dev UUID=123 /dev/dm-1 # Returns true if /dev/dm-1 UUID starts with "123". match_dev() { - [ -z "$1" -o "$1" = '*' ] && return 0 + [ -z "$1" ] || [ "$1" = '*' ] && return 0 local devlist local dev @@ -206,7 +206,7 @@ getkey() { local key_dev local key_path - [ -z "$keys_file" -o -z "$for_dev" ] && die 'getkey: wrong usage!' + [ -z "$keys_file" ] || [ -z "$for_dev" ] && die 'getkey: wrong usage!' [ -f "$keys_file" ] || return 1 while IFS=: read -r luks_dev key_dev key_path _ || [ -n "$luks_dev" ]; do diff --git a/modules.d/90crypt/cryptroot-ask.sh b/modules.d/90crypt/cryptroot-ask.sh index b1f8df8..901c9a3 100755 --- a/modules.d/90crypt/cryptroot-ask.sh +++ b/modules.d/90crypt/cryptroot-ask.sh @@ -30,7 +30,7 @@ numtries=${4:-10} if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; then while read -r name dev luksfile luksoptions || [ -n "$name" ]; do # ignore blank lines and comments - if [ -z "$name" -o "${name#\#}" != "$name" ]; then + if [ -z "$name" ] || [ "${name#\#}" != "$name" ]; then continue fi @@ -137,7 +137,7 @@ unset allowdiscards # fallback to passphrase ask_passphrase=1 -if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then +if [ -n "$luksfile" ] && [ "$luksfile" != "none" ] && [ -e "$luksfile" ]; then # shellcheck disable=SC2086 if readkey "$luksfile" / "$device" \ | cryptsetup -d - $cryptsetupopts luksOpen "$device" "$luksname"; then @@ -176,7 +176,7 @@ fi if [ $ask_passphrase -ne 0 ]; then luks_open="$(command -v cryptsetup) $cryptsetupopts luksOpen" - _timeout=$(getargs "rd.luks.timeout") + _timeout=$(getarg "rd.luks.timeout") _timeout=${_timeout:-0} ask_for_password --ply-tries 5 \ --ply-cmd "$luks_open -T1 $device $luksname" \ @@ -187,7 +187,7 @@ if [ $ask_passphrase -ne 0 ]; then unset _timeout fi -if [ "$is_keysource" -ne 0 -a "${luksname##luks-}" != "$luksname" ]; then +if [ "$is_keysource" -ne 0 ] && [ "${luksname##luks-}" != "$luksname" ]; then luks_close="$(command -v cryptsetup) close" { printf -- '[ -e /dev/mapper/%s ] && ' "$luksname" diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh index 8d24825..cc74077 100755 --- a/modules.d/90crypt/module-setup.sh +++ b/modules.d/90crypt/module-setup.sh @@ -118,7 +118,7 @@ install() { forceentry="" while [ $# -gt 0 ]; do case $1 in - force) + force | x-initrd.attach) forceentry="yes" break ;; diff --git a/modules.d/90crypt/parse-crypt.sh b/modules.d/90crypt/parse-crypt.sh index 39fc6d2..9567a4a 100755 --- a/modules.d/90crypt/parse-crypt.sh +++ b/modules.d/90crypt/parse-crypt.sh @@ -174,7 +174,7 @@ else } >> "$hookdir/emergency/90-crypt.sh" fi done - elif getargbool 1 rd.auto; then + elif getargbool 1 rd.auto && [ -z "$(getargs rd.luks.name)" ]; then if [ -z "$DRACUT_SYSTEMD" ]; then { printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' "$(command -v initqueue)" diff --git a/modules.d/90crypt/probe-keydev.sh b/modules.d/90crypt/probe-keydev.sh index e5a3f36..bb86b8f 100755 --- a/modules.d/90crypt/probe-keydev.sh +++ b/modules.d/90crypt/probe-keydev.sh @@ -6,7 +6,7 @@ real_keydev="$1" keypath="$2" luksdev="$3" -[ -z "$real_keydev" -o -z "$keypath" ] && die 'probe-keydev: wrong usage!' +[ -z "$real_keydev" ] || [ -z "$keypath" ] && die 'probe-keydev: wrong usage!' [ -z "$luksdev" ] && luksdev='*' info "Probing $real_keydev for $keypath..." diff --git a/modules.d/90dmraid/dmraid.sh b/modules.d/90dmraid/dmraid.sh index b517320..c12d92e 100755 --- a/modules.d/90dmraid/dmraid.sh +++ b/modules.d/90dmraid/dmraid.sh @@ -15,7 +15,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then info "Scanning for dmraid devices $DM_RAIDS" SETS=$(dmraid -c -s) - if [ "$SETS" = "no raid disks" -o "$SETS" = "no raid sets" ]; then + if [ "$SETS" = "no raid disks" ] || [ "$SETS" = "no raid sets" ]; then return fi diff --git a/modules.d/90dmsquash-live-autooverlay/create-overlay.sh b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh index 10e8ea5..05a8c35 100755 --- a/modules.d/90dmsquash-live-autooverlay/create-overlay.sh +++ b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh @@ -14,14 +14,12 @@ gatherData() { info "Skipping overlay creation: kernel command line parameter 'rd.live.overlay' is not set" exit 0 fi - # shellcheck disable=SC2086 - if ! str_starts ${overlay} LABEL=; then + if ! str_starts "${overlay}" LABEL=; then die "Overlay creation failed: the partition must be set by LABEL in the 'rd.live.overlay' kernel parameter" fi overlayLabel=${overlay#LABEL=} - # shellcheck disable=SC2086 - if [ -b /dev/disk/by-label/${overlayLabel} ]; then + if [ -b "/dev/disk/by-label/${overlayLabel}" ]; then info "Skipping overlay creation: overlay already exists" exit 0 fi @@ -41,32 +39,24 @@ gatherData() { # The kernel command line's 'root=' parameter was parsed into the $root variable by the dmsquash-live module. # $root contains the path to a symlink within /dev/disk/by-label, which points to a partition. # This script needs that partition's parent block device. - # shellcheck disable=SC2046 - # shellcheck disable=SC2086 - rootDeviceAbsolutePath=$(readlink -f ${rootDevice}) - rootDeviceSysfsPath=/sys/class/block/${rootDeviceAbsolutePath##*/} + rootDeviceAbsolutePath=$(readlink -f "${rootDevice}") + rootDeviceSysfsPath="/sys/class/block/${rootDeviceAbsolutePath##*/}" if [ -f "${rootDeviceSysfsPath}/partition" ]; then - # shellcheck disable=SC2086 - read -r partition < ${rootDeviceSysfsPath}/partition + read -r partition < "${rootDeviceSysfsPath}/partition" else partition=0 fi - # shellcheck disable=SC2086 - read -r readonly < ${rootDeviceSysfsPath}/ro - # shellcheck disable=SC2086 + read -r readonly < "${rootDeviceSysfsPath}/ro" if [ "$partition" != "1" ] || [ "$readonly" != "0" ]; then info "Skipping overlay creation: unpartitioned or read-only media detected" exit 0 fi - # shellcheck disable=SC2046 - # shellcheck disable=SC2086 - fullDriveSysfsPath=$(readlink -f ${rootDeviceSysfsPath}/..) - blockDevice=/dev/${fullDriveSysfsPath##*/} + fullDriveSysfsPath=$(readlink -f "${rootDeviceSysfsPath}/..") + blockDevice="/dev/${fullDriveSysfsPath##*/}" currentPartitionCount=$(grep --count -E "${blockDevice#/dev/}[0-9]+" /proc/partitions) - # shellcheck disable=SC2086 - freeSpaceStart=$(parted --script ${blockDevice} unit % print free \ - | awk -v x=${currentPartitionCount} '$1 == x {getline; print $1}') + freeSpaceStart=$(parted --script "${blockDevice}" unit % print free \ + | awk -v "x=${currentPartitionCount}" '$1 == x {getline; print $1}') if [ -z "$freeSpaceStart" ]; then info "Skipping overlay creation: there is no free space after the last partition" exit 0 @@ -87,22 +77,18 @@ gatherData() { } createPartition() { - # shellcheck disable=SC2086 - parted --script --align optimal ${blockDevice} mkpart primary ${partitionStart}% 100% + parted --script --align optimal "${blockDevice}" mkpart primary ${partitionStart}% 100% } createFilesystem() { - # shellcheck disable=SC2086 - mkfs.${filesystem} -L ${overlayLabel} ${overlayPartition} + "mkfs.${filesystem}" -L "${overlayLabel}" "${overlayPartition}" baseDir=/run/initramfs/create-overlayfs mkdir -p ${baseDir} - # shellcheck disable=SC2086 - mount -t ${filesystem} ${overlayPartition} ${baseDir} + mount -t "${filesystem}" "${overlayPartition}" ${baseDir} - mkdir -p ${baseDir}/${live_dir}/ovlwork - # shellcheck disable=SC2086 - mkdir ${baseDir}/${live_dir}/overlay-${label}-${uuid} + mkdir -p "${baseDir}/${live_dir}/ovlwork" + mkdir "${baseDir}/${live_dir}/overlay-${label}-${uuid}" umount ${baseDir} rm -r ${baseDir} diff --git a/modules.d/90dmsquash-live/apply-live-updates.sh b/modules.d/90dmsquash-live/apply-live-updates.sh index a5a5a39..be3b2c2 100755 --- a/modules.d/90dmsquash-live/apply-live-updates.sh +++ b/modules.d/90dmsquash-live/apply-live-updates.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then +if [ -h /dev/root ] && [ -d /run/initramfs/live/updates ] || [ -d /updates ]; then info "Applying updates to live image..." mount -o bind /run "$NEWROOT"/run # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories @@ -16,7 +16,7 @@ if [ -h /dev/root ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then 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 + && [ -f /run/initramfs/squashed.img ] || [ -f /run/initramfs/rootfs.img ]; then umount --detach-loop /run/initramfs/live umount /run/initramfs/isoscan fi diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh index 4518852..e4a3f00 100755 --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh @@ -67,7 +67,7 @@ if [ ! -f "$livedev" ]; then check_dev=$(get_check_dev "$livedev") # CD/DVD media check [ -b "$check_dev" ] && fs=$(det_fs "$check_dev") - if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then + if [ "$fs" = "iso9660" ] || [ "$fs" = "udf" ]; then check="yes" fi getarg rd.live.check -d check || check="" @@ -97,7 +97,6 @@ det_img_fs() { blkid -s TYPE -u noraid -o value "$1" } -load_fstype squashfs CMDLINE=$(getcmdline) for arg in $CMDLINE; do case $arg in @@ -112,14 +111,15 @@ if [ -f "$livedev" ]; then # check filesystem type and handle accordingly fstype=$(det_img_fs "$livedev") case $fstype in - squashfs) SQUASHED=$livedev ;; - auto) die "cannot mount live image (unknown filesystem type)" ;; + squashfs | erofs) SQUASHED=$livedev ;; + auto) die "cannot mount live image (unknown filesystem type $fstype)" ;; *) FSIMG=$livedev ;; esac load_fstype "$fstype" else livedev_fstype=$(det_fs "$livedev") - if [ "$livedev_fstype" = "squashfs" ]; then + load_fstype "$livedev_fstype" + if [ "$livedev_fstype" = "squashfs" ] || [ "$livedev_fstype" = "erofs" ]; then # no mount needed - we've already got the LiveOS image in $livedev SQUASHED=$livedev elif [ "$livedev_fstype" != "ntfs" ]; then @@ -148,7 +148,7 @@ do_live_overlay() { pathspec=${overlay##*:} fi - if [ -z "$pathspec" -o "$pathspec" = "auto" ]; then + if [ -z "$pathspec" ] || [ "$pathspec" = "auto" ]; then pathspec="/${live_dir}/overlay-$l-$u" elif ! str_starts "$pathspec" "/"; then pathspec=/"${pathspec}" @@ -156,7 +156,7 @@ do_live_overlay() { devspec=${overlay%%:*} # need to know where to look for the overlay - if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then + if [ -z "$setup" ] && [ -n "$devspec" ] && [ -n "$pathspec" ] && [ -n "$overlay" ]; then mkdir -m 0755 -p /run/initramfs/overlayfs if ismounted "$devspec"; then devmnt=$(findmnt -e -v -n -o 'TARGET' --source "$devspec") @@ -166,8 +166,8 @@ do_live_overlay() { else mount -n -t auto "$devspec" /run/initramfs/overlayfs || : fi - if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then - OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} /run/initramfs/overlayfs$pathspec) + if [ -f "/run/initramfs/overlayfs$pathspec" ] && [ -w "/run/initramfs/overlayfs$pathspec" ]; then + OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} "/run/initramfs/overlayfs$pathspec") over=$OVERLAY_LOOPDEV umount -l /run/initramfs/overlayfs || : oltype=$(det_img_fs "$OVERLAY_LOOPDEV") @@ -194,10 +194,10 @@ do_live_overlay() { setup="yes" fi fi - elif [ -d /run/initramfs/overlayfs$pathspec ] \ - && [ -d /run/initramfs/overlayfs$pathspec/../ovlwork ]; then - ln -s /run/initramfs/overlayfs$pathspec /run/overlayfs${readonly_overlay:+-r} - ln -s /run/initramfs/overlayfs$pathspec/../ovlwork /run/ovlwork${readonly_overlay:+-r} + elif [ -d "/run/initramfs/overlayfs$pathspec" ] \ + && [ -d "/run/initramfs/overlayfs$pathspec/../ovlwork" ]; then + ln -s "/run/initramfs/overlayfs$pathspec" /run/overlayfs${readonly_overlay:+-r} + ln -s "/run/initramfs/overlayfs$pathspec/../ovlwork" /run/ovlwork${readonly_overlay:+-r} if [ -z "$overlayfs" ] && [ -n "$DRACUT_SYSTEMD" ]; then reloadsysrootmountunit=":>/xor_overlayfs;" fi @@ -218,10 +218,10 @@ do_live_overlay() { fi fi - if [ -z "$setup" -o -n "$readonly_overlay" ]; then + if [ -z "$setup" ] || [ -n "$readonly_overlay" ]; then if [ -n "$setup" ]; then warn "Using temporary overlay." - elif [ -n "$devspec" -a -n "$pathspec" ]; then + elif [ -n "$devspec" ] && [ -n "$pathspec" ]; then [ -z "$m" ] \ && m=' Unable to find a persistent overlay; using a temporary one.' m="$m"' @@ -265,7 +265,7 @@ do_live_overlay() { fi else dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((overlay_size * 1024)) 2> /dev/null - if [ -n "$setup" -a -n "$readonly_overlay" ]; then + if [ -n "$setup" ] && [ -n "$readonly_overlay" ]; then RO_OVERLAY_LOOPDEV=$(losetup -f --show /overlay) over=$RO_OVERLAY_LOOPDEV else @@ -319,24 +319,24 @@ do_live_overlay() { # end do_live_overlay() # we might have an embedded fs image on squashfs (compressed live) -if [ -e /run/initramfs/live/${live_dir}/${squash_image} ]; then +if [ -e "/run/initramfs/live/${live_dir}/${squash_image}" ]; then SQUASHED="/run/initramfs/live/${live_dir}/${squash_image}" fi if [ -e "$SQUASHED" ]; then if [ -n "$live_ram" ]; then - imgsize=$(($(stat -c %s -- $SQUASHED) / (1024 * 1024))) + imgsize=$(($(stat -c %s -- "$SQUASHED") / (1024 * 1024))) check_live_ram $imgsize echo 'Copying live image to RAM...' > /dev/kmsg echo ' (this may take a minute)' > /dev/kmsg - dd if=$SQUASHED of=/run/initramfs/squashed.img bs=512 2> /dev/null + dd "if=$SQUASHED" of=/run/initramfs/squashed.img bs=512 2> /dev/null echo 'Done copying live image to RAM.' > /dev/kmsg SQUASHED="/run/initramfs/squashed.img" fi SQUASHED_LOOPDEV=$(losetup -f) - losetup -r "$SQUASHED_LOOPDEV" $SQUASHED + losetup -r "$SQUASHED_LOOPDEV" "$SQUASHED" mkdir -m 0755 -p /run/initramfs/squashfs - mount -n -t squashfs -o ro "$SQUASHED_LOOPDEV" /run/initramfs/squashfs + mount -n -o ro "$SQUASHED_LOOPDEV" /run/initramfs/squashfs if [ -d /run/initramfs/squashfs/LiveOS ]; then if [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then @@ -356,15 +356,15 @@ if [ -e "$SQUASHED" ]; then fi else # we might have an embedded fs image to use as rootfs (uncompressed live) - if [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then + if [ -e "/run/initramfs/live/${live_dir}/rootfs.img" ]; then FSIMG="/run/initramfs/live/${live_dir}/rootfs.img" - elif [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then + elif [ -e "/run/initramfs/live/${live_dir}/ext3fs.img" ]; then FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img" fi if [ -n "$live_ram" ]; then echo 'Copying live image to RAM...' > /dev/kmsg echo ' (this may take a minute or so)' > /dev/kmsg - dd if=$FSIMG of=/run/initramfs/rootfs.img bs=512 2> /dev/null + dd "if=$FSIMG" of=/run/initramfs/rootfs.img bs=512 2> /dev/null echo 'Done copying live image to RAM.' > /dev/kmsg FSIMG='/run/initramfs/rootfs.img' fi @@ -376,17 +376,17 @@ if [ -n "$FSIMG" ]; then echo "Unpacking live filesystem (may take some time)" > /dev/kmsg mkdir -m 0755 -p /run/initramfs/fsimg/ if [ -n "$SQUASHED" ]; then - cp -v $FSIMG /run/initramfs/fsimg/rootfs.img + cp -v "$FSIMG" /run/initramfs/fsimg/rootfs.img else - unpack_archive $FSIMG /run/initramfs/fsimg/ + unpack_archive "$FSIMG" /run/initramfs/fsimg/ fi FSIMG=/run/initramfs/fsimg/rootfs.img fi # For writable DM images... readonly_base=1 - if [ -z "$SQUASHED" -a -n "$live_ram" -a -z "$overlayfs" ] \ + if [ -z "$SQUASHED" ] && [ -n "$live_ram" ] && [ -z "$overlayfs" ] \ || [ -n "$writable_fsimg" ] \ - || [ "$overlay" = none -o "$overlay" = None -o "$overlay" = NONE ]; then + || [ "$overlay" = none ] || [ "$overlay" = None ] || [ "$overlay" = NONE ]; then if [ -z "$readonly_overlay" ]; then unset readonly_base setup=rw @@ -397,7 +397,7 @@ if [ -n "$FSIMG" ]; then if [ "$FSIMG" = "$SQUASHED" ]; then BASE_LOOPDEV=$SQUASHED_LOOPDEV else - BASE_LOOPDEV=$(losetup -f --show ${readonly_base:+-r} $FSIMG) + BASE_LOOPDEV=$(losetup -f --show ${readonly_base:+-r} "$FSIMG") sz=$(blockdev --getsz "$BASE_LOOPDEV") fi if [ "$setup" = rw ]; then @@ -422,7 +422,7 @@ fi if [ -n "$overlayfs" ]; then if [ -n "$FSIMG" ]; then mkdir -m 0755 -p /run/rootfsbase - mount -r $FSIMG /run/rootfsbase + mount -r "$FSIMG" /run/rootfsbase else ln -sf /run/initramfs/live /run/rootfsbase fi diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh index b905e3d..99d2114 100755 --- a/modules.d/90dmsquash-live/module-setup.sh +++ b/modules.d/90dmsquash-live/module-setup.sh @@ -17,7 +17,7 @@ depends() { # called by dracut installkernel() { - instmods squashfs loop iso9660 + instmods squashfs loop iso9660 erofs } # called by dracut diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh index ec60f39..f159f0b 100755 --- a/modules.d/90kernel-modules/module-setup.sh +++ b/modules.d/90kernel-modules/module-setup.sh @@ -2,9 +2,10 @@ # called by dracut installkernel() { - local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma|blk_mq_alloc_disk|blk_mq_alloc_request|blk_mq_destroy_queue|blk_cleanup_disk' + local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma|blk_alloc_disk|blk_mq_alloc_disk|blk_mq_alloc_request|blk_mq_destroy_queue|blk_cleanup_disk' local -A _hostonly_drvs + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves record_block_dev_drv() { for _mod in $(get_dev_module /dev/block/"$1"); do @@ -80,6 +81,7 @@ installkernel() { "=drivers/mmc/host" \ "=drivers/nvmem" \ "=drivers/phy" \ + "=drivers/platform/chrome" \ "=drivers/power" \ "=drivers/regulator" \ "=drivers/reset" \ diff --git a/modules.d/90livenet/livenetroot.sh b/modules.d/90livenet/livenetroot.sh index 34f91ff..eccaaed 100755 --- a/modules.d/90livenet/livenetroot.sh +++ b/modules.d/90livenet/livenetroot.sh @@ -47,7 +47,7 @@ while [ "$i" -le "$RETRIES" ]; do imgfile= fi - if [ -n "$imgfile" -a -s "$imgfile" ]; then + if [ -n "$imgfile" ] && [ -s "$imgfile" ]; then break else if [ $i -ge "$RETRIES" ]; then diff --git a/modules.d/90mdraid/59-persistent-storage-md.rules b/modules.d/90mdraid/59-persistent-storage-md.rules index 0d745cc..9e29135 100644 --- a/modules.d/90mdraid/59-persistent-storage-md.rules +++ b/modules.d/90mdraid/59-persistent-storage-md.rules @@ -16,7 +16,7 @@ ATTR{md/array_state}=="|clear|inactive", GOTO="md_end" LABEL="md_ignore_state" -IMPORT{program}="/sbin/mdadm --detail --export $tempnode" +IMPORT{program}="/sbin/mdadm --detail --export $devnode" IMPORT{builtin}="blkid" OPTIONS+="link_priority=100" OPTIONS+="watch" diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh index d8c5de2..2645f1c 100755 --- a/modules.d/90mdraid/mdraid_start.sh +++ b/modules.d/90mdraid/mdraid_start.sh @@ -32,11 +32,14 @@ _md_force_run() { local _md local _UUID local _MD_UUID + local _LEFT_UUID + local _uuid _MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=) [ -n "$_MD_UUID" ] || getargbool 0 rd.auto || return if [ -n "$_MD_UUID" ]; then + _LEFT_UUID=$(str_replace "$_MD_UUID" "-" ":") _MD_UUID=$(str_replace "$_MD_UUID" "-" "") _MD_UUID=$(str_replace "$_MD_UUID" ":" "") @@ -51,6 +54,9 @@ _md_force_run() { ) [ -z "$_UUID" ] && continue + # remove the UUID already assembled from the list + _LEFT_UUID=$(str_replace "$_LEFT_UUID" "$_UUID" "") + _UUID=$(str_replace "$_UUID" ":" "") # check if we should handle this device @@ -65,6 +71,14 @@ _md_force_run() { _md_start "${_md}" done fi + + # try to assemble all the left md devices that should be assembled + # probably failed because of timing issue in the first beginning + if [ -n "$_LEFT_UUID" ]; then + for _uuid in ${_LEFT_UUID}; do + mdadm --assemble --scan --uuid="$_uuid" + done + fi } _md_force_run diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh index 4d3a6b2..adc8aa6 100755 --- a/modules.d/90mdraid/parse-md.sh +++ b/modules.d/90mdraid/parse-md.sh @@ -21,7 +21,7 @@ else 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 # shellcheck disable=SC2016 - printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n' + printf 'IMPORT{program}="/sbin/mdadm --examine --export $devnode"\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 diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh index 782a880..0a1fd55 100755 --- a/modules.d/90multipath/module-setup.sh +++ b/modules.d/90multipath/module-setup.sh @@ -21,14 +21,23 @@ majmin_to_mpath_dev() { # called by dracut check() { - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves is_mpath || return 255 - } + local _any_mpath_dev # if there's no multipath binary, no go. require_binaries multipath || return 1 require_binaries kpartx || return 1 + for_each_host_dev_and_slaves is_mpath + _any_mpath_dev=$? + + [[ $hostonly ]] || [[ $mount_needs ]] && { + [[ $_any_mpath_dev == 0 ]] || return 255 + } + + if [[ $_any_mpath_dev != 0 ]] && [[ ! -f /etc/multipath.conf ]]; then + return 255 + fi + return 0 } @@ -53,7 +62,7 @@ installkernel() { local _arch=${DRACUT_ARCH:-$(uname -m)} local _funcs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target' - if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then + if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then _s390drivers="=drivers/s390/scsi" fi @@ -69,6 +78,7 @@ install() { local -A _allow local config_dir + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves add_hostonly_mpath_conf() { if is_mpath "$1"; then local _dev diff --git a/modules.d/90qemu/module-setup.sh b/modules.d/90qemu/module-setup.sh index d11f377..9e8c3a5 100755 --- a/modules.d/90qemu/module-setup.sh +++ b/modules.d/90qemu/module-setup.sh @@ -15,7 +15,7 @@ installkernel() { # qemu specific modules hostonly='' instmods \ ata_piix ata_generic pata_acpi cdrom sr_mod ahci \ - virtio_blk virtio virtio_ring virtio_pci \ + virtio_blk virtio virtio_crypto virtio_ring virtio_pci \ virtio_scsi virtio_console virtio_rng virtio_mem \ spapr-vscsi \ qemu_fw_cfg \ diff --git a/modules.d/91tpm2-tss/module-setup.sh b/modules.d/91tpm2-tss/module-setup.sh index 4106e3e..4441f55 100755 --- a/modules.d/91tpm2-tss/module-setup.sh +++ b/modules.d/91tpm2-tss/module-setup.sh @@ -30,9 +30,9 @@ installkernel() { # Install the required file(s) and directories for the module in the initramfs. install() { + inst_sysusers tpm2-tss.conf inst_multiple -o \ - "$sysusers"/tpm2-tss.conf \ "$tmpfilesdir"/tpm2-tss-fapi.conf \ "$udevrulesdir"/60-tpm-udev.rules \ "$systemdutildir"/system-generators/systemd-tpm2-generator \ diff --git a/modules.d/91zipl/install_zipl_cmdline.sh b/modules.d/91zipl/install_zipl_cmdline.sh index 9332d31..3a51332 100755 --- a/modules.d/91zipl/install_zipl_cmdline.sh +++ b/modules.d/91zipl/install_zipl_cmdline.sh @@ -23,7 +23,7 @@ fi if [ -f ${MNT}/active_devices.txt ]; then while read -r dev _ || [[ $dev ]]; do - [ "$dev" = "#" -o "$dev" = "" ] && continue + [ "$dev" = "#" ] || [ "$dev" = "" ] && continue cio_ignore -r "$dev" done < ${MNT}/active_devices.txt fi diff --git a/modules.d/91zipl/module-setup.sh b/modules.d/91zipl/module-setup.sh index cb21454..16e5c96 100755 --- a/modules.d/91zipl/module-setup.sh +++ b/modules.d/91zipl/module-setup.sh @@ -12,7 +12,7 @@ get_boot_zipl_dev() { check() { local _arch=${DRACUT_ARCH:-$(uname -m)} # Only for systems on s390 using indirect booting via userland grub - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 # /boot/zipl contains a first stage kernel used to launch grub in initrd [ -d /boot/zipl ] || return 1 return 0 @@ -36,7 +36,7 @@ installkernel() { ID_FS_TYPE=ext4 ;; esac - instmods ${ID_FS_TYPE} + instmods "${ID_FS_TYPE}" fi fi } diff --git a/modules.d/91zipl/parse-zipl.sh b/modules.d/91zipl/parse-zipl.sh index d95a1dd..dc0a291 100755 --- a/modules.d/91zipl/parse-zipl.sh +++ b/modules.d/91zipl/parse-zipl.sh @@ -42,7 +42,7 @@ if [ -n "$zipl_arg" ]; then if [ "$zipl_env" ]; then { printf 'ACTION=="add|change", SUBSYSTEM=="block", %s=="%s", ENV{SYSTEMD_READY}!="0", RUN+="/sbin/initqueue --settled --onetime --unique --name install_zipl_cmdline /sbin/install_zipl_cmdline.sh %s"\n' \ - ${zipl_env} "${zipl_val}" "${zipl_arg}" + "${zipl_env}" "${zipl_val}" "${zipl_arg}" echo "[ -f /tmp/install.zipl.cmdline-done ]" > "$hookdir"/initqueue/finished/wait-zipl-conf.sh } >> /etc/udev/rules.d/99zipl-conf.rules cat /etc/udev/rules.d/99zipl-conf.rules diff --git a/modules.d/95cifs/cifs-lib.sh b/modules.d/95cifs/cifs-lib.sh index b996b41..9564534 100755 --- a/modules.d/95cifs/cifs-lib.sh +++ b/modules.d/95cifs/cifs-lib.sh @@ -30,7 +30,7 @@ cifs_to_var() { # shellcheck disable=SC2034 server=${server%/*} - if [ ! "$cifsuser" -o ! "$cifspass" ]; then + if [ ! "$cifsuser" ] || [ ! "$cifspass" ]; then die "For CIFS support you need to specify a cifsuser and cifspass either in the cifsuser and cifspass commandline parameters or in the root= CIFS URL." fi # shellcheck disable=SC2034 diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh index 825f95d..c89d09e 100755 --- a/modules.d/95dasd/module-setup.sh +++ b/modules.d/95dasd/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 require_binaries dasdconf.sh || return 1 return 0 } diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh index 155eaac..8770683 100755 --- a/modules.d/95dasd_mod/module-setup.sh +++ b/modules.d/95dasd_mod/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 return 0 } diff --git a/modules.d/95debug/module-setup.sh b/modules.d/95debug/module-setup.sh index 3124f1a..b21148a 100755 --- a/modules.d/95debug/module-setup.sh +++ b/modules.d/95debug/module-setup.sh @@ -13,10 +13,44 @@ depends() { # called by dracut install() { - inst_multiple -o ls ps grep more cat rm strace free showmount df du lsblk \ - ping netstat rpcinfo vi scp ping6 ssh find chroot \ - tcpdump cp dd less hostname mkdir systemd-analyze \ - fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck + inst_multiple -o \ + cat \ + chroot \ + cp \ + dd \ + df \ + du \ + e2fsck \ + findmnt \ + find \ + free \ + fsck \ + fsck.ext2 \ + fsck.ext3 \ + fsck.ext4 \ + fsck.ext4dev \ + fsck.f2fs \ + fsck.vfat \ + grep \ + hostname \ + less \ + ls \ + lsblk \ + mkdir \ + more \ + netstat \ + ping \ + ping6 \ + ps \ + rm \ + rpcinfo \ + scp \ + showmount \ + ssh \ + strace \ + systemd-analyze \ + tcpdump \ + vi grep '^tcpdump:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd" } diff --git a/modules.d/95fcoe-uefi/module-setup.sh b/modules.d/95fcoe-uefi/module-setup.sh index 9dc1e73..24acf99 100755 --- a/modules.d/95fcoe-uefi/module-setup.sh +++ b/modules.d/95fcoe-uefi/module-setup.sh @@ -2,6 +2,7 @@ # called by dracut check() { + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_fcoe() { block_is_fcoe "$1" || return 1 } diff --git a/modules.d/95fcoe/fcoe-edd.sh b/modules.d/95fcoe/fcoe-edd.sh index 17f8a7c..ece31ba 100755 --- a/modules.d/95fcoe/fcoe-edd.sh +++ b/modules.d/95fcoe/fcoe-edd.sh @@ -34,7 +34,7 @@ for disk in /sys/firmware/edd/int13_*; do fi for nic in "${disk}"/pci_dev/net/*; do [ -d "$nic" ] || continue - if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then + if [ -n "${dev_port}" ] && [ -e "${nic}/dev_port" ]; then if [ "$(cat "${nic}"/dev_port)" -ne "${dev_port}" ]; then continue fi diff --git a/modules.d/95fcoe/fcoe-up.sh b/modules.d/95fcoe/fcoe-up.sh index 0828f03..3c6654c 100755 --- a/modules.d/95fcoe/fcoe-up.sh +++ b/modules.d/95fcoe/fcoe-up.sh @@ -11,7 +11,7 @@ type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh # Huh? Missing arguments ?? -[ -z "$1" -o -z "$2" ] && exit 1 +[ -z "$1" ] || [ -z "$2" ] && exit 1 netif=$1 dcb=$2 diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh index 3de85c2..ecebbda 100755 --- a/modules.d/95fcoe/module-setup.sh +++ b/modules.d/95fcoe/module-setup.sh @@ -2,6 +2,7 @@ # called by dracut check() { + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_fcoe() { block_is_fcoe "$1" || return 1 } diff --git a/modules.d/95fcoe/parse-fcoe.sh b/modules.d/95fcoe/parse-fcoe.sh index a6f284b..dc4ca32 100755 --- a/modules.d/95fcoe/parse-fcoe.sh +++ b/modules.d/95fcoe/parse-fcoe.sh @@ -72,7 +72,7 @@ parse_fcoe_opts() { ;; esac - if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ]; then + if [ "$fcoe_dcb" != "nodcb" ] && [ "$fcoe_dcb" != "dcb" ]; then warn "Invalid FCoE DCB option: $fcoe_dcb" fi @@ -81,7 +81,7 @@ parse_fcoe_opts() { return 0 fi - if [ -z "$fcoe_interface" -a -z "$fcoe_mac" ]; then + if [ -z "$fcoe_interface" ] && [ -z "$fcoe_mac" ]; then warn "fcoe: Neither interface nor MAC specified for fcoe=$fcoe" return 1 fi diff --git a/modules.d/95hwdb/module-setup.sh b/modules.d/95hwdb/module-setup.sh new file mode 100644 index 0000000..19112be --- /dev/null +++ b/modules.d/95hwdb/module-setup.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# This file is part of dracut. +# SPDX-License-Identifier: GPL-2.0-or-later + +# called by dracut +install() { + inst_multiple -o \ + /etc/udev/udev.hwdb \ + "${udevdir}"/hwdb.bin + + # Install the hosts local user configurations if enabled. + if [[ $hostonly ]]; then + inst_multiple -H -o \ + "$udevconfdir"/hwdb.bin + fi +} diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh index b6af7f4..5c65357 100755 --- a/modules.d/95iscsi/iscsiroot.sh +++ b/modules.d/95iscsi/iscsiroot.sh @@ -229,7 +229,7 @@ handle_netroot() { echo "$target" done }) - [ -z "$targets" ] && warn "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && return 1 + [ -z "$targets" ] && warn "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed" && return 1 found= for target in $targets; do diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh index 5eaab4e..d3307b9 100755 --- a/modules.d/95iscsi/module-setup.sh +++ b/modules.d/95iscsi/module-setup.sh @@ -109,11 +109,11 @@ install_iscsiroot() { [ -z "$iscsi_address" ] && return ip_params_for_remote_addr "$iscsi_address" - if [ -n "$iscsi_address" -a -n "$iscsi_targetname" ]; then - if [ -n "$iscsi_port" -a "$iscsi_port" -eq 3260 ]; then + if [ -n "$iscsi_address" ] && [ -n "$iscsi_targetname" ]; then + if [ -n "$iscsi_port" ] && [ "$iscsi_port" -eq 3260 ]; then iscsi_port= fi - if [ -n "$iscsi_lun" -a "$iscsi_lun" -eq 0 ]; then + if [ -n "$iscsi_lun" ] && [ "$iscsi_lun" -eq 0 ]; then iscsi_lun= fi # In IPv6 case rd.iscsi.initatior= must pass address in [] brackets @@ -134,6 +134,7 @@ install_iscsiroot() { install_softiscsi() { [ -d /sys/firmware/ibft ] && return 0 + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_softiscsi() { local _dev=$1 local iscsi_dev @@ -163,7 +164,7 @@ installkernel() { instmods bnx2i qla4xxx cxgb3i cxgb4i be2iscsi qedi hostonly="" instmods iscsi_tcp iscsi_ibft crc32c iscsi_boot_sysfs 8021q - if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then + if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then _s390drivers="=drivers/s390/scsi" fi diff --git a/modules.d/95lunmask/fc_transport_scan_lun.sh b/modules.d/95lunmask/fc_transport_scan_lun.sh index d14d2ca..57b530a 100755 --- a/modules.d/95lunmask/fc_transport_scan_lun.sh +++ b/modules.d/95lunmask/fc_transport_scan_lun.sh @@ -23,4 +23,4 @@ if [ -f /sys"$DEVPATH"/scsi_target_id ]; then read -r TARGET < /sys"$DEVPATH"/scsi_target_id fi [ -z "$TARGET" ] && exit 1 -echo "$CHANNEL" "$TARGET" $LUN > /sys/class/scsi_host/host"$HOST"/scan +echo "$CHANNEL $TARGET $LUN" > /sys/class/scsi_host/host"$HOST"/scan diff --git a/modules.d/95lunmask/module-setup.sh b/modules.d/95lunmask/module-setup.sh index cf6e3d7..f78cb26 100755 --- a/modules.d/95lunmask/module-setup.sh +++ b/modules.d/95lunmask/module-setup.sh @@ -4,6 +4,7 @@ # called by dracut cmdline() { + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves get_lunmask() { local _dev=$1 local _devpath _sdev _lun _rport _end_device _classdev _wwpn _sas_address diff --git a/modules.d/95lunmask/sas_transport_scan_lun.sh b/modules.d/95lunmask/sas_transport_scan_lun.sh index 1d1fc47..2f1cd42 100755 --- a/modules.d/95lunmask/sas_transport_scan_lun.sh +++ b/modules.d/95lunmask/sas_transport_scan_lun.sh @@ -23,4 +23,4 @@ if [ -f /sys"$DEVPATH"/scsi_target_id ]; then read -r TARGET < /sys"$DEVPATH"/scsi_target_id fi [ -z "$TARGET" ] && exit 1 -echo 0 "$TARGET" $LUN > /sys/class/scsi_host/host"$HOST"/scan +echo "0 $TARGET $LUN" > /sys/class/scsi_host/host"$HOST"/scan diff --git a/modules.d/95nbd/nbdroot.sh b/modules.d/95nbd/nbdroot.sh index b1a8030..35e24fa 100755 --- a/modules.d/95nbd/nbdroot.sh +++ b/modules.d/95nbd/nbdroot.sh @@ -60,7 +60,7 @@ while [ -n "$nbdopts" ]; do if [ -z "$f" ]; then break fi - if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then + if [ -z "${f%bs=*}" ] || [ -z "${f%timeout=*}" ]; then preopts="$preopts $f" continue fi @@ -75,7 +75,7 @@ while [ -n "$nbdflags" ]; do if [ -z "$f" ]; then break fi - if [ "$f" = "ro" -o "$f" = "rw" ]; then + if [ "$f" = "ro" ] || [ "$f" = "rw" ]; then nbdrw=$f continue fi @@ -96,7 +96,7 @@ done # If we didn't get a root= on the command line, then we need to # add the udev rules for mounting the nbd0 device -if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then +if [ "$root" = "block:/dev/root" ] || [ "$root" = "dhcp" ]; then printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' > /etc/udev/rules.d/99-nbd-root.rules udevadm control --reload wait_for_dev -n /dev/root diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh index abe1ee5..5cc4289 100755 --- a/modules.d/95nfs/module-setup.sh +++ b/modules.d/95nfs/module-setup.sh @@ -125,7 +125,7 @@ install() { # Rather than copy the passwd file in, just set a user for rpcbind # We'll save the state and restart the daemon from the root anyway - grep -E '^nfsnobody:|^rpc:|^rpcuser:' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd" + grep -E '^(nfsnobody|_rpc|rpc|rpcuser):' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd" grep -E '^nogroup:|^rpc:|^nobody:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group" dracut_need_initqueue diff --git a/modules.d/95nfs/nfs-lib.sh b/modules.d/95nfs/nfs-lib.sh index 7896da9..52fa97b 100755 --- a/modules.d/95nfs/nfs-lib.sh +++ b/modules.d/95nfs/nfs-lib.sh @@ -155,3 +155,16 @@ mount_nfs() { fi mount -t "$nfs" -o"$options" "$server:$path" "$mntdir" } + +get_rpc_user() { + while read -r line; do + user="${line%%:*}" + case $user in + _rpc | rpc | rpcuser | nfsnobody) + echo "$user" + return + ;; + esac + done < /etc/passwd + echo "root" +} diff --git a/modules.d/95nfs/nfs-start-rpc.sh b/modules.d/95nfs/nfs-start-rpc.sh index 52f6a4d..641a58d 100755 --- a/modules.d/95nfs/nfs-start-rpc.sh +++ b/modules.d/95nfs/nfs-start-rpc.sh @@ -8,8 +8,9 @@ if load_fstype sunrpc rpc_pipefs; then # FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why? command -v portmap > /dev/null && [ -z "$(pidof portmap)" ] && portmap if command -v rpcbind > /dev/null && [ -z "$(pidof rpcbind)" ]; then + . /lib/nfs-lib.sh mkdir -p /run/rpcbind - chown rpc:rpc /run/rpcbind + chown "$(get_rpc_user):root" /run/rpcbind rpcbind fi diff --git a/modules.d/95nfs/nfsroot-cleanup.sh b/modules.d/95nfs/nfsroot-cleanup.sh index d99519b..3b164de 100755 --- a/modules.d/95nfs/nfsroot-cleanup.sh +++ b/modules.d/95nfs/nfsroot-cleanup.sh @@ -16,12 +16,12 @@ pid=$(pidof rpcbind) if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then # try to create the destination directory - [ -d "$NEWROOT"/$rpcpipefspath ] \ - || mkdir -m 0755 -p "$NEWROOT"/$rpcpipefspath 2> /dev/null + [ -d "$NEWROOT/$rpcpipefspath" ] \ + || mkdir -m 0755 -p "$NEWROOT/$rpcpipefspath" 2> /dev/null - if [ -d "$NEWROOT"/$rpcpipefspath ]; then + if [ -d "$NEWROOT/$rpcpipefspath" ]; then # mount --move does not seem to work??? - mount --bind /var/lib/nfs/rpc_pipefs "$NEWROOT"/$rpcpipefspath + mount --bind /var/lib/nfs/rpc_pipefs "$NEWROOT/$rpcpipefspath" umount /var/lib/nfs/rpc_pipefs 2> /dev/null else umount /var/lib/nfs/rpc_pipefs 2> /dev/null diff --git a/modules.d/95nfs/parse-nfsroot.sh b/modules.d/95nfs/parse-nfsroot.sh index a07c5f4..00497c2 100755 --- a/modules.d/95nfs/parse-nfsroot.sh +++ b/modules.d/95nfs/parse-nfsroot.sh @@ -126,5 +126,5 @@ echo '[ -e $NEWROOT/proc ]' > "$hookdir"/initqueue/finished/nfsroot.sh # rpc user needs to be able to write to this directory to save the warmstart # file mkdir -p /var/lib/rpcbind -chown rpc:rpc /var/lib/rpcbind +chown "$(get_rpc_user):root" /var/lib/rpcbind chmod 770 /var/lib/rpcbind diff --git a/modules.d/95nvmf/module-setup.sh b/modules.d/95nvmf/module-setup.sh index 6a1e3f5..c2cf0fb 100755 --- a/modules.d/95nvmf/module-setup.sh +++ b/modules.d/95nvmf/module-setup.sh @@ -4,6 +4,7 @@ check() { require_binaries nvme jq || return 1 + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves is_nvmf() { local _dev=$1 local trtype @@ -68,6 +69,7 @@ cmdline() { local _hostnqn local _hostid + # shellcheck disable=SC2317 # called later by for_each_host_dev_and_slaves gen_nvmf_cmdline() { local _dev=$1 local trtype diff --git a/modules.d/95resume/parse-resume.sh b/modules.d/95resume/parse-resume.sh index 75a905d..b5c60a6 100755 --- a/modules.d/95resume/parse-resume.sh +++ b/modules.d/95resume/parse-resume.sh @@ -72,7 +72,7 @@ if ! getarg noresume; then if [ -x /usr/sbin/resume ]; then printf -- '%s' 'SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",' # shellcheck disable=SC2016 - printf -- ' RUN+="/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s $tempnode"\n' "$a_splash" + printf -- ' RUN+="/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s $devnode"\n' "$a_splash" fi printf -- '%s' 'SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="suspend|swsuspend|swsupend",' printf -- '%s\n' ' RUN+="/sbin/initqueue --finished --unique --name 00resume echo %M:%m > /sys/power/resume"' diff --git a/modules.d/95resume/resume.sh b/modules.d/95resume/resume.sh index c808880..a39b064 100755 --- a/modules.d/95resume/resume.sh +++ b/modules.d/95resume/resume.sh @@ -2,7 +2,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin -[ -s /.resume -a -b "$resume" ] && { +[ -s /.resume ] && [ -b "$resume" ] && { # First try user level resume; it offers splash etc case "$splash" in quiet) diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh index 396fb11..943db48 100755 --- a/modules.d/95rootfs-block/module-setup.sh +++ b/modules.d/95rootfs-block/module-setup.sh @@ -40,7 +40,7 @@ cmdline_rootfs() { return fi - if [ -n "$_block" -a -b "$_dev" ]; then + if [ -n "$_block" ] && [ -b "$_dev" ]; then printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$_dev")")" fi _fstype="$(find_mp_fstype /)" diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh index 973069b..5bb6f0f 100755 --- a/modules.d/95rootfs-block/mount-root.sh +++ b/modules.d/95rootfs-block/mount-root.sh @@ -98,7 +98,7 @@ mount_root() { # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab if ! getargbool 0 ro && fsck_able "$rootfs" \ - && [ "$rootfsck" != "0" -a -z "$fastboot" ] \ + && [ "$rootfsck" != "0" ] && [ -z "$fastboot" ] \ && ! strstr "${rflags}" _netdev \ && ! getargbool 0 rd.skipfsck; then umount "$NEWROOT" @@ -121,6 +121,6 @@ mount_root() { fi } -if [ -n "$root" -a -z "${root%%block:*}" ]; then +if [ -n "$root" ] && [ -z "${root%%block:*}" ]; then mount_root fi diff --git a/modules.d/95udev-rules/module-setup.sh b/modules.d/95udev-rules/module-setup.sh index e5b7f97..d82ed5e 100755 --- a/modules.d/95udev-rules/module-setup.sh +++ b/modules.d/95udev-rules/module-setup.sh @@ -29,16 +29,36 @@ install() { 55-scsi-sg3_id.rules \ 58-scsi-sg3_symlink.rules \ 59-scsi-sg3_utils.rules \ + 60-autosuspend.rules \ 60-block.rules \ 60-cdrom_id.rules \ + 60-drm.rules \ + 60-evdev.rules \ + 60-fido-id.rules \ + 60-input-id.rules \ + 60-persistent-alsa.rules \ + 60-persistent-input.rules \ + 60-persistent-storage-tape.rules \ 60-persistent-storage.rules \ + 60-persistent-v4l.rules \ + 60-sensor.rules \ + 60-serial.rules \ 64-btrfs.rules \ + 70-joystick.rules \ + 70-memory.rules \ + 70-mouse.rules \ + 70-touchpad.rules \ 70-uaccess.rules \ 71-seat.rules \ 73-seat-late.rules \ 75-net-description.rules \ - 80-drivers.rules 95-udev-late.rules \ - 80-net-name-slot.rules 80-net-setup-link.rules \ + 75-probe_mtd.rules \ + 78-sound-card.rules \ + 80-drivers.rules \ + 80-net-name-slot.rules \ + 80-net-setup-link.rules \ + 81-net-dhcp.rules \ + 95-udev-late.rules \ "$moddir/59-persistent-storage.rules" \ "$moddir/61-persistent-storage.rules" @@ -61,12 +81,17 @@ install() { "${udevdir}"/ata_id \ "${udevdir}"/cdrom_id \ "${udevdir}"/create_floppy_devices \ + "${udevdir}"/dmi_memory_id \ + "${udevdir}"/fido_id \ "${udevdir}"/fw_unit_symlinks.sh \ "${udevdir}"/hid2hci \ - "${udevdir}"/path_id \ "${udevdir}"/input_id \ + "${udevdir}"/mtd_probe \ + "${udevdir}"/mtp-probe \ + "${udevdir}"/path_id \ "${udevdir}"/scsi_id \ - "${udevdir}"/usb_id + "${udevdir}"/usb_id \ + "${udevdir}"/v4l_id inst_libdir_file "libnss_files*" @@ -74,6 +99,7 @@ install() { if [[ $hostonly ]]; then inst_dir /etc/udev inst_multiple -H -o \ - /etc/udev/udev.conf + /etc/udev/udev.conf \ + "$udevrulesconfdir/*.rules" fi } diff --git a/modules.d/95virtfs/mount-virtfs.sh b/modules.d/95virtfs/mount-virtfs.sh index e52c752..417ace7 100755 --- a/modules.d/95virtfs/mount-virtfs.sh +++ b/modules.d/95virtfs/mount-virtfs.sh @@ -68,7 +68,7 @@ mount_root() { [ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2> /dev/null } -if [ -n "$root" -a -z "${root%%virtfs:*}" ]; then +if [ -n "$root" ] && [ -z "${root%%virtfs:*}" ]; then mount_root fi : diff --git a/modules.d/95virtiofs/mount-virtiofs.sh b/modules.d/95virtiofs/mount-virtiofs.sh index 3d73884..3f499cd 100755 --- a/modules.d/95virtiofs/mount-virtiofs.sh +++ b/modules.d/95virtiofs/mount-virtiofs.sh @@ -2,7 +2,7 @@ type ismounted > /dev/null 2>&1 || . /lib/dracut-lib.sh -if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then +if [ "${fstype}" = "virtiofs" ] || [ "${root%%:*}" = "virtiofs" ]; then if ! load_fstype virtiofs; then die "virtiofs is required but not available." fi diff --git a/modules.d/95virtiofs/parse-virtiofs.sh b/modules.d/95virtiofs/parse-virtiofs.sh index 760e413..192a950 100755 --- a/modules.d/95virtiofs/parse-virtiofs.sh +++ b/modules.d/95virtiofs/parse-virtiofs.sh @@ -3,7 +3,7 @@ # rootfstype=virtiofs root=<tag> # root=virtiofs:<tag> -if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then +if [ "${fstype}" = "virtiofs" ] || [ "${root%%:*}" = "virtiofs" ]; then # shellcheck disable=SC2034 rootok=1 fi diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh index b547f9b..09a6420 100755 --- a/modules.d/95zfcp/module-setup.sh +++ b/modules.d/95zfcp/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 require_binaries zfcp_cio_free sed || return 1 diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh index 95164bb..3b5ed60 100755 --- a/modules.d/95znet/module-setup.sh +++ b/modules.d/95znet/module-setup.sh @@ -3,7 +3,7 @@ # called by dracut check() { arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" ] || [ "$arch" = "s390x" ] || return 1 require_binaries grep sed seq readlink chzdev || return 1 @@ -45,14 +45,12 @@ install() { # shellcheck disable=SC2155 local _nullglob=$(shopt -p nullglob) shopt -u nullglob - # shellcheck disable=SC2086 readarray -t _array < <( - ls -1 $initdir/etc/udev/rules.d/41-*.rules 2> /dev/null + ls -1 "$initdir"/etc/udev/rules.d/41-*.rules 2> /dev/null ) [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" - # shellcheck disable=SC2086 readarray -t _array < <( - ls -1 $initdir/etc/modprobe.d/s390x-*.conf 2> /dev/null + ls -1 "$initdir"/etc/modprobe.d/s390x-*.conf 2> /dev/null ) [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" $_nullglob diff --git a/modules.d/98dracut-systemd/dracut-cmdline-ask.sh b/modules.d/98dracut-systemd/dracut-cmdline-ask.sh index 13c4f20..895cd90 100755 --- a/modules.d/98dracut-systemd/dracut-cmdline-ask.sh +++ b/modules.d/98dracut-systemd/dracut-cmdline-ask.sh @@ -14,6 +14,8 @@ echo echo echo echo "Enter additional kernel command line parameter (end with ctrl-d or .)" +# In POSIX sh, read -p is undefined, but dash supports it +# shellcheck disable=SC3045 while read -r -p "> " ${BASH:+-e} line || [ -n "$line" ]; do [ "$line" = "." ] && break [ -n "$line" ] && printf -- "%s\n" "$line" >> /etc/cmdline.d/99-cmdline-ask.conf diff --git a/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc b/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc index 21ec88c..1e9f88c 100644 --- a/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc +++ b/modules.d/98dracut-systemd/dracut-shutdown.service.8.asc @@ -20,15 +20,20 @@ can be safely unmounted. The following steps are executed during a shutdown: -* systemd switches to the shutdown.target -* systemd starts /lib/systemd/system/shutdown.target.wants/dracut-shutdown.service -* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore which unpacks the initramfs to /run/initramfs -* systemd finishes shutdown.target +* The system starts to shut down +* ``$prefix/lib/systemd/system/sysinit.target.wants/dracut-shutdown.service`` + gets its ``ExecStop`` target triggered. +* ``dracut-shutdown.service`` executes + ``/usr/lib/dracut/dracut-initramfs-restore`` which unpacks the initramfs to + ``/run/initramfs`` * systemd kills all processes * systemd tries to unmount everything and mounts the remaining read-only -* systemd checks, if there is a /run/initramfs/shutdown executable -* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown. The old root is then mounted on /oldroot. /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable. -* shutdown will try to umount every /oldroot mount and calls the various shutdown hooks from the dracut modules +* systemd checks if there is a ``/run/initramfs/shutdown`` executable +* if yes, it does a pivot_root to ``/run/initramfs`` and executes ``./shutdown``. + The old root is then mounted on ``/oldroot``. + ``/usr/lib/dracut/modules.d/99shutdown/shutdown.sh`` is the shutdown executable. +* shutdown will try to unmount every ``/oldroot`` mount and calls the various + shutdown hooks from the dracut modules This ensures, that all devices are disassembled and unmounted cleanly. diff --git a/modules.d/98selinux/selinux-loadpolicy.sh b/modules.d/98selinux/selinux-loadpolicy.sh index 0235b8e..4e00859 100755 --- a/modules.d/98selinux/selinux-loadpolicy.sh +++ b/modules.d/98selinux/selinux-loadpolicy.sh @@ -18,7 +18,7 @@ rd_load_policy() { fi # Attempt to load SELinux Policy - if [ -x "$NEWROOT/usr/sbin/load_policy" -o -x "$NEWROOT/sbin/load_policy" ]; then + if [ -x "$NEWROOT/usr/sbin/load_policy" ] || [ -x "$NEWROOT/sbin/load_policy" ]; then local ret=0 local out info "Loading SELinux policy" @@ -41,7 +41,7 @@ rd_load_policy() { return 0 fi - if [ $ret -eq 0 -o $ret -eq 2 ]; then + if [ $ret -eq 0 ] || [ $ret -eq 2 ]; then # If machine requires a relabel, force to permissive mode [ -e "$NEWROOT"/.autorelabel ] && LANG=C /usr/sbin/setenforce 0 mount --rbind /dev "$NEWROOT/dev" @@ -51,14 +51,14 @@ rd_load_policy() { fi warn "Initial SELinux policy load failed." - if [ $ret -eq 3 -o $permissive -eq 0 ]; then + if [ $ret -eq 3 ] || [ $permissive -eq 0 ]; then warn "Machine in enforcing mode." warn "Not continuing" emergency_shell -n selinux exit 1 fi return 0 - elif [ $permissive -eq 0 -a "$SELINUX" != "disabled" ]; then + elif [ $permissive -eq 0 ] && [ "$SELINUX" != "disabled" ]; then warn "Machine in enforcing mode and cannot execute load_policy." warn "To disable selinux, add selinux=0 to the kernel command line." warn "Not continuing" diff --git a/modules.d/98syslog/rsyslogd-start.sh b/modules.d/98syslog/rsyslogd-start.sh index d404e51..19a7229 100755 --- a/modules.d/98syslog/rsyslogd-start.sh +++ b/modules.d/98syslog/rsyslogd-start.sh @@ -41,7 +41,7 @@ rsyslog_config() { if [ "$type" = "rsyslogd" ]; then template=/etc/templates/rsyslog.conf if [ -n "$server" ]; then - rsyslog_config "$server" "$template" "$filters" > $conf + rsyslog_config "$server" "$template" "$filters" > "$conf" rsyslogd -c3 fi fi diff --git a/modules.d/99base/dracut-dev-lib.sh b/modules.d/99base/dracut-dev-lib.sh index 5779508..6a443a6 100755 --- a/modules.d/99base/dracut-dev-lib.sh +++ b/modules.d/99base/dracut-dev-lib.sh @@ -30,7 +30,7 @@ dev_unit_name() { return $? fi - if [ "$dev" = "/" -o -z "$dev" ]; then + if [ "$dev" = "/" ] || [ -z "$dev" ]; then printf -- "-" return 0 fi diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index e83ee94..cbef2db 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -37,7 +37,7 @@ strstr() { # matches; as it would match anything, it's not an interesting case. strglob() { # shellcheck disable=SC2295 - [ -n "$1" -a -z "${1##$2}" ] + [ -n "$1" ] && [ -z "${1##$2}" ] } # returns OK if $1 contains (anywhere) a match of glob pattern $2 @@ -45,7 +45,7 @@ strglob() { # matches; as it would match anything, it's not an interesting case. strglobin() { # shellcheck disable=SC2295 - [ -n "$1" -a -z "${1##*$2*}" ] + [ -n "$1" ] && [ -z "${1##*$2*}" ] } # returns OK if $1 contains literal string $2 at the beginning, and isn't empty @@ -266,7 +266,7 @@ getargnum() { _b=$(getarg "$1") || _b=${_b:-"$_default"} if [ -n "$_b" ]; then isdigit "$_b" && _b=$((_b)) \ - && [ $_b -ge "$_min" ] && [ $_b -le "$_max" ] && echo $_b && return + && [ "$_b" -ge "$_min" ] && [ "$_b" -le "$_max" ] && echo "$_b" && return fi echo "$_default" } @@ -354,14 +354,14 @@ splitsep() { shift 2 local tmp - while [ -n "$str" -a "$#" -gt 1 ]; do + while [ -n "$str" ] && [ "$#" -gt 1 ]; do tmp="${str%%"$sep"*}" eval "$1='${tmp}'" str="${str#"$tmp"}" str="${str#"$sep"}" shift done - [ -n "$str" -a -n "$1" ] && eval "$1='$str'" + [ -n "$str" ] && [ -n "$1" ] && eval "$1='$str'" debug_on return 0 } @@ -937,15 +937,15 @@ _emergency_shell() { _ctty="$(RD_DEBUG='' getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}" if [ -z "$_ctty" ]; then _ctty=console - while [ -f /sys/class/tty/$_ctty/active ]; do - read -r _ctty < /sys/class/tty/$_ctty/active + while [ -f "/sys/class/tty/$_ctty/active" ]; do + read -r _ctty < "/sys/class/tty/$_ctty/active" _ctty=${_ctty##* } # last one in the list done _ctty=/dev/$_ctty fi [ -c "$_ctty" ] || _ctty=/dev/tty1 case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY="--ctty" ;; esac - setsid $CTTY /bin/sh -i -l 0<> $_ctty 1<> $_ctty 2<> $_ctty + setsid ${CTTY:+"${CTTY}"} /bin/sh -i -l 0<> "$_ctty" 1<> "$_ctty" 2<> "$_ctty" fi } @@ -1002,8 +1002,8 @@ export_n() { local var local val for var in "$@"; do - eval val=\$$var - unset $var + eval "val=\$$var" + unset "$var" [ -n "$val" ] && eval "$var=\"$val\"" done } diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index 727f279..2a095a6 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -109,6 +109,8 @@ source_conf /etc/conf.d if getarg "rd.cmdline=ask"; then echo "Enter additional kernel command line parameter (end with ctrl-d or .)" + # In POSIX sh, read -p is undefined, but dash supports it + # shellcheck disable=SC3045 while read -r -p "> " ${BASH:+-e} line || [ -n "$line" ]; do [ "$line" = "." ] && break echo "$line" >> /etc/cmdline.d/99-cmdline-ask.conf |