Commit 10c5c1c3 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ganeti.initd: Move code checking daemon exit code to daemon-util



This is again for re-using code.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent d2baa21d
......@@ -51,6 +51,29 @@ check_config() {
return 0
}
# Checks the exit code of a daemon
check_exitcode() {
if [[ "$#" -lt 1 ]]; then
echo 'Missing exit code.' >&2
return 1
fi
local rc="$1"; shift
case "$rc" in
0) ;;
11)
echo "not master"
;;
*)
echo "exit code $rc"
return 1
;;
esac
return 0
}
# Checks whether daemon is running
check() {
if [[ "$#" -lt 1 ]]; then
......
......@@ -29,17 +29,13 @@ test -f "@PREFIX@/sbin/$NODED" || exit 0
check_exitcode() {
RC=$1
case $RC in
0)
log_action_end_msg 0
;;
11)
log_action_end_msg 0 "not master"
;;
*)
log_action_end_msg 1 "exit code $RC"
;;
esac
if errmsg=$($DAEMON_UTIL check-exitcode $RC)
then
log_action_end_msg 0 "$errmsg"
else
log_action_end_msg 1 "$errmsg"
fi
}
start_action() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment