Bug 20745: koha-zebra doesn't return the correct error codes

This patch makes koha-zebra return 0 (or 1) even when verbose mode is
off. This made koha-zebra --start always return a failure even when the
daemon was correctly launched.

To test:
- Have Zebra running for kohadev instance on your KohaDevBox
- Run:
  $ sudo koha-zebra --stop kohadev && echo yay || echo doh
=> FAIL: 'doh' is printed
- Run:
  $ sudo koha-zebra --start kohadev e&& echo yay || echo doh
=> FAIL: 'doh' is printed as well
- Apply this patch
- Run:
  $ sudo perl misc4dev/cp_debian_files.pl
  $ sudo koha-zebra --stop kohadev && echo yay || echo doh
=> SUCCESS: 'yay' is printed
- Run:
  $ sudo koha-zebra --start kohadev e&& echo yay || echo doh
=> SUCCESS: 'yay' is printed
- Sign off :-D

Sponsored-by: ByWater Solutions

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomas Cohen Arazi 2018-05-10 12:37:53 -03:00 committed by Jonathan Druart
parent e3fd46d3dd
commit 6ea48ca934
1 changed files with 14 additions and 8 deletions

View File

@ -82,16 +82,18 @@ start_zebra()
log_daemon_msg "Starting Koha Zebra daemon for ${name}"
if daemon $DAEMONOPTS -- $ZEBRA_DAEMON $ZEBRA_PARAMS; then
[ "$verbose" != "no" ] && \
log_end_msg 0
([ "$verbose" != "no" ] && \
log_end_msg 0) || return 0
else
[ "$verbose" != "no" ] && \
log_end_msg 1
([ "$verbose" != "no" ] && \
log_end_msg 1) || return 1
fi
else
if [ "$verbose" != "no" ]; then
log_daemon_msg "Error: Zebra already running for ${name}"
log_end_msg 1
else
return 1
fi
fi
}
@ -115,16 +117,18 @@ stop_zebra()
log_daemon_msg "Stopping Koha Zebra daemon for ${name}"
if daemon $DAEMONOPTS --stop -- $ZEBRA_DAEMON $ZEBRA_PARAMS; then
[ "$verbose" != "no" ] && \
log_end_msg 0
([ "$verbose" != "no" ] && \
log_end_msg 0) || return 0
else
[ "$verbose" != "no" ] && \
log_end_msg 1
([ "$verbose" != "no" ] && \
log_end_msg 1) || return 1
fi
else
if [ "$verbose" != "no" ]; then
log_daemon_msg "Error: Zebra not running for ${name}"
log_end_msg 1
else
return 1
fi
fi
}
@ -142,6 +146,8 @@ restart_zebra()
if [ "$verbose" != "no" ]; then
log_daemon_msg "Error: Zebra not running for ${name}"
log_end_msg 1
else
return 1
fi
fi
}