From 514b4f06791da2b21e11baf77452e7b59faa0962 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Nov 03 2021 08:11:00 +0000 Subject: mkdumprd: use kdump_get_conf_val to read config values upstream: fedora resolves: bz2003832 conflict: none commit 075e62252ec13e582e8aaa43a0fefee1ad5d8a58 Author: Kairui Song 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 Acked-by: Philipp Rudo Signed-off-by: Tao Liu --- diff --git a/mkdumprd b/mkdumprd index f856773..d40f3ca 100644 --- a/mkdumprd +++ b/mkdumprd @@ -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)