kdumpctl: cleanup 'stop'

Like for 'start' move the printing of the error message to the calling
function. This not only makes the code more consistent to 'start' but
also prevents 'kdumpctl restart' to call 'start' in case 'stop' has
failed. This doesn't impact the case when 'kdumpctl restart' is run
without any crash kernel being loaded as kexec will still return success
in that case.

Signed-off-by: Philipp Rudo <prudo@redhat.com>
Reviewed-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Philipp Rudo 2023-01-12 16:31:09 +01:00 committed by Coiby Xu
parent 33b307af20
commit 5eefcf2e94

View File

@ -1090,15 +1090,9 @@ reload_fadump()
stop() stop()
{ {
if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then
stop_fadump stop_fadump || return
else else
stop_kdump stop_kdump || return
fi
# shellcheck disable=SC2181
if [[ $? != 0 ]]; then
derror "Stopping kdump: [FAILED]"
return 1
fi fi
dinfo "Stopping kdump: [OK]" dinfo "Stopping kdump: [OK]"
@ -1683,7 +1677,10 @@ main()
fi fi
;; ;;
stop) stop)
stop if ! stop; then
derror "Stopping kdump: [FAILED]"
exit 1
fi
;; ;;
status) status)
EXIT_CODE=0 EXIT_CODE=0
@ -1704,7 +1701,10 @@ main()
reload reload
;; ;;
restart) restart)
stop if ! stop; then
derror "Stopping kdump: [FAILED]"
exit 1
fi
if ! start; then if ! start; then
derror "Starting kdump: [FAILED]" derror "Starting kdump: [FAILED]"
exit 1 exit 1