fix(base): shellcheck for modules.d/99base

Also remove some functions, which are not used and broken anyway.
master
Harald Hoyer 2021-03-22 10:13:19 +01:00 committed by Harald Hoyer
parent cbef7cf3da
commit 2fabaaa62d
8 changed files with 206 additions and 219 deletions

View File

View File

@ -3,9 +3,10 @@
export DRACUT_SYSTEMD export DRACUT_SYSTEMD
export NEWROOT export NEWROOT
if [ -n "$NEWROOT" ]; then if [ -n "$NEWROOT" ]; then
[ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT [ -d "$NEWROOT" ] || mkdir -p -m 0755 "$NEWROOT"
fi fi


# shellcheck disable=SC2153
if [ -z "$PREFIX" ]; then if [ -z "$PREFIX" ]; then
if ! [ -d /run/initramfs ]; then if ! [ -d /run/initramfs ]; then
mkdir -p -m 0755 /run/initramfs/log mkdir -p -m 0755 /run/initramfs/log
@ -71,8 +72,9 @@ if [ -z "$DRACUT_SYSTEMD" ]; then
info() { info() {
check_quiet check_quiet
echo "<30>dracut: $*" > /dev/kmsg echo "<30>dracut: $*" > /dev/kmsg
[ "$DRACUT_QUIET" != "yes" ] \ if [ "$DRACUT_QUIET" != "yes" ]; then
&& echo "dracut: $*" >&2 || : echo "dracut: $*" >&2
fi
} }


else else
@ -88,14 +90,14 @@ else
fi fi


vwarn() { vwarn() {
while read line || [ -n "$line" ]; do while read -r line || [ -n "$line" ]; do
warn $line warn "$line"
done done
} }


vinfo() { vinfo() {
while read line || [ -n "$line" ]; do while read -r line || [ -n "$line" ]; do
info $line info "$line"
done done
} }


@ -121,7 +123,6 @@ str_replace() {


killall_proc_mountpoint() { killall_proc_mountpoint() {
local _pid local _pid
local _t
local _killed=0 local _killed=0
for _pid in /proc/*; do for _pid in /proc/*; do
_pid=${_pid##/proc/} _pid=${_pid##/proc/}
@ -180,7 +181,11 @@ getarg() {
-y) -y)
if dracut-getarg "$2" > /dev/null; then if dracut-getarg "$2" > /dev/null; then
if [ "$_deprecated" = "1" ]; then if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated." if [ -n "$_newoption" ]; then
warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead."
else
warn "Option '$2' is deprecated."
fi
fi fi
echo 1 echo 1
debug_on debug_on
@ -193,7 +198,11 @@ getarg() {
if dracut-getarg "$2" > /dev/null; then if dracut-getarg "$2" > /dev/null; then
echo 0 echo 0
if [ "$_deprecated" = "1" ]; then if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated." if [ -n "$_newoption" ]; then
warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead."
else
warn "Option '$2' is deprecated."
fi
fi fi
debug_on debug_on
return 1 return 1
@ -207,7 +216,11 @@ getarg() {
fi fi
if dracut-getarg "$1"; then if dracut-getarg "$1"; then
if [ "$_deprecated" = "1" ]; then if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated." if [ -n "$_newoption" ]; then
warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead."
else
warn "Option '$1' is deprecated."
fi
fi fi
debug_on debug_on
return 0 return 0
@ -234,12 +247,11 @@ getargbool() {
local _default local _default
_default="$1" _default="$1"
shift shift
_b=$(getarg "$@") _b=$(getarg "$@") || _b=${_b:-"$_default"}
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then if [ -n "$_b" ]; then
[ $_b = "0" ] && return 1 [ "$_b" = "0" ] && return 1
[ $_b = "no" ] && return 1 [ "$_b" = "no" ] && return 1
[ $_b = "off" ] && return 1 [ "$_b" = "off" ] && return 1
fi fi
return 0 return 0
} }
@ -267,44 +279,44 @@ getargnum() {
shift shift
_max="$1" _max="$1"
shift shift
_b=$(getarg "$1") _b=$(getarg "$1") || _b=${_b:-"$_default"}
[ $? -ne 0 -a -z "$_b" ] && _b=$_default
if [ -n "$_b" ]; then if [ -n "$_b" ]; then
isdigit "$_b" && _b=$((_b)) \ isdigit "$_b" && _b=$((_b)) \
&& [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return && [ $_b -ge "$_min" ] && [ $_b -le "$_max" ] && echo $_b && return
fi fi
echo $_default echo "$_default"
} }


getargs() { getargs() {
debug_off
CMDLINE=$(getcmdline) CMDLINE=$(getcmdline)
export CMDLINE export CMDLINE
debug_off local _val _i _gfound _deprecated
local _val _i _args _gfound _deprecated
unset _val unset _val
unset _gfound unset _gfound
_newoption="$1" _newoption="$1"
_args="$@" for _i in "$@"; do
set --
for _i in $_args; do
if [ "$_i" = "-d" ]; then if [ "$_i" = "-d" ]; then
_deprecated=1 _deprecated=1
continue continue
fi fi
_val="$(dracut-getargs "$_i")"
if [ $? -eq 0 ]; then if _val="$(dracut-getargs "$_i")"; then
if [ "$_deprecated" = "1" ]; then if [ "$_deprecated" = "1" ]; then
[ -n "$_newoption" ] && warn "Option '$_i' is deprecated, use '$_newoption' instead." || warn "Option $_i is deprecated!" if [ -n "$_newoption" ]; then
warn "Option '$_i' is deprecated, use '$_newoption' instead."
else
warn "Option $_i is deprecated!"
fi
fi
if [ -n "$_val" ]; then
printf '%s\n' "$_val"
fi fi
_gfound=1 _gfound=1
fi fi
[ -n "$_val" ] && set -- "$@" "$_val"
_deprecated=0 _deprecated=0
done done
if [ -n "$_gfound" ]; then if [ -n "$_gfound" ]; then
if [ $# -gt 0 ]; then
printf '%s' "$*"
fi
debug_on debug_on
return 0 return 0
fi fi
@ -394,7 +406,19 @@ source_all() {
_dir=$1 _dir=$1
shift shift
[ "$_dir" ] && [ -d "/$_dir" ] || return [ "$_dir" ] && [ -d "/$_dir" ] || return
for f in "/$_dir"/*.sh; do [ -e "$f" ] && . "$f" "$@"; done for f in "/$_dir"/*.sh; do
if [ -e "$f" ]; then
# dash can't source with parameters
if [ -z "$BASH" ] && [ $# -gt 0 ]; then
[ -x "$f" ] || chmod 0755 "$f"
"$f" "$@"
else
# shellcheck disable=SC1090
# shellcheck disable=SC2240
. "$f" "$@"
fi
fi
done
} }


hookdir=/lib/dracut/hooks hookdir=/lib/dracut/hooks
@ -409,8 +433,9 @@ source_hook() {


check_finished() { check_finished() {
local f local f
for f in $hookdir/initqueue/finished/*.sh; do for f in "$hookdir"/initqueue/finished/*.sh; do
[ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0 [ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0
# shellcheck disable=SC1090
{ [ -e "$f" ] && (. "$f"); } || return 1 { [ -e "$f" ] && (. "$f"); } || return 1
done done
return 0 return 0
@ -419,6 +444,7 @@ check_finished() {
source_conf() { source_conf() {
local f local f
[ "$1" ] && [ -d "/$1" ] || return [ "$1" ] && [ -d "/$1" ] || return
# shellcheck disable=SC1090
for f in "/$1"/*.conf; do [ -e "$f" ] && . "$f"; done for f in "/$1"/*.conf; do [ -e "$f" ] && . "$f"; done
} }


@ -434,7 +460,7 @@ die() {
} >> $hookdir/emergency/01-die.sh } >> $hookdir/emergency/01-die.sh
[ -d /run/initramfs ] || mkdir -p -- /run/initramfs [ -d /run/initramfs ] || mkdir -p -- /run/initramfs


> /run/initramfs/.die : > /run/initramfs/.die


if getargbool 0 "rd.shell"; then if getargbool 0 "rd.shell"; then
emergency_shell emergency_shell
@ -456,7 +482,7 @@ check_quiet() {
getargbool 0 rd.debug -d -y rdinitdebug && DRACUT_QUIET="no" getargbool 0 rd.debug -d -y rdinitdebug && DRACUT_QUIET="no"
getarg quiet || DRACUT_QUIET="yes" getarg quiet || DRACUT_QUIET="yes"
a=$(getarg loglevel=) a=$(getarg loglevel=)
[ -n "$a" ] && [ $a -ge 28 ] && DRACUT_QUIET="yes" [ -n "$a" ] && [ "$a" -ge 28 ] && DRACUT_QUIET="yes"
export DRACUT_QUIET export DRACUT_QUIET
fi fi
} }
@ -474,52 +500,43 @@ check_occurances() {
count=$((count + 1)) count=$((count + 1))
done done


[ $count -eq $expected ] [ $count -eq "$expected" ]
} }


incol2() { incol2() {
debug_off debug_off
local dummy check local check
local file="$1" local file="$1"
local str="$2" local str="$2"


[ -z "$file" ] && return 1 [ -z "$file" ] && return 1
[ -z "$str" ] && return 1 [ -z "$str" ] && return 1


while read dummy check restofline || [ -n "$check" ]; do while read -r _ check _ || [ -n "$check" ]; do
if [ "$check" = "$str" ]; then if [ "$check" = "$str" ]; then
debug_on debug_on
return 0 return 0
fi fi
done < $file done < "$file"
debug_on debug_on
return 1 return 1
} }


udevsettle() { udevsettle() {
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version) # shellcheck disable=SC2086

udevadm settle --exit-if-exists=$hookdir/initqueue/work $settle_exit_if_exists
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=$hookdir/initqueue/work $settle_exit_if_exists
else
udevadm settle --timeout=30
fi
} }


udevproperty() { udevproperty() {
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version) for i in "$@"; do

udevadm control --property="$i"
if [ $UDEVVERSION -ge 143 ]; then done
for i in "$@"; do udevadm control --property=$i; done
else
for i in "$@"; do udevadm control --env=$i; done
fi
} }


find_mount() { find_mount() {
local dev mnt etc wanted_dev local dev wanted_dev
wanted_dev="$(readlink -e -q $1)" wanted_dev="$(readlink -e -q "$1")"
while read dev mnt etc || [ -n "$dev" ]; do while read -r dev _ || [ -n "$dev" ]; do
[ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0 [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0
done < /proc/mounts done < /proc/mounts
return 1 return 1
@ -538,7 +555,7 @@ else
return 1 return 1
fi fi


while read a m a || [ -n "$m" ]; do while read -r _ m _ || [ -n "$m" ]; do
[ "$m" = "$1" ] && return 0 [ "$m" = "$1" ] && return 0
done < /proc/mounts done < /proc/mounts
return 1 return 1
@ -644,10 +661,11 @@ mkuniqdir() {
# copytree SRC DEST # copytree SRC DEST
copytree() { copytree() {
local src="$1" dest="$2" local src="$1" dest="$2"
mkdir -p "$dest" [ -d "$src" ] || return 1
dest=$(readlink -e -q "$dest") mkdir -p "$dest" || return 1
dest=$(readlink -e -q "$dest") || return 1
( (
cd "$src" cd "$src" || exit 1
cp -af . -t "$dest" cp -af . -t "$dest"
) )
} }
@ -671,7 +689,7 @@ copytree() {
# foreach_uuid_until "mount -U \$___ /mnt; echo OK; umount /mnt" \ # foreach_uuid_until "mount -U \$___ /mnt; echo OK; umount /mnt" \
# "01234 f512 a235567f-12a3-c123-a1b1-01234567abcb" # "01234 f512 a235567f-12a3-c123-a1b1-01234567abcb"
foreach_uuid_until() ( foreach_uuid_until() (
cd /dev/disk/by-uuid cd /dev/disk/by-uuid || return 1


[ "$1" = -p ] && local prefix="$2" && shift 2 [ "$1" = -p ] && local prefix="$2" && shift 2
local cmd="$1" local cmd="$1"
@ -684,10 +702,11 @@ foreach_uuid_until() (
[ -n "${cmd}" ] || return 1 [ -n "${cmd}" ] || return 1


for uuid in ${uuids_list:-*}; do for uuid in ${uuids_list:-*}; do
for full_uuid in ${uuid}*; do for full_uuid in "${uuid}"*; do
[ -e "${full_uuid}" ] || continue [ -e "${full_uuid}" ] || continue
# shellcheck disable=SC2034
___="${prefix}${full_uuid}" ___="${prefix}${full_uuid}"
eval ${cmd} && return 0 eval "${cmd}" && return 0
done done
done done


@ -715,6 +734,7 @@ devnames() {


case "$dev" in case "$dev" in
UUID=*) UUID=*)
# shellcheck disable=SC2016
dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \ dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
&& return 255 && return 255
[ -z "$dev" ] && return 255 [ -z "$dev" ] && return 255
@ -781,10 +801,11 @@ inst_hook() {
_exe=$1 _exe=$1
shift shift


[ -x "$_exe" ] || _exe=$(command -v $_exe) [ -x "$_exe" ] || _exe=$(command -v "$_exe")


if [ -n "$onetime" ]; then if [ -n "$onetime" ]; then
{ {
# shellcheck disable=SC2016
echo '[ -e "$_job" ] && rm -f -- "$_job"' echo '[ -e "$_job" ] && rm -f -- "$_job"'
echo "$_exe $*" echo "$_exe $*"
} > "/tmp/$$-${_job}.sh" } > "/tmp/$$-${_job}.sh"
@ -801,41 +822,12 @@ inst_hook() {
# which executes <script> as soon as <mountpoint> is mounted. # which executes <script> as soon as <mountpoint> is mounted.
inst_mount_hook() { inst_mount_hook() {
local _prio="$2" _jobname="$3" _script="$4" local _prio="$2" _jobname="$3" _script="$4"
local _hookname="mount-$(str_replace "$1" '/' '\\x2f')" local _hookname
_hookname="mount-$(str_replace "$1" '/' '\\x2f')"
[ -d "$hookdir/${_hookname}" ] || mkdir -p "$hookdir/${_hookname}" [ -d "$hookdir/${_hookname}" ] || mkdir -p "$hookdir/${_hookname}"
inst_hook --hook "$_hookname" --unique --name "${_prio}-${_jobname}" "$_script" inst_hook --hook "$_hookname" --unique --name "${_prio}-${_jobname}" "$_script"
} }


# add_mount_point <dev> <mountpoint> <filesystem> <fsopts>
#
# Mount <dev> on <mountpoint> with <filesystem> and <fsopts>
# and call any mount hooks, as soon, as it is mounted
add_mount_point() {
local _dev="$1" _mp="$2" _fs="$3" _fsopts="$4"
local _hookname="mount-$(str_replace "$2" '/' '\\x2f')"
local _devname="dev-$(str_replace "$1" '/' '\\x2f')"
echo "$_dev $_mp $_fs $_fsopts 0 0" >> /etc/fstab

exec 7> /etc/udev/rules.d/99-mount-${_devname}.rules
echo 'SUBSYSTEM!="block", GOTO="mount_end"' >&7
echo 'ACTION!="add|change", GOTO="mount_end"' >&7
if [ -n "$_dev" ]; then
udevmatch "$_dev" >&7 || {
warn "add_mount_point dev=$_dev incorrect!"
return 1
}
printf ', ' >&7
fi

{
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
printf -- '--name mount-%%k '
printf -- '%s %s"\n' "$(command -v mount_hook)" "${_mp}"
} >&7
echo 'LABEL="mount_end"' >&7
exec 7>&-
}

# wait_for_mount <mountpoint> # wait_for_mount <mountpoint>
# #
# Installs a initqueue-finished script, # Installs a initqueue-finished script,
@ -844,11 +836,11 @@ add_mount_point() {
wait_for_mount() { wait_for_mount() {
local _name local _name
_name="$(str_replace "$1" '/' '\\x2f')" _name="$(str_replace "$1" '/' '\\x2f')"
printf '. /lib/dracut-lib.sh\nismounted "%s"\n' $1 \ printf '. /lib/dracut-lib.sh\nismounted "%s"\n' "$1" \
>> "$hookdir/initqueue/finished/ismounted-${_name}.sh" >> "$hookdir/initqueue/finished/ismounted-${_name}.sh"
{ {
printf 'ismounted "%s" || ' $1 printf 'ismounted "%s" || ' "$1"
printf 'warn "\"%s\" is not mounted"\n' $1 printf 'warn "\"%s\" is not mounted"\n' "$1"
} >> "$hookdir/emergency/90-${_name}.sh" } >> "$hookdir/emergency/90-${_name}.sh"
} }


@ -869,6 +861,7 @@ dev_unit_name() {


dev="${1%%/}" dev="${1%%/}"
dev="${dev##/}" dev="${dev##/}"
# shellcheck disable=SC1003
dev="$(str_replace "$dev" '\' '\x5c')" dev="$(str_replace "$dev" '\' '\x5c')"
dev="$(str_replace "$dev" '-' '\x2d')" dev="$(str_replace "$dev" '-' '\x2d')"
if [ "${dev##.}" != "$dev" ]; then if [ "${dev##.}" != "$dev" ]; then
@ -898,21 +891,21 @@ set_systemd_timeout_for_dev() {


if [ -n "$DRACUT_SYSTEMD" ]; then if [ -n "$DRACUT_SYSTEMD" ]; then
_name=$(dev_unit_name "$1") _name=$(dev_unit_name "$1")
if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device ]; then if ! [ -L "${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device" ]; then
[ -d ${PREFIX}/etc/systemd/system/initrd.target.wants ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.wants [ -d "${PREFIX}"/etc/systemd/system/initrd.target.wants ] || mkdir -p "${PREFIX}"/etc/systemd/system/initrd.target.wants
ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device ln -s ../"${_name}".device "${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device"
type mark_hostonly > /dev/null 2>&1 && mark_hostonly /etc/systemd/system/initrd.target.wants/${_name}.device type mark_hostonly > /dev/null 2>&1 && mark_hostonly /etc/systemd/system/initrd.target.wants/"${_name}".device
_needreload=1 _needreload=1
fi fi


if ! [ -f ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf ]; then if ! [ -f "${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf" ]; then
mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d mkdir -p "${PREFIX}/etc/systemd/system/${_name}.device.d"
{ {
echo "[Unit]" echo "[Unit]"
echo "JobTimeoutSec=$_timeout" echo "JobTimeoutSec=$_timeout"
echo "JobRunningTimeoutSec=$_timeout" echo "JobRunningTimeoutSec=$_timeout"
} > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf } > "${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf"
type mark_hostonly > /dev/null 2>&1 && mark_hostonly /etc/systemd/system/${_name}.device.d/timeout.conf type mark_hostonly > /dev/null 2>&1 && mark_hostonly /etc/systemd/system/"${_name}".device.d/timeout.conf
_needreload=1 _needreload=1
fi fi


@ -948,7 +941,7 @@ wait_for_dev() {
printf 'warn "\"%s\" does not exist"\n' "$1" printf 'warn "\"%s\" does not exist"\n' "$1"
} >> "${PREFIX}$hookdir/emergency/80-${_name}.sh" } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh"


set_systemd_timeout_for_dev $_noreload $1 set_systemd_timeout_for_dev $_noreload "$1"
} }


cancel_wait_for_dev() { cancel_wait_for_dev() {
@ -958,29 +951,30 @@ cancel_wait_for_dev() {
rm -f -- "$hookdir/emergency/80-${_name}.sh" rm -f -- "$hookdir/emergency/80-${_name}.sh"
if [ -n "$DRACUT_SYSTEMD" ]; then if [ -n "$DRACUT_SYSTEMD" ]; then
_name=$(dev_unit_name "$1") _name=$(dev_unit_name "$1")
rm -f -- ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device rm -f -- "${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device"
rm -f -- ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf rm -f -- "${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf"
/sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload
fi fi
} }


killproc() { killproc() {
debug_off debug_off
local _exe="$(command -v $1)" local _exe
_exe="$(command -v "$1")"
local _sig=$2 local _sig=$2
local _i local _i
[ -x "$_exe" ] || return 1 [ -x "$_exe" ] || return 1
for _i in /proc/[0-9]*; do for _i in /proc/[0-9]*; do
[ "$_i" = "/proc/1" ] && continue [ "$_i" = "/proc/1" ] && continue
if [ -e "$_i"/_exe ] && [ "$_i/_exe" -ef "$_exe" ]; then if [ -e "$_i"/_exe ] && [ "$_i/_exe" -ef "$_exe" ]; then
kill $_sig ${_i##*/} kill "$_sig" "${_i##*/}"
fi fi
done done
debug_on debug_on
} }


need_shutdown() { need_shutdown() {
> /run/initramfs/.need_shutdown : > /run/initramfs/.need_shutdown
} }


wait_for_loginit() { wait_for_loginit() {
@ -1003,7 +997,7 @@ wait_for_loginit() {


if [ $i -eq 10 ]; then if [ $i -eq 10 ]; then
kill %1 > /dev/null 2>&1 kill %1 > /dev/null 2>&1
kill $(while read line || [ -n "$line" ]; do echo $line; done < /run/initramfs/loginit.pid) kill "$(while read -r line || [ -n "$line" ]; do echo "$line"; done < /run/initramfs/loginit.pid)"
fi fi


setdebug setdebug
@ -1034,7 +1028,7 @@ if ! command -v pidof > /dev/null 2> /dev/null; then
[ "${_rl%/$_cmd}" != "$_rl" ] || continue [ "${_rl%/$_cmd}" != "$_rl" ] || continue
fi fi
i=${i%/exe} i=${i%/exe}
echo ${i##/proc/} echo "${i##/proc/}"
_ret=0 _ret=0
done done
debug_on debug_on
@ -1045,7 +1039,7 @@ fi
_emergency_shell() { _emergency_shell() {
local _name="$1" local _name="$1"
if [ -n "$DRACUT_SYSTEMD" ]; then if [ -n "$DRACUT_SYSTEMD" ]; then
> /.console_lock : > /.console_lock
echo "PS1=\"$_name:\\\${PWD}# \"" > /etc/profile echo "PS1=\"$_name:\\\${PWD}# \"" > /etc/profile
systemctl start dracut-emergency.service systemctl start dracut-emergency.service
rm -f -- /etc/profile rm -f -- /etc/profile
@ -1057,7 +1051,7 @@ _emergency_shell() {
/sbin/rdsosreport /sbin/rdsosreport
echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot' echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot'
echo 'after mounting them and attach it to a bug report.' echo 'after mounting them and attach it to a bug report.'
if ! RD_DEBUG= getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then if ! RD_DEBUG='' getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
echo echo
echo 'To get more debug information in the report,' echo 'To get more debug information in the report,'
echo 'reboot with "rd.debug" added to the kernel command line.' echo 'reboot with "rd.debug" added to the kernel command line.'
@ -1066,9 +1060,9 @@ _emergency_shell() {
echo 'Dropping to debug shell.' echo 'Dropping to debug shell.'
echo echo
export PS1="$_name:\${PWD}# " export PS1="$_name:\${PWD}# "
[ -e /.profile ] || > /.profile [ -e /.profile ] || : > /.profile


_ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}" _ctty="$(RD_DEBUG='' getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
if [ -z "$_ctty" ]; then if [ -z "$_ctty" ]; then
_ctty=console _ctty=console
while [ -f /sys/class/tty/$_ctty/active ]; do while [ -f /sys/class/tty/$_ctty/active ]; do
@ -1115,7 +1109,7 @@ emergency_shell() {
&& _emergency_action=halt && _emergency_action=halt


if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
_emergency_shell $_rdshell_name _emergency_shell "$_rdshell_name"
else else
source_hook "$hook" source_hook "$hook"
warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line." warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
@ -1143,7 +1137,7 @@ export_n() {
for var in "$@"; do for var in "$@"; do
eval val=\$$var eval val=\$$var
unset $var unset $var
[ -n "$val" ] && eval $var=\"$val\" [ -n "$val" ] && eval "$var=\"$val\""
done done
} }


@ -1186,7 +1180,8 @@ are_lists_eq() {


setmemdebug() { setmemdebug() {
if [ -z "$DEBUG_MEM_LEVEL" ]; then if [ -z "$DEBUG_MEM_LEVEL" ]; then
export DEBUG_MEM_LEVEL=$(getargnum 0 0 5 rd.memdebug) DEBUG_MEM_LEVEL=$(getargnum 0 0 5 rd.memdebug)
export DEBUG_MEM_LEVEL
fi fi
} }


@ -1207,7 +1202,9 @@ make_trace_mem() {
return return
fi fi


msg=$(echo $msg) # FIXME? useless echo?
# shellcheck disable=SC2116
msg=$(echo "$msg")


msg_printed=0 msg_printed=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
@ -1236,7 +1233,7 @@ make_trace_mem() {
echo "$prefix $msg" echo "$prefix $msg"
msg_printed=1 msg_printed=1
fi fi
show_memstats $trace show_memstats "$trace"
fi fi
shift shift
done done
@ -1246,7 +1243,7 @@ make_trace_mem() {
show_memstats() { show_memstats() {
case $1 in case $1 in
shortmem) shortmem)
cat /proc/meminfo | grep -e "^MemFree" -e "^Cached" -e "^Slab" grep -e "^MemFree" -e "^Cached" -e "^Slab" /proc/meminfo
;; ;;
mem) mem)
cat /proc/meminfo cat /proc/meminfo

View File

@ -16,20 +16,18 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PATH export PATH


# mount some important things # mount some important things
[ ! -d /proc/self ] \ if [ ! -d /proc/self ]; then
&& mount -t proc -o nosuid,noexec,nodev proc /proc > /dev/null if ! mount -t proc -o nosuid,noexec,nodev proc /proc > /dev/null; then

echo "Cannot mount proc on /proc! Compile the kernel with CONFIG_PROC_FS!"
if [ "$?" != "0" ]; then exit 1
echo "Cannot mount proc on /proc! Compile the kernel with CONFIG_PROC_FS!" fi
exit 1
fi fi


[ ! -d /sys/kernel ] \ if [ ! -d /sys/kernel ]; then
&& mount -t sysfs -o nosuid,noexec,nodev sysfs /sys > /dev/null if ! mount -t sysfs -o nosuid,noexec,nodev sysfs /sys > /dev/null; then

echo "Cannot mount sysfs on /sys! Compile the kernel with CONFIG_SYSFS!"
if [ "$?" != "0" ]; then exit 1
echo "Cannot mount sysfs on /sys! Compile the kernel with CONFIG_SYSFS!" fi
exit 1
fi fi


RD_DEBUG="" RD_DEBUG=""
@ -77,14 +75,14 @@ fi


if command -v kmod > /dev/null 2> /dev/null; then if command -v kmod > /dev/null 2> /dev/null; then
kmod static-nodes --format=tmpfiles 2> /dev/null \ kmod static-nodes --format=tmpfiles 2> /dev/null \
| while read type file mode a a a majmin || [ -n "$type" ]; do | while read -r type file mode _ _ _ majmin || [ -n "$type" ]; do
type=${type%\!} type=${type%\!}
case $type in case $type in
d) d)
mkdir -m $mode -p $file mkdir -m "$mode" -p "$file"
;; ;;
c) c)
mknod -m $mode $file $type ${majmin%:*} ${majmin#*:} mknod -m "$mode" "$file" "$type" "${majmin%:*}" "${majmin#*:}"
;; ;;
esac esac
done done
@ -92,20 +90,13 @@ fi


trap "emergency_shell Signal caught!" 0 trap "emergency_shell Signal caught!" 0


export UDEVVERSION=$(udevadm --version) export UDEVRULESD=/run/udev/rules.d
if [ $UDEVVERSION -gt 166 ]; then [ -d /run/udev ] || mkdir -p -m 0755 /run/udev
# newer versions of udev use /run/udev/rules.d [ -d "$UDEVRULESD" ] || mkdir -p -m 0755 "$UDEVRULESD"
export UDEVRULESD=/run/udev/rules.d
[ -d /run/udev ] || mkdir -p -m 0755 /run/udev
[ -d $UDEVRULESD ] || mkdir -p -m 0755 $UDEVRULESD
else
mkdir -m 0755 -p /dev/.udev /dev/.udev/rules.d
export UDEVRULESD=/dev/.udev/rules.d
fi


if [ "$RD_DEBUG" = "yes" ]; then if [ "$RD_DEBUG" = "yes" ]; then
mkfifo /run/initramfs/loginit.pipe mkfifo /run/initramfs/loginit.pipe
loginit $DRACUT_QUIET < /run/initramfs/loginit.pipe > /dev/console 2>&1 & loginit "$DRACUT_QUIET" < /run/initramfs/loginit.pipe > /dev/console 2>&1 &
exec > /run/initramfs/loginit.pipe 2>&1 exec > /run/initramfs/loginit.pipe 2>&1
else else
exec 0<> /dev/console 1<> /dev/console 2<> /dev/console exec 0<> /dev/console 1<> /dev/console 2<> /dev/console
@ -118,7 +109,7 @@ source_conf /etc/conf.d


if getarg "rd.cmdline=ask"; then if getarg "rd.cmdline=ask"; then
echo "Enter additional kernel command line parameter (end with ctrl-d or .)" echo "Enter additional kernel command line parameter (end with ctrl-d or .)"
while read -p "> " line || [ -n "$line" ]; do while read -r -p "> " line || [ -n "$line" ]; do
[ "$line" = "." ] && break [ "$line" = "." ] && break
echo "$line" >> /etc/cmdline.d/99-cmdline-ask.conf echo "$line" >> /etc/cmdline.d/99-cmdline-ask.conf
done done
@ -150,14 +141,10 @@ getargbool 0 rd.udev.info -d -y rdudevinfo && UDEV_LOG=info
getargbool 0 rd.udev.debug -d -y rdudevdebug && UDEV_LOG=debug getargbool 0 rd.udev.debug -d -y rdudevdebug && UDEV_LOG=debug


# start up udev and trigger cold plugs # start up udev and trigger cold plugs
UDEV_LOG=$UDEV_LOG $systemdutildir/systemd-udevd --daemon --resolve-names=never UDEV_LOG=$UDEV_LOG "$systemdutildir"/systemd-udevd --daemon --resolve-names=never


UDEV_QUEUE_EMPTY="udevadm settle --timeout=0" UDEV_QUEUE_EMPTY="udevadm settle --timeout=0"


if [ $UDEVVERSION -lt 140 ]; then
UDEV_QUEUE_EMPTY="udevadm settle --timeout=1"
fi

udevproperty "hookdir=$hookdir" udevproperty "hookdir=$hookdir"


make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
@ -186,21 +173,23 @@ while :; do


check_finished && break check_finished && break


if [ -f $hookdir/initqueue/work ]; then if [ -f "$hookdir"/initqueue/work ]; then
rm -f -- $hookdir/initqueue/work rm -f -- "$hookdir"/initqueue/work
fi fi


for job in $hookdir/initqueue/*.sh; do for job in "$hookdir"/initqueue/*.sh; do
[ -e "$job" ] || break [ -e "$job" ] || break
job=$job . $job # shellcheck disable=SC2097 disable=SC1090 disable=SC2098
job=$job . "$job"
check_finished && break 2 check_finished && break 2
done done


$UDEV_QUEUE_EMPTY > /dev/null 2>&1 || continue $UDEV_QUEUE_EMPTY > /dev/null 2>&1 || continue


for job in $hookdir/initqueue/settled/*.sh; do for job in "$hookdir"/initqueue/settled/*.sh; do
[ -e "$job" ] || break [ -e "$job" ] || break
job=$job . $job # shellcheck disable=SC2097 disable=SC1090 disable=SC2098
job=$job . "$job"
check_finished && break 2 check_finished && break 2
done done


@ -210,11 +199,12 @@ while :; do
sleep 0.5 sleep 0.5


if [ $main_loop -gt $((2 * RDRETRY / 3)) ]; then if [ $main_loop -gt $((2 * RDRETRY / 3)) ]; then
for job in $hookdir/initqueue/timeout/*.sh; do for job in "$hookdir"/initqueue/timeout/*.sh; do
[ -e "$job" ] || break [ -e "$job" ] || break
job=$job . $job # shellcheck disable=SC2097 disable=SC1090 disable=SC2098
job=$job . "$job"
udevadm settle --timeout=0 > /dev/null 2>&1 || main_loop=0 udevadm settle --timeout=0 > /dev/null 2>&1 || main_loop=0
[ -f $hookdir/initqueue/work ] && main_loop=0 [ -f "$hookdir"/initqueue/work ] && main_loop=0
done done
fi fi


@ -245,7 +235,8 @@ while :; do
usable_root "$NEWROOT" && break usable_root "$NEWROOT" && break
umount "$NEWROOT" umount "$NEWROOT"
fi fi
for f in $hookdir/mount/*.sh; do for f in "$hookdir"/mount/*.sh; do
# shellcheck disable=SC1090
[ -f "$f" ] && . "$f" [ -f "$f" ] && . "$f"
if ismounted "$NEWROOT"; then if ismounted "$NEWROOT"; then
usable_root "$NEWROOT" && break usable_root "$NEWROOT" && break
@ -265,7 +256,7 @@ done


{ {
printf "Mounted root filesystem " printf "Mounted root filesystem "
while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts while read -r dev mp _ || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo "$dev"; done < /proc/mounts
} | vinfo } | vinfo


# pre pivot scripts are sourced just before we doing cleanup and switch over # pre pivot scripts are sourced just before we doing cleanup and switch over
@ -303,21 +294,8 @@ done
emergency_shell emergency_shell
} }


if [ $UDEVVERSION -lt 168 ]; then udevadm control --exit
# stop udev queue before killing it udevadm info --cleanup-db
udevadm control --stop-exec-queue

HARD=""
while pidof udevd > /dev/null 2>&1; do
for pid in $(pidof udevd); do
kill $HARD $pid > /dev/null 2>&1
done
HARD="-9"
done
else
udevadm control --exit
udevadm info --cleanup-db
fi


debug_off # Turn off debugging for this section debug_off # Turn off debugging for this section


@ -345,23 +323,23 @@ done
rm -f -- /tmp/export.orig rm -f -- /tmp/export.orig


initargs="" initargs=""
read CLINE < /proc/cmdline read -r CLINE < /proc/cmdline
if getarg init= > /dev/null; then if getarg init= > /dev/null; then
ignoreargs="console BOOT_IMAGE" ignoreargs="console BOOT_IMAGE"
# only pass arguments after init= to the init # only pass arguments after init= to the init
CLINE=${CLINE#*init=} CLINE=${CLINE#*init=}
set -- $CLINE set -- "$CLINE"
shift # clear out the rest of the "init=" arg shift # clear out the rest of the "init=" arg
for x in "$@"; do for x in "$@"; do
for s in $ignoreargs; do for s in $ignoreargs; do
[ "${x%%=*}" = $s ] && continue 2 [ "${x%%=*}" = "$s" ] && continue 2
done done
initargs="$initargs $x" initargs="$initargs $x"
done done
unset CLINE unset CLINE
else else
debug_off # Turn off debugging for this section debug_off # Turn off debugging for this section
set -- $CLINE set -- "$CLINE"
for x in "$@"; do for x in "$@"; do
case "$x" in case "$x" in
[0-9] | s | S | single | emergency | auto) [0-9] | s | S | single | emergency | auto)
@ -399,17 +377,17 @@ if [ -f /etc/capsdrop ]; then
. /etc/capsdrop . /etc/capsdrop
info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped." info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped."
unset RD_DEBUG unset RD_DEBUG
exec $CAPSH --drop="$CAPS_INIT_DROP" -- \ exec "$CAPSH" --drop="$CAPS_INIT_DROP" -- \
-c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" \ -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" \
|| { || {
warn "Command:" warn "Command:"
warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs warn capsh --drop="$CAPS_INIT_DROP" -- -c exec switch_root "$NEWROOT" "$INIT" "$initargs"
warn "failed." warn "failed."
emergency_shell emergency_shell
} }
else else
unset RD_DEBUG unset RD_DEBUG
exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || { exec "$SWITCH_ROOT" "$NEWROOT" "$INIT" "$initargs" || {
warn "Something went very badly wrong in the initramfs. Please " warn "Something went very badly wrong in the initramfs. Please "
warn "file a bug against dracut." warn "file a bug against dracut."
emergency_shell emergency_shell

View File

@ -54,18 +54,19 @@ fi
exe=$1 exe=$1
shift shift


[ -x "$exe" ] || exe=$(command -v $exe) [ -x "$exe" ] || exe=$(command -v "$exe")
if [ -z "$exe" ]; then if [ -z "$exe" ]; then
echo "Invalid command" echo "Invalid command"
exit 1 exit 1
fi fi


{ {
# shellcheck disable=SC2016
[ -n "$onetime" ] && echo '[ -e "$job" ] && rm -f -- "$job"' [ -n "$onetime" ] && echo '[ -e "$job" ] && rm -f -- "$job"'
[ -n "$env" ] && echo "$env" [ -n "$env" ] && echo "$env"
echo "$exe" "$@" echo "$exe" "$@"
} > "/tmp/$$-${job}.sh" } > "/tmp/$$-${job}.sh"


mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh" mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh"
[ -z "$qname" ] && >> $hookdir/initqueue/work [ -z "$qname" ] && : >> "$hookdir"/initqueue/work
exit 0 exit 0

View File

@ -5,12 +5,13 @@ set +x


QUIET=$1 QUIET=$1


printf -- "$$" > /run/initramfs/loginit.pid printf "%s" "$$" > /run/initramfs/loginit.pid


# shellcheck disable=SC2015
[ -e /dev/kmsg ] && exec 5> /dev/kmsg || exec 5> /dev/null [ -e /dev/kmsg ] && exec 5> /dev/kmsg || exec 5> /dev/null
exec 6> /run/initramfs/init.log exec 6> /run/initramfs/init.log


while read line || [ -n "$line" ]; do while read -r line || [ -n "$line" ]; do
if [ "$line" = "DRACUT_LOG_END" ]; then if [ "$line" = "DRACUT_LOG_END" ]; then
rm -f -- /run/initramfs/loginit.pipe rm -f -- /run/initramfs/loginit.pipe
exit 0 exit 0

View File

@ -15,7 +15,7 @@ depends() {
install() { install() {
inst_multiple mount mknod mkdir sleep chroot chown \ inst_multiple mount mknod mkdir sleep chroot chown \
sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid \ sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid \
modprobe modprobe chmod


inst_multiple -o findmnt less kmod dracut-getargs inst_multiple -o findmnt less kmod dracut-getargs


@ -55,7 +55,7 @@ install() {
if ! dracut_module_included "systemd"; then if ! dracut_module_included "systemd"; then
inst_multiple switch_root || dfatal "Failed to install switch_root" inst_multiple switch_root || dfatal "Failed to install switch_root"
inst_hook cmdline 10 "$moddir/parse-root-opts.sh" inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
inst_multiple -o $systemdutildir/systemd-timestamp inst_multiple -o "$systemdutildir"/systemd-timestamp
fi fi


if [[ $realinitpath ]]; then if [[ $realinitpath ]]; then
@ -69,12 +69,13 @@ install() {
echo ro >> "${initdir}/etc/cmdline.d/base.conf" echo ro >> "${initdir}/etc/cmdline.d/base.conf"
fi fi


[ -e "${initdir}/usr/lib" ] || mkdir -m 0755 -p ${initdir}/usr/lib [ -e "${initdir}/usr/lib" ] || mkdir -m 0755 -p "${initdir}"/usr/lib


local VERSION="" local VERSION=""
local PRETTY_NAME="" local PRETTY_NAME=""
# Derive an os-release file from the host, if it exists # Derive an os-release file from the host, if it exists
if [[ -e $dracutsysrootdir/etc/os-release ]]; then if [[ -e $dracutsysrootdir/etc/os-release ]]; then
# shellcheck disable=SC1090
. "$dracutsysrootdir"/etc/os-release . "$dracutsysrootdir"/etc/os-release
grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' "$dracutsysrootdir"/etc/os-release > "${initdir}"/usr/lib/initrd-release grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' "$dracutsysrootdir"/etc/os-release > "${initdir}"/usr/lib/initrd-release
[[ -n ${VERSION} ]] && VERSION+=" " [[ -n ${VERSION} ]] && VERSION+=" "
@ -83,26 +84,26 @@ install() {
# Fall back to synthesizing one, since dracut is presently used # Fall back to synthesizing one, since dracut is presently used
# on non-systemd systems as well. # on non-systemd systems as well.
{ {
echo NAME=dracut echo "NAME=dracut"
echo ID=dracut echo "ID=dracut"
echo VERSION_ID=\"$DRACUT_VERSION\" echo "VERSION_ID=\"$DRACUT_VERSION\""
echo ANSI_COLOR='"0;34"' echo 'ANSI_COLOR="0;34"'
} > ${initdir}/usr/lib/initrd-release } > "${initdir}"/usr/lib/initrd-release
fi fi
VERSION+="dracut-$DRACUT_VERSION" VERSION+="dracut-$DRACUT_VERSION"
PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)" PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)"
{ {
echo VERSION=\"$VERSION\" echo "VERSION=\"$VERSION\""
echo PRETTY_NAME=\"$PRETTY_NAME\" echo "PRETTY_NAME=\"$PRETTY_NAME\""
# This addition is relatively new, intended to allow software # This addition is relatively new, intended to allow software
# to easily detect the dracut version if need be without # to easily detect the dracut version if need be without
# having it mixed in with the real underlying OS version. # having it mixed in with the real underlying OS version.
echo DRACUT_VERSION=\"${DRACUT_VERSION}\" echo "DRACUT_VERSION=\"${DRACUT_VERSION}\""
} >> "$initdir"/usr/lib/initrd-release } >> "$initdir"/usr/lib/initrd-release
echo "dracut-$DRACUT_VERSION" > "$initdir/lib/dracut/dracut-$DRACUT_VERSION" echo "dracut-$DRACUT_VERSION" > "$initdir/lib/dracut/dracut-$DRACUT_VERSION"
ln -sf ../usr/lib/initrd-release $initdir/etc/initrd-release ln -sf ../usr/lib/initrd-release "$initdir"/etc/initrd-release
ln -sf initrd-release $initdir/usr/lib/os-release ln -sf initrd-release "$initdir"/usr/lib/os-release
ln -sf initrd-release $initdir/etc/os-release ln -sf initrd-release "$initdir"/etc/os-release


## save host_devs which we need bring up ## save host_devs which we need bring up
if [[ $hostonly_cmdline == "yes" ]]; then if [[ $hostonly_cmdline == "yes" ]]; then
@ -112,10 +113,11 @@ install() {
if [[ -f $initdir/lib/dracut/need-initqueue ]] || ! dracut_module_included "systemd"; then if [[ -f $initdir/lib/dracut/need-initqueue ]] || ! dracut_module_included "systemd"; then
( (
if dracut_module_included "systemd"; then if dracut_module_included "systemd"; then
DRACUT_SYSTEMD=1 export DRACUT_SYSTEMD=1
fi fi
PREFIX="$initdir" export PREFIX="$initdir"


# shellcheck source=dracut-lib.sh
. "$moddir/dracut-lib.sh" . "$moddir/dracut-lib.sh"


for _dev in "${host_devs[@]}"; do for _dev in "${host_devs[@]}"; do
@ -130,10 +132,10 @@ install() {
[[ $_dev == "$_dev2" ]] && continue 2 [[ $_dev == "$_dev2" ]] && continue 2
done done


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


case "$_pdev" in case "$_pdev" in
/dev/?*) wait_for_dev $_pdev ;; /dev/?*) wait_for_dev "$_pdev" ;;
*) ;; *) ;;
esac esac
done done

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh


# shellcheck disable=SC2034
root=$(getarg root=) root=$(getarg root=)


rflags="$(getarg rootflags=)" rflags="$(getarg rootflags=)"

View File

@ -10,14 +10,18 @@ PWFILTER='s/\(ftp:\/\/.*\):.*@/\1:*******@/g;s/\(cifs:\/\/.*\):.*@/\1:*******@/g
set -x set -x
cat /lib/dracut/dracut-* cat /lib/dracut/dracut-*


cat /proc/cmdline | sed -e "$PWFILTER" echo "/proc/cmdline"
sed -e "$PWFILTER" /proc/cmdline


[ -f /etc/cmdline ] && cat /etc/cmdline | sed -e "$PWFILTER" if [ -f /etc/cmdline ]; then
echo "/etc/cmdline"
sed -e "$PWFILTER" /etc/cmdline
fi


for _i in /etc/cmdline.d/*.conf; do for _i in /etc/cmdline.d/*.conf; do
[ -f "$_i" ] || break [ -f "$_i" ] || break
echo $_i echo "$_i"
cat $_i | sed -e "$PWFILTER" sed -e "$PWFILTER" "$_i"
done done


cat /proc/self/mountinfo cat /proc/self/mountinfo
@ -30,8 +34,8 @@ ls -l /dev/disk/by*


for _i in /etc/conf.d/*.conf; do for _i in /etc/conf.d/*.conf; do
[ -f "$_i" ] || break [ -f "$_i" ] || break
echo $_i echo "$_i"
cat $_i | sed -e "$PWFILTER" sed -e "$PWFILTER" "$_i"
done done


if command -v lvm > /dev/null 2> /dev/null; then if command -v lvm > /dev/null 2> /dev/null; then
@ -50,5 +54,8 @@ if command -v journalctl > /dev/null 2> /dev/null; then
journalctl -ab --no-pager -o short-monotonic | sed -e "$PWFILTER" journalctl -ab --no-pager -o short-monotonic | sed -e "$PWFILTER"
else else
dmesg | sed -e "$PWFILTER" dmesg | sed -e "$PWFILTER"
[ -f /run/initramfs/init.log ] && cat /run/initramfs/init.log | sed -e "$PWFILTER" if [ -f /run/initramfs/init.log ]; then
echo "/run/initramfs/init.log"
sed -e "$PWFILTER" /run/initramfs/init.log
fi
fi fi