This help deduplicate the code. Use a single function instead of
repeat the same logic.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-module-setup.sh | 15 +++------------
kdump-lib.sh | 9 ++++-----
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index e6358a8..8e9fe42 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -428,12 +428,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
- _save_path=$(get_option_value "path")
- [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
-
- # strip the duplicated "/"
- _save_path=$(echo $_save_path | tr -s /)
-
+ _save_path=$(get_save_path)
_mntpoint=$(get_mntpoint_from_path $_save_path)
_target=$(get_target_from_path $_save_path)
@@ -472,13 +467,9 @@ default_dump_target_install_conf()
adjust_bind_mount_path()
{
local _target=$1
- local _save_path=$(get_option_value "path")
- [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
-
- # strip the duplicated "/"
- _save_path=$(echo $_save_path | tr -s /)
-
+ local _save_path=$(get_save_path)
local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path
+
_absolute_save_path=$(echo "$_absolute_save_path" | tr -s /)
local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 2318e2d..d35282d 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -126,12 +126,11 @@ get_root_fs_device()
get_save_path()
{
- local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
- if [ -z "$_save_path" ]; then
- _save_path=$DEFAULT_PATH
- fi
+ local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
+ [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
- echo $_save_path
+ # strip the duplicated "/"
+ echo $(echo $_save_path | tr -s /)
}
get_block_dump_target()
--
2.23.0