[kexec-tools] drcut-kdump.sh: cleanup kdump.conf check
Dave Young
yangrr at fedoraproject.org
Thu Jun 14 02:10:28 UTC 2012
commit 33d933f800e3e8f03a39e621a6fa4a94f061df6e
Author: Dave Young <dyoung at redhat.com>
Date: Thu Jun 14 09:55:54 2012 +0800
drcut-kdump.sh: cleanup kdump.conf check
move conf_file as a global variable to the top.
vivek: return earlier if kdump.conf is not found in read_kdump_conf to
avoid the deep indent.
Signed-off-by: Dave Young <dyoung at redhat.com>
Acked-by: Vivek Goyal <vgoyal at redhat.com>
dracut-kdump.sh | 115 ++++++++++++++++++++++++++++---------------------------
1 files changed, 59 insertions(+), 56 deletions(-)
---
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 3b60760..0baa8cc 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -13,6 +13,7 @@ KDUMP_SCRIPT_DIR="/kdumpscripts"
DD_BLKSIZE=512
FINAL_ACTION="reboot -f"
DUMP_RETVAL=0
+conf_file="/etc/kdump.conf"
export PATH=$PATH:$KDUMP_SCRIPT_DIR
@@ -124,63 +125,65 @@ dump_ssh()
read_kdump_conf()
{
- local conf_file="/etc/kdump.conf"
- if [ -f "$conf_file" ]; then
- # first get the necessary variables
- while read config_opt config_val;
- do
- case "$config_opt" in
- path)
- KDUMP_PATH="$config_val"
- ;;
- core_collector)
- [ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
- ;;
- sshkey)
- if [ -f "$config_val" ]; then
- SSH_KEY_LOCATION=$config_val
- fi
- ;;
- default)
- case $config_val in
- shell)
- DEFAULT_ACTION="sh -i -l"
- ;;
- reboot)
- DEFAULT_ACTION="reboot -f"
- ;;
- halt)
- DEFAULT_ACTION="halt -f"
- ;;
- poweroff)
- DEFAULT_ACTION="poweroff -f"
- ;;
- esac
- ;;
- esac
- done < $conf_file
-
- # rescan for add code for dump target
- while read config_opt config_val;
- do
- case "$config_opt" in
- ext[234]|xfs|btrfs|minix)
- add_dump_code "dump_localfs $config_val"
- ;;
- raw)
- add_dump_code "dump_raw $config_val"
- ;;
- net)
- wait_for_net_ok
- if [[ "$config_val" =~ "@" ]]; then
- add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
- else
- add_dump_code "dump_nfs $config_val"
- fi
- ;;
- esac
- done < $conf_file
+ if [ ! -f "$conf_file" ]; then
+ echo "$conf_file not found"
+ return
fi
+
+ # first get the necessary variables
+ while read config_opt config_val;
+ do
+ case "$config_opt" in
+ path)
+ KDUMP_PATH="$config_val"
+ ;;
+ core_collector)
+ [ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
+ ;;
+ sshkey)
+ if [ -f "$config_val" ]; then
+ SSH_KEY_LOCATION=$config_val
+ fi
+ ;;
+ default)
+ case $config_val in
+ shell)
+ DEFAULT_ACTION="sh -i -l"
+ ;;
+ reboot)
+ DEFAULT_ACTION="reboot -f"
+ ;;
+ halt)
+ DEFAULT_ACTION="halt -f"
+ ;;
+ poweroff)
+ DEFAULT_ACTION="poweroff -f"
+ ;;
+ esac
+ ;;
+ esac
+ done < $conf_file
+
+ # rescan for add code for dump target
+ while read config_opt config_val;
+ do
+ case "$config_opt" in
+ ext[234]|xfs|btrfs|minix)
+ add_dump_code "dump_localfs $config_val"
+ ;;
+ raw)
+ add_dump_code "dump_raw $config_val"
+ ;;
+ net)
+ wait_for_net_ok
+ if [[ "$config_val" =~ "@" ]]; then
+ add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
+ else
+ add_dump_code "dump_nfs $config_val"
+ fi
+ ;;
+ esac
+ done < $conf_file
}
read_kdump_conf
More information about the scm-commits
mailing list