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!"
fi
if is_wdt_active; then
add_opt_module watchdog
fi
if is_ssh_dump_target; then
_dep="$_dep ssh-client"
fi

View File

@ -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).

View File

@ -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.