Bug 20745: koha-zebra doesn't return the correct error codes
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 10 May 2018 15:37:53 +0000 (12:37 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 11 May 2018 13:52:44 +0000 (10:52 -0300)
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>

debian/scripts/koha-zebra

index 944e2e1..f6d2268 100755 (executable)
@@ -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
 }