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 and also consolidates
these MACRO names primarily to kdump-lib.sh
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
dracut-kdump.sh | 7 ++++---
dracut-module-setup.sh | 8 ++++----
kdump-lib-initramfs.sh | 3 +--
kdump-lib.sh | 21 +++++++++++----------
kdumpctl | 9 ++++-----
mkdumprd | 13 ++++++-------
6 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b75c2a5ac1e7..3f686bd9af64 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -7,6 +7,7 @@ fi
exec &> /dev/console
. /lib/dracut-lib.sh
+. /lib/kdump-lib.sh
. /lib/kdump-lib-initramfs.sh
set -o pipefail
@@ -133,8 +134,8 @@ get_host_ip()
read_kdump_conf()
{
- if [ ! -f "$KDUMP_CONF" ]; then
- echo "kdump: $KDUMP_CONF not found"
+ if [ ! -f "$KDUMP_CONFIG_FILE" ]; then
+ echo "kdump: $KDUMP_CONFIG_FILE not found"
return
fi
@@ -160,7 +161,7 @@ read_kdump_conf()
add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
;;
esac
- done < $KDUMP_CONF
+ done < $KDUMP_CONFIG_FILE
}
fence_kdump_notify()
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 9f88b4edaf7a..d466e1ead5be 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -10,7 +10,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 +439,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 +472,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-initramfs.sh b/kdump-lib-initramfs.sh
index 2c18c8703fe3..99f5517575b4 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -14,7 +14,6 @@ SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
KDUMP_SCRIPT_DIR="/kdumpscripts"
DD_BLKSIZE=512
FINAL_ACTION="systemctl reboot -f"
-KDUMP_CONF="/etc/kdump.conf"
KDUMP_PRE=""
KDUMP_POST=""
NEWROOT="/sysroot"
@@ -71,7 +70,7 @@ get_kdump_confs()
esac
;;
esac
- done < $KDUMP_CONF
+ done < $KDUMP_CONFIG_FILE
if [ -z "$CORE_COLLECTOR" ]; then
CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 8ebad70d8d92..f8b040977384 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 e440bbbd8af4..a133e986e019 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -4,7 +4,6 @@ KEXEC=/sbin/kexec
KDUMP_KERNELVER=""
KDUMP_COMMANDLINE=""
KEXEC_ARGS=""
-KDUMP_CONFIG_FILE="/etc/kdump.conf"
MKDUMPRD="/sbin/mkdumprd -f"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
@@ -173,7 +172,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 +975,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 +987,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 +996,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 5a25853d0f3d..d2bb70f50728 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -11,9 +11,8 @@
. /lib/kdump/kdump-lib.sh
export IN_KDUMP=1
-conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
+SAVE_PATH=$(grep ^path $KDUMP_CONFIG_FILE| cut -d' ' -f2)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
# strip the duplicated "/"
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
@@ -228,7 +227,7 @@ check_size() {
# $1: core_collector config value
verify_core_collector() {
- if grep -q "^raw" $conf_file && [ "${1%% *}" !=
"makedumpfile" ]; then
+ if grep -q "^raw" $KDUMP_CONFIG_FILE && [ "${1%% *}" !=
"makedumpfile" ]; then
echo "Warning: specifying a non-makedumpfile core collector, you will have
to recover the vmcore manually."
fi
if is_ssh_dump_target || is_raw_dump_target; then
@@ -294,7 +293,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" $KDUMP_CONFIG_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 /)
@@ -307,7 +306,7 @@ get_override_resettable()
{
local override_resettable
- override_resettable=$(grep "^override_resettable" $conf_file)
+ override_resettable=$(grep "^override_resettable" $KDUMP_CONFIG_FILE)
if [ -n "$override_resettable" ]; then
OVERRIDE_RESETTABLE=$(echo $override_resettable | cut -d' ' -f2)
if [ "$OVERRIDE_RESETTABLE" != "0" ] && [
"$OVERRIDE_RESETTABLE" != "1" ];then
@@ -423,7 +422,7 @@ if ! check_crypt; then
fi
# firstly get right SSH_KEY_LOCATION
-keyfile=$(awk '/^sshkey/ {print $2}' $conf_file)
+keyfile=$(awk '/^sshkey/ {print $2}' $KDUMP_CONFIG_FILE)
if [ -f "$keyfile" ]; then
# canonicalize the path
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
@@ -494,7 +493,7 @@ do
fi
;;
esac
-done < $conf_file
+done < $KDUMP_CONFIG_FILE
handle_default_dump_target
--
2.7.4