From fd7e7be48331bcaca9b33a2286179efe6812b456 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 8 Mar 2020 16:41:10 +0800 Subject: [PATCH] mkdumprd: Use get_save_path instead of parsing config get_save_path provides default value fail back and error check, no need to repeat it again. Also remove a redundant echo and grep in get_save_path Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 4 ++-- mkdumprd | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 9c41439..d06a417 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -138,11 +138,11 @@ get_root_fs_device() get_save_path() { - local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}') + local _save_path=$(awk '$1 == "path" {print $2}' /etc/kdump.conf) [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH # strip the duplicated "/" - echo $(echo $_save_path | tr -s /) + echo $_save_path | tr -s / } get_block_dump_target() diff --git a/mkdumprd b/mkdumprd index f80304b..f04f565 100644 --- a/mkdumprd +++ b/mkdumprd @@ -13,10 +13,7 @@ export IN_KDUMP=1 conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file) -[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH -# strip the duplicated "/" -SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules=""