From 69bf81bc8bbc0a0562a59a4cd294361c32caa9ad Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:16:44 +0800 Subject: [PATCH] Move watchdog detect and install code to module-setup.sh Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 4 ++++ kdump-lib.sh | 12 ++++++++++++ mkdumprd | 18 ------------------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b54447b..850c6f6 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -40,6 +40,10 @@ depends() { dwarning "Required modules to build a squashed kdump image is missing!" fi + if is_wdt_active; then + add_opt_module watchdog + fi + if is_ssh_dump_target; then _dep="$_dep ssh-client" fi diff --git a/kdump-lib.sh b/kdump-lib.sh index b55d987..748419f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -479,6 +479,18 @@ is_wdt_mod_omitted() { return $ret } +is_wdt_active() { + local active + + [ -d /sys/class/watchdog ] || return 1 + for dir in /sys/class/watchdog/*; do + [ -f "$dir/state" ] || continue + active=$(< "$dir/state") + [ "$active" = "active" ] && return 0 + done + return 1 +} + # If "dracut_args" contains "--mount" information, use it # directly without any check(users are expected to ensure # its correctness). diff --git a/mkdumprd b/mkdumprd index 4c4cd0b..0623940 100644 --- a/mkdumprd +++ b/mkdumprd @@ -44,20 +44,6 @@ trap ' # clean up after ourselves no matter how we die. trap 'exit 1;' SIGINT -is_wdt_addition_needed() { - local active - - is_wdt_mod_omitted - [[ $? -eq 0 ]] && return 1 - [[ -d /sys/class/watchdog/ ]] || return 1 - for dir in /sys/class/watchdog/*; do - [[ -f "$dir/state" ]] || continue - active=$(< "$dir/state") - [[ "$active" = "active" ]] && return 0 - done - return 1 -} - add_dracut_arg() { dracut_args="$dracut_args $@" } @@ -417,10 +403,6 @@ if [ -f "$keyfile" ]; then SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) fi -if is_wdt_addition_needed; then - add_dracut_arg "-a" "watchdog" -fi - while read config_opt config_val; do # remove inline comments after the end of a directive.