Move watchdog detect and install code to module-setup.sh

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
This commit is contained in:
Kairui Song 2020-10-15 18:16:44 +08:00
parent bc639c9763
commit 69bf81bc8b
3 changed files with 16 additions and 18 deletions

View File

@ -40,6 +40,10 @@ depends() {
dwarning "Required modules to build a squashed kdump image is missing!" dwarning "Required modules to build a squashed kdump image is missing!"
fi fi
if is_wdt_active; then
add_opt_module watchdog
fi
if is_ssh_dump_target; then if is_ssh_dump_target; then
_dep="$_dep ssh-client" _dep="$_dep ssh-client"
fi fi

View File

@ -479,6 +479,18 @@ is_wdt_mod_omitted() {
return $ret 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 # If "dracut_args" contains "--mount" information, use it
# directly without any check(users are expected to ensure # directly without any check(users are expected to ensure
# its correctness). # its correctness).

View File

@ -44,20 +44,6 @@ trap '
# clean up after ourselves no matter how we die. # clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT 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() { add_dracut_arg() {
dracut_args="$dracut_args $@" dracut_args="$dracut_args $@"
} }
@ -417,10 +403,6 @@ if [ -f "$keyfile" ]; then
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
fi fi
if is_wdt_addition_needed; then
add_dracut_arg "-a" "watchdog"
fi
while read config_opt config_val; while read config_opt config_val;
do do
# remove inline comments after the end of a directive. # remove inline comments after the end of a directive.