mkdumprd: use kdump_get_conf_val to read config values

upstream: fedora
resolves: bz2003832
conflict: none

commit 075e62252e
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 01:58:04 2021 +0800

    mkdumprd: use kdump_get_conf_val to read config values

    Simplify the code and cover more corner cases.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
Tao Liu 2021-11-03 15:31:19 +08:00
parent e35e4054ca
commit 514b4f0679

View File

@ -23,7 +23,6 @@ if [ $? -ne 0 ]; then
exit 1
fi
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
SAVE_PATH=$(get_save_path)
OVERRIDE_RESETTABLE=0
@ -292,19 +291,6 @@ handle_default_dump_target()
check_size fs $_target
}
get_override_resettable()
{
local override_resettable
override_resettable=$(grep "^override_resettable" $conf_file)
if [ -n "$override_resettable" ]; then
OVERRIDE_RESETTABLE=$(echo $override_resettable | cut -d' ' -f2)
if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then
perror_exit "override_resettable value $OVERRIDE_RESETTABLE is invalid"
fi
fi
}
# $1: function name
for_each_block_target()
{
@ -343,9 +329,13 @@ is_unresettable()
#return true if resettable
check_resettable()
{
local _ret _target
local _ret _target _override_resettable
get_override_resettable
_override_resettable=$(kdump_get_conf_val override_resettable)
OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE}
if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then
perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid"
fi
for_each_block_target is_unresettable
_ret=$?
@ -375,7 +365,7 @@ if ! check_crypt; then
fi
# firstly get right SSH_KEY_LOCATION
keyfile=$(awk '/^sshkey/ {print $2}' $conf_file)
keyfile=$(kdump_get_conf_val sshkey)
if [ -f "$keyfile" ]; then
# canonicalize the path
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)