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 <kasong(a)redhat.com>
---
kdump-lib.sh | 4 ++--
mkdumprd | 5 +----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index d27aa3b..ea41d0c 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 c6a0586..d86d9b5 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=""
--
2.24.1