From 60f042f457a725521bfa916c9a9a9b5257586684 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Fri, 6 May 2016 13:15:35 -0700
Subject: [PATCH] Ticket #48144 - Add /usr/sbin/status-dirsrv script to get the
 status of the directory server instance.

Description: Additional feature for the return value/exit status.
EXIT STATUS
  status-dirsrv returns 0 if all Directory Server instances are running.
  Otherwise, it returns a positive value which represents the number of
  server instances which are not running.

  If a single Directory Server instance is specified, 0 is returned if
  the instance is running; 1 is returned if the instance is not running;
  255 is returned if the instance does not exist.
---
 ldap/admin/src/scripts/status-dirsrv.in | 10 ++++------
 man/man8/status-dirsrv.8                |  6 +++---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/ldap/admin/src/scripts/status-dirsrv.in b/ldap/admin/src/scripts/status-dirsrv.in
index 02fcc0d..0f01eaa 100755
--- a/ldap/admin/src/scripts/status-dirsrv.in
+++ b/ldap/admin/src/scripts/status-dirsrv.in
@@ -40,7 +40,7 @@ status_instance() {
         @bindir@/systemctl status @package_name@@$SERV_ID.service
         rv=$?
         if [ $rv -ne 0 ]; then
-            return $rv
+            return 1
         fi
     fi
     return 0
@@ -64,7 +64,7 @@ fi
 found=0
 if [ $# -eq 0 ]; then
     # We're reporting the status of all instances.
-    ret=-1
+    ret=0
     @bindir@/systemctl status @package_name@.target
     initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
     for i in $initfiles; do
@@ -73,10 +73,8 @@ if [ $# -eq 0 ]; then
         status_instance $inst
         rv=$?
         #if one of them is successful, return 0.
-        if [ $ret -gt -1 ]; then
-            ret=`expr $ret \& $rv`
-        else
-            ret=$rv
+        if [ $rv -ne 0 ]; then
+            ret=`expr $ret + 1`
         fi
     done
     exit $ret
diff --git a/man/man8/status-dirsrv.8 b/man/man8/status-dirsrv.8
index 0198670..83844b3 100644
--- a/man/man8/status-dirsrv.8
+++ b/man/man8/status-dirsrv.8
@@ -37,10 +37,10 @@ Sample usage:
 .TP
 .B status-dirsrv example
 .br
-.SH EXIST STATUS
-status-dirsrv returns 0 if all Directory Server instances are running.  Otherwise, a non-zero failure code returned from systemctl is returned.
+.SH EXIT STATUS
+status-dirsrv returns 0 if all Directory Server instances are running.  Otherwise, it returns a positive value which represents the number of server instances which are not running.
 
-If a single Directory Server instance is specified, 0 is returned if the instance is running; a non-zero failure code returned from systemctl is returned if the instance is not running; 255 is returned if the instance does not exist.
+If a single Directory Server instance is specified, 0 is returned if the instance is running; 1 is returned if the instance is not running; 255 is returned if the instance does not exist.
 .br
 .SH AUTHOR
 status\-dirsrv was written by the 389 Project.
-- 
2.4.11

