kdumpctl: status function cleanup
Move the code to check /sys/kernel/kexec_crash_loaded to function check_kdump_feasibility(). And rename status() to check_current_kdump_status() so these two functions become clearer. cleanup kdumpctl status path as well. Tested with kernel without CONFIG_KEXEC Tested with run kdumpctl start two times. Signed-off-by: Dave Young <dyoung@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
afff4dc8a3
commit
d802c3a1df
27
kdumpctl
27
kdumpctl
@ -384,12 +384,8 @@ function propagate_ssh_key()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function status()
|
function check_current_kdump_status()
|
||||||
{
|
{
|
||||||
if [ ! -e /sys/kernel/kexec_crash_loaded ]
|
|
||||||
then
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
rc=`cat /sys/kernel/kexec_crash_loaded`
|
rc=`cat /sys/kernel/kexec_crash_loaded`
|
||||||
if [ $rc == 1 ]; then
|
if [ $rc == 1 ]; then
|
||||||
return 0
|
return 0
|
||||||
@ -535,6 +531,11 @@ function check_kdump_feasibility()
|
|||||||
echo "Secure Boot is Enabled. Kdump service can't be started. Disable Secure Boot and retry"
|
echo "Secure Boot is Enabled. Kdump service can't be started. Disable Secure Boot and retry"
|
||||||
return 1;
|
return 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -e /sys/kernel/kexec_crash_loaded ]; then
|
||||||
|
echo "Kdump is not supported on this kernel"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function start()
|
function start()
|
||||||
@ -560,17 +561,11 @@ function start()
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
status
|
check_current_kdump_status
|
||||||
rc=$?
|
if [ $? == 0 ]; then
|
||||||
if [ $rc == 2 ]; then
|
|
||||||
echo "Kdump is not supported on this kernel: [WARNING]"
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
if [ $rc == 0 ]; then
|
|
||||||
echo "Kdump already running: [WARNING]"
|
echo "Kdump already running: [WARNING]"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
if check_ssh_config; then
|
if check_ssh_config; then
|
||||||
if ! check_ssh_target; then
|
if ! check_ssh_target; then
|
||||||
@ -628,7 +623,7 @@ main ()
|
|||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
status
|
check_current_kdump_status
|
||||||
case "$?" in
|
case "$?" in
|
||||||
0)
|
0)
|
||||||
echo "Kdump is operational"
|
echo "Kdump is operational"
|
||||||
@ -638,10 +633,6 @@ main ()
|
|||||||
echo "Kdump is not operational"
|
echo "Kdump is not operational"
|
||||||
EXIT_CODE=3
|
EXIT_CODE=3
|
||||||
;;
|
;;
|
||||||
2)
|
|
||||||
echo "Kdump is unsupported on this kernel"
|
|
||||||
EXIT_CODE=3
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
exit $EXIT_CODE
|
exit $EXIT_CODE
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user