At the moment several kdump helper scripts use both MACROs/labels and
absolute names to signify the configuration file names
(for e.g. /etc/kdump.conf).
This patch tries to use only MACROs/labels instead of absolute file
names to signify the configuration file names.
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
dracut-module-setup.sh | 10 ++++++----
kdump-lib.sh | 21 +++++++++++----------
kdumpctl | 8 ++++----
mkdumprd | 2 +-
4 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 9f88b4e..48f2b77 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+KDUMP_CONFIG_FILE="/etc/kdump.conf"
+
. $dracutfunctions
. /lib/kdump/kdump-lib.sh
@@ -10,7 +12,7 @@ fi
check() {
[[ $debug ]] && set -x
#kdumpctl sets this explicitly
- if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ]
+ if [ -z "$IN_KDUMP" ] || [ ! -f $KDUMP_CONFIG_FILE ]
then
return 1
fi
@@ -439,7 +441,7 @@ adjust_bind_mount_path()
#install kdump.conf and what user specifies in kdump.conf
kdump_install_conf() {
local _opt _val _pdev
- sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf
+ sed -ne '/^#/!p' $KDUMP_CONFIG_FILE > ${initdir}/tmp/$$-kdump.conf
while read _opt _val;
do
@@ -472,12 +474,12 @@ kdump_install_conf() {
dracut_install "${_val%%[[:blank:]]*}"
;;
esac
- done < /etc/kdump.conf
+ done < $KDUMP_CONFIG_FILE
default_dump_target_install_conf
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
- inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf"
+ inst "${initdir}/tmp/$$-kdump.conf" "$KDUMP_CONFIG_FILE"
rm -f ${initdir}/tmp/$$-kdump.conf
}
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 8ebad70..f8b0409 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -6,6 +6,7 @@
DEFAULT_PATH="/var/crash/"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
+KDUMP_CONFIG_FILE="/etc/kdump.conf"
perror_exit() {
echo $@ >&2
@@ -18,18 +19,18 @@ perror() {
is_ssh_dump_target()
{
- grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
+ grep -q "^ssh[[:blank:]].*@" $KDUMP_CONFIG_FILE
}
is_nfs_dump_target()
{
- grep -q "^nfs" /etc/kdump.conf || \
- [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount"
/etc/kdump.conf)") = nfs* ]]
+ grep -q "^nfs" $KDUMP_CONFIG_FILE || \
+ [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount"
$KDUMP_CONFIG_FILE)") = nfs* ]]
}
is_raw_dump_target()
{
- grep -q "^raw" /etc/kdump.conf
+ grep -q "^raw" $KDUMP_CONFIG_FILE
}
is_fs_type_nfs()
@@ -41,7 +42,7 @@ is_fs_type_nfs()
is_fs_dump_target()
{
- egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
+ egrep -q "^ext[234]|^xfs|^btrfs|^minix" $KDUMP_CONFIG_FILE
}
is_user_configured_dump_target()
@@ -71,7 +72,7 @@ is_generic_fence_kdump()
{
[ -x $FENCE_KDUMP_SEND ] || return 1
- grep -q "^fence_kdump_nodes" /etc/kdump.conf
+ grep -q "^fence_kdump_nodes" $KDUMP_CONFIG_FILE
}
to_dev_name() {
@@ -96,7 +97,7 @@ get_user_configured_dump_disk()
return
fi
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf
2>/dev/null |awk '{print $2}')
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" $KDUMP_CONFIG_FILE
2>/dev/null |awk '{print $2}')
[ -n "$_target" ] && echo $_target
return
@@ -194,7 +195,7 @@ get_mntpoint_from_target()
# get_option_value <option_name>
# retrieves value of option defined in kdump.conf
get_option_value() {
- echo $(strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 |
cut -d\ -f2-`)
+ echo $(strip_comments `grep "^$1[[:space:]]\+" $KDUMP_CONFIG_FILE | tail -1
| cut -d\ -f2-`)
}
#This function compose a absolute path with the mount
@@ -369,7 +370,7 @@ is_wdt_mod_omitted() {
local dracut_args
local ret=1
- dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
+ dracut_args=$(grep "^dracut_args" $KDUMP_CONFIG_FILE)
[[ -z $dracut_args ]] && return $ret
eval set -- $dracut_args
@@ -392,7 +393,7 @@ is_wdt_mod_omitted() {
# its correctness).
is_mount_in_dracut_args()
{
- grep -q "^dracut_args .*\-\-mount" /etc/kdump.conf
+ grep -q "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE
}
# If $1 contains dracut_args "--mount", return <filesystem type>
diff --git a/kdumpctl b/kdumpctl
index e440bbb..4125454 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -173,7 +173,7 @@ check_kdump_cpus()
is_dump_to_rootfs()
{
- grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
+ grep "^default[[:space:]]dump_to_rootfs" $KDUMP_CONFIG_FILE >/dev/null
}
# This function performs a series of edits on the command line.
@@ -976,7 +976,7 @@ save_raw()
get_save_path()
{
- local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
+ local _save_path=$(grep "^path" $KDUMP_CONFIG_FILE|awk '{print $2}')
if [ -z "$_save_path" ]; then
_save_path="/var/crash"
fi
@@ -988,7 +988,7 @@ is_dump_target_configured()
{
local _target
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs"
/etc/kdump.conf)
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs"
$KDUMP_CONFIG_FILE)
[ -n "$_target" ]
}
@@ -997,7 +997,7 @@ local_fs_dump_target()
{
local _target
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf)
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" $KDUMP_CONFIG_FILE)
if [ $? -eq 0 ]; then
echo $_target|awk '{print $2}'
fi
diff --git a/mkdumprd b/mkdumprd
index 5a25853..75afd51 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -294,7 +294,7 @@ handle_default_dump_target()
get_default_action_target()
{
local _target
- local _action=$(grep "^default" /etc/kdump.conf 2>/dev/null | awk
'{print $2}')
+ local _action=$(grep "^default" $conf_file 2>/dev/null | awk '{print
$2}')
if [ -n "$_action" ] && [ "$_action" =
"dump_to_rootfs" ]; then
#get rootfs device name
_target=$(findmnt -k -f -n -o SOURCE /)
--
2.7.4