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@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
16e24a1197
commit
33d933f800
115
dracut-kdump.sh
115
dracut-kdump.sh
@ -13,6 +13,7 @@ KDUMP_SCRIPT_DIR="/kdumpscripts"
|
|||||||
DD_BLKSIZE=512
|
DD_BLKSIZE=512
|
||||||
FINAL_ACTION="reboot -f"
|
FINAL_ACTION="reboot -f"
|
||||||
DUMP_RETVAL=0
|
DUMP_RETVAL=0
|
||||||
|
conf_file="/etc/kdump.conf"
|
||||||
|
|
||||||
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
||||||
|
|
||||||
@ -124,63 +125,65 @@ dump_ssh()
|
|||||||
|
|
||||||
read_kdump_conf()
|
read_kdump_conf()
|
||||||
{
|
{
|
||||||
local conf_file="/etc/kdump.conf"
|
if [ ! -f "$conf_file" ]; then
|
||||||
if [ -f "$conf_file" ]; then
|
echo "$conf_file not found"
|
||||||
# first get the necessary variables
|
return
|
||||||
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
|
|
||||||
fi
|
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
|
read_kdump_conf
|
||||||
|
Loading…
Reference in New Issue
Block a user