This mass update is done with the assistant of shellcheck and shfmt.
This patch series fixed most syntax issues found by shellcheck,
tons of corner cases and issues are fixed.
Also simplified a lot of code according to suggestions by shellcheck.
Related shellcheck warn/error/suggest info links are included in the commit
message.
Since shellcheck can help to detect non-POSIX syntax issue in POSIX
script (#!/bin/sh), and the coding style in kexec-tools package is
very messy, this series refactored the code structure in following way:
- kdumpctl, mkdumprd, mkfadumprd, *-module-setup.sh and kdump-lib.sh
is "bash only" script. We rely on bash only syntax heavily, and they
will only be used in the first kernel, so just let them leverage bash
syntax for better maintainability and better performance.
- kdump-lib-initramfs.sh, and dracut-kdump.sh is now POSIX compatible,
and will be used in the second kernel.
This refactoring also enables kdump to use dash or busybox, instead of
bash in the second kernel, which improves performance and memory
usage. Tested with latest dracut on Fedora 34, now "dash" in second
kernel works well, it's faster than bash and save a lot of memory.
We may test dash or busybox as default kdump shell in the future for
better performance.
For reviewers:
Patch 25, 26, 30, 41, 46 is automatic code update using script and
tools like shfmt, other patch may need careful review.
Patch 1 added a editorconfig file for shfmt to work properly, which
is Acked by Pingfan but still posting it to make it easier to review.
Patch 2 - 29 focus on the bash part:
Patch 2, 3, 4, 5, 8 introduced new config file read and format helper,
which unified the config file reading in kexec-tools scripts. So space
in config file should be no longer a problem (previously random problem
may occur since kexec-tools scripts is using many different ways to read
the config file). And this make it much easier to clean up the code.
Patch 6, 7, 9 - 24 fixed many issues found with shellcheck in bash
scripts manually.
Some issues are already breaking kdump just no one noticed yet.
Patch 25, 26, 30 is an automatic code update using sed and shfmt, there
should be no code behaviour change.
Patch 27, 28, 29 batch fixed some common bash script issues manually
with hints from shellcheck.
Patch 31 - 48 focus on the POSIX part:
Patch 31 - 33 restructures the code, prepare to make
kdump-lib-initramfs.sh a POSIX script and drop kdump-lib.sh in kdump
kernel.
Patch 34 - 38 clean up code in dracut-kdump.sh, and fix misc issues
found by shellcheck manually, prepare to make it POSIX compatible.
Patch 39 contains a lot of code refactoring that makes dracut-kdump.sh POSIX
compatible.
Patch 40 contains a lot of code refactoring that makes kdump-lib-initramfs.sh
POSIX compatible.
Patch 41 is an automatic code update using sed, there should be no code
behaviour change.
Patch 42, 43 reworked how nmcli is being called by kexec-tools, fixed
word splitting issue and allow connection name to contain space.
Patch 44 optimized a sed call.
Patch 45 batch fixed some common bash script issues manually
with hints from shellcheck.
Patch 46 is an automatic code update using shfmt, there should be no code
behaviour change.
Patch 47, 48 contains a lot of change that makes kdump-logger.sh
POSIX compatible.
Patch 49 allows mkdumprd to use dash instead of bash in second kernel.
Update from V1:
- Fix many typos and code error, and fix a few more existing code issues
found while reviewing the patch, many thanks to Philipp Rudo.
- Add more info in commit message and cover letter.
Kairui Song (49):
Add a .editorconfig file
kdump-lib.sh: add a config format and read helper
kdump-lib.sh: add a config value retrive helper
kdump-lib.sh: use kdump_get_conf_val to read config values
kdumpctl: use kdump_get_conf_val to read config values
kdumpctl: get rid of a `wc` call
kdumpctl: fix fragile loops over find output
mkdumprd: use kdump_get_conf_val to read config values
mkdumprd: make dracut_args an array again
mkdumprd: remove some redundant echo
mkdumprd: fix multiple issues with get_ssh_size
mkdumprd: use array to store ssh arguments in mkdir_save_path_ssh
mkfadumprd: make _dracut_isolate_args an array
dracut-module-setup.sh: rework kdump_get_ip_route_field
dracut-module-setup.sh: remove an unused variable
dracut-module-setup.sh: fix _bondoptions wrong references
dracut-module-setup.sh: use "*" to expend array as string
dracut-module-setup.sh: fix a ambiguous variable reference
dracut-module-setup.sh: fix a loop over ls issue
dracut-module-setup.sh: make iscsi check fail early if cd failed
bash scripts: remove useless cat
bash scripts: get rid of expr and let
bash scripts: get rid of unnessary sed calls
bash scripts: always use "read -r"
bash scripts: use $(...) notation instead of legacy `...`
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
bash scripts: fix variable quoting issue
bash scripts: fix redundant exit code check
bash scripts: declare and assign separately
bash scripts: reformat with shfmt
Prepare to make kdump-lib-initramfs.sh a POSIX compatible lib
Merge kdump-error-handler.sh into kdump.sh
kdump-lib-initramfs.sh: move dump raleted functions to kdump.sh
dracut-kdump.sh: don't put KDUMP_SCRIPT_DIR in PATH
dracut-kdump.sh: remove add_dump_code
dracut-kdump.sh: simplify dump_ssh
dracut-kdump.sh: Use stat instead of ls to get vmcore size
dracut-kdump.sh: POSIX doesn't support pipefail
dracut-kdump.sh: make it POSIX compatible
kdump-lib-initramfs.sh: make it POSIX compatible
kdump-lib.sh: replace '[ ]' with '[[ ]]' and get rid of legacy ``
kdump-lib.sh: fix and simplify get_nmcli_value_by_field
kdump-lib.sh: fix word splitting of nmcli params
kdump-lib.sh: avoid calling sed multiple times in get_system_size
kdump-lib.sh: batch fix issues found with shellcheck
kdump-lib.sh: reformat with shfmt
kdump-logger.sh: refactor to remove some bash only syntax
kdump-logger.sh: make it POSIX compatible
mkdumprd: allow using dash
.editorconfig | 32 +
dracut-early-kdump-module-setup.sh | 11 +-
dracut-kdump-emergency.service | 2 +-
dracut-kdump-error-handler.sh | 10 -
dracut-kdump.sh | 511 ++++++++---
dracut-module-setup.sh | 668 +++++++-------
kdump-lib-initramfs.sh | 346 ++-----
kdump-lib.sh | 1356 +++++++++++++---------------
kdump-logger.sh | 117 +--
kdumpctl | 604 ++++++-------
kexec-tools.spec | 2 -
mkdumprd | 600 ++++++------
mkfadumprd | 21 +-
13 files changed, 2104 insertions(+), 2176 deletions(-)
create mode 100644 .editorconfig
delete mode 100755 dracut-kdump-error-handler.sh
--
2.31.1