From 6ea48ca9345862fc655e0ef418ea91d040ead03a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 10 May 2018 12:37:53 -0300 Subject: [PATCH] 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 Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- debian/scripts/koha-zebra | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/debian/scripts/koha-zebra b/debian/scripts/koha-zebra index 944e2e12a1..f6d2268c7e 100755 --- a/debian/scripts/koha-zebra +++ b/debian/scripts/koha-zebra @@ -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 } -- 2.39.5