kdump-utils/0005-99kdumpbase-fix-shellcheck-warnings.patch
Philipp Rudo d38412baaf Enable erofs support for the kdump initrd
Resolves: RHEL-50942
Upstream: https://github.com/rhkdump/kdump-utils.git
Conflict: Dropped hunks concerning OVS bridge support in patch 3 and 5
	   due to missing 224d310 ("Support setting up Open vSwitch
	   (Ovs) Bridge network")

Also contains upstream commit

commit 2970176d9e9b7b6a1191a9ee54423d2f1c56fbaf
Author: Philipp Rudo <prudo@redhat.com>
Date:   Tue Sep 24 10:39:32 2024 +0200

    spec: fix patching of files in subdirectories

    With 23df04b ("dracut: create sub-directories for dracut modules") the
    dracut modules were moved to subdirectories. This causes problems when
    someone wants to include a patch to the spec file to change one of the
    files in those subdirectories. Reason is that '%autosetup' in the spec
    file calls 'patch' per default. 'patch' however, will strip all
    directories when it is called without option -p. Which means that it
    will search the file in the root directory and then fail because it
    cannot find it. Thus add option -p1 to '%autosetup' which will be passed
    on to 'patch'. Choose -p1 as that will work with the most common patch
    creation tools like git and packit.

    Signed-off-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Philipp Rudo <prudo@redhat.com>
2024-09-27 15:48:12 +02:00

248 lines
8.5 KiB
Diff

From 441843d66d25c8c144caeb5d4aa78b38453295e9 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 16:01:30 +0200
Subject: [PATCH 05/16] 99kdumpbase: fix shellcheck warnings
Fix the shellcheck warnings for 99kdumpbase. With this
$ shellcheck -x dracut/99kdumpbase/*.sh
now returns without finding.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99kdumpbase/kdump.sh | 32 +++++++++++-------
dracut/99kdumpbase/module-setup.sh | 40 +++++++++++++++++++++--
dracut/99kdumpbase/monitor_dd_progress.sh | 6 ++--
3 files changed, 62 insertions(+), 16 deletions(-)
diff --git a/dracut/99kdumpbase/kdump.sh b/dracut/99kdumpbase/kdump.sh
index 22586b1..dea83ee 100755
--- a/dracut/99kdumpbase/kdump.sh
+++ b/dracut/99kdumpbase/kdump.sh
@@ -3,8 +3,11 @@
# The main kdump routine in capture kernel, bash may not be the
# default shell. Any code added must be POSIX compliant.
+# shellcheck source=/dev/null
. /lib/dracut-lib.sh
+# shellcheck source=SCRIPTDIR/../../kdump-logger.sh
. /lib/kdump-logger.sh
+# shellcheck source=SCRIPTDIR/../../kdump-lib-initramfs.sh
. /lib/kdump-lib-initramfs.sh
#initiate the kdump logger
@@ -262,11 +265,14 @@ dump_to_rootfs() {
kdump_emergency_shell() {
ddebug "Switching to kdump emergency shell..."
+ # shellcheck source=/dev/null
[ -f /etc/profile ] && . /etc/profile
export PS1='kdump:${PWD}# '
+ # shellcheck source=/dev/null
. /lib/dracut-lib.sh
if [ -f /dracut-state.sh ]; then
+ # shellcheck source=/dev/null
. /dracut-state.sh 2> /dev/null
fi
@@ -293,16 +299,16 @@ kdump_emergency_shell() {
do_failure_action() {
dinfo "Executing failure action $FAILURE_ACTION"
- eval $FAILURE_ACTION
+ eval "$FAILURE_ACTION"
}
do_final_action() {
dinfo "Executing final action $FINAL_ACTION"
- eval $FINAL_ACTION
+ eval "$FINAL_ACTION"
}
do_dump() {
- eval $DUMP_INSTRUCTION
+ eval "$DUMP_INSTRUCTION"
_ret=$?
if [ $_ret -ne 0 ]; then
@@ -390,7 +396,7 @@ dump_ssh() {
dinfo "saving to $2:$_ssh_dir"
cat /var/lib/random-seed > /dev/urandom
- ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1
+ ssh -q "$_ssh_opt" "$2" mkdir -p "$_ssh_dir" || return 1
save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2"
@@ -402,17 +408,19 @@ dump_ssh() {
save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address"
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
- scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete"
+ scp -q "$_ssh_opt" /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete"
_ret=$?
_vmcore="vmcore"
else
- $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'"
+ # shellcheck disable=SC2029
+ $CORE_COLLECTOR /proc/vmcore | ssh "$_ssh_opt" "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'"
_ret=$?
_vmcore="vmcore.flat"
fi
if [ $_ret -eq 0 ]; then
- ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'"
+ # shellcheck disable=SC2029
+ ssh "$_ssh_opt" "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'"
_ret=$?
if [ $_ret -ne 0 ]; then
derror "moving vmcore failed, exitcode:$_ret"
@@ -442,12 +450,13 @@ save_opalcore_ssh() {
dinfo "saving opalcore:$OPALCORE to $3:$1"
- if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then
+ if ! scp "$2" "$OPALCORE" "$4:$1/opalcore-incomplete"; then
derror "saving opalcore failed"
return 1
fi
- ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore"
+ # shellcheck disable=SC2029
+ ssh "$2" "$3" mv "$1/opalcore-incomplete" "$1/opalcore"
dinfo "saving opalcore complete"
return 0
}
@@ -458,8 +467,9 @@ save_opalcore_ssh() {
# $4: ssh address in <user>@<host> format
save_vmcore_dmesg_ssh() {
dinfo "saving vmcore-dmesg.txt to $4:$2"
- if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then
- ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt"
+ # shellcheck disable=SC2029
+ if "$1" /proc/vmcore | ssh "$3" "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then
+ ssh -q "$3" "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt"
dinfo "saving vmcore-dmesg.txt complete"
else
derror "saving vmcore-dmesg.txt failed"
diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh
index 56215e4..70dc8ca 100755
--- a/dracut/99kdumpbase/module-setup.sh
+++ b/dracut/99kdumpbase/module-setup.sh
@@ -11,12 +11,14 @@ _get_kdump_netifs() {
}
kdump_module_init() {
+ # shellcheck disable=SC2154
if ! [[ -d "${initdir}/tmp" ]]; then
mkdir -p "${initdir}/tmp"
fi
mkdir -p "$_DRACUT_KDUMP_NM_TMP_DIR"
+ # shellcheck source=SCRIPTDIR/../../kdump-lib.sh
. /lib/kdump/kdump-lib.sh
}
@@ -38,6 +40,7 @@ depends() {
kdump_module_init
add_opt_module() {
+ # shellcheck disable=SC2154
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
}
@@ -56,7 +59,7 @@ depends() {
fi
if is_lvm2_thinp_dump_target; then
- if grep -q lvmthinpool-monitor <<< $(dracut --list-modules); then
+ if grep -q lvmthinpool-monitor <<< "$(dracut --list-modules)"; then
add_opt_module lvmthinpool-monitor
else
dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057."
@@ -481,12 +484,14 @@ kdump_setup_vlan() {
# setup s390 znet
kdump_setup_znet() {
local _netif
- local _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX)
+ local _tempfile
if [[ "$(uname -m)" != "s390x" ]]; then
return
fi
+ _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX)
+
for _netif in $1; do
chzdev --export "$_tempfile" --active --by-interface "$_netif" |& ddebug
sed -i -e 's/^\[active /\[persistent /' "$_tempfile"
@@ -830,6 +861,7 @@ kdump_check_iscsi_targets() {
# If our prerequisites are not met, fail anyways.
type -P iscsistart > /dev/null || return 1
+ # shellcheck disable=SC2317
kdump_check_setup_iscsi() {
local _dev
_dev=$1
@@ -896,6 +928,7 @@ get_pcs_fence_kdump_nodes() {
for node in ${nodelist}; do
# convert $node from 'uname="nodeX"' to 'nodeX'
eval "$node"
+ # shellcheck disable=SC2154
nodename="$uname"
# Skip its own node name
if is_localhost "$nodename"; then
@@ -910,6 +943,7 @@ get_pcs_fence_kdump_nodes() {
# retrieves fence_kdump args from config file
get_pcs_fence_kdump_args() {
if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then
+ # shellcheck disable=SC1090
. "$FENCE_KDUMP_CONFIG_FILE"
echo "$FENCE_KDUMP_OPTS"
fi
@@ -1013,6 +1047,7 @@ install() {
kdump_install_random_seed
fi
dracut_install -o /etc/adjtime /etc/localtime
+ # shellcheck disable=SC2154
inst "$moddir/monitor_dd_progress.sh" "/kdumpscripts/monitor_dd_progress.sh"
inst "/bin/dd" "/bin/dd"
inst "/bin/tail" "/bin/tail"
@@ -1031,6 +1066,7 @@ install() {
inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
+ # shellcheck disable=SC2154
inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service
# Replace existing emergency service and emergency target
diff --git a/dracut/99kdumpbase/monitor_dd_progress.sh b/dracut/99kdumpbase/monitor_dd_progress.sh
index f9b03d5..f6ed409 100755
--- a/dracut/99kdumpbase/monitor_dd_progress.sh
+++ b/dracut/99kdumpbase/monitor_dd_progress.sh
@@ -11,15 +11,15 @@ done
while true; do
sleep 5
- if [ ! -d /proc/$DD_PID ]; then
+ if [ ! -d /proc/"$DD_PID" ]; then
break
fi
- kill -s USR1 $DD_PID
+ kill -s USR1 "$DD_PID"
CURRENT_SIZE=$(tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g")
[ -n "$CURRENT_SIZE" ] && {
CURRENT_MB=$((CURRENT_SIZE / 1048576))
- echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r"
+ printf "Copied %s MB / %s MB\r" "$CURRENT_MB" "$SRC_FILE_MB"
}
done
--
2.46.1