Browse Source

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.

https://fedorahosted.org/389/ticket/48144

Reviewed by [email protected] (Thank you, Mark!)
Noriko Hosoi 9 years ago
parent
commit
6ec814a0e5
2 changed files with 7 additions and 9 deletions
  1. 4 6
      ldap/admin/src/scripts/status-dirsrv.in
  2. 3 3
      man/man8/status-dirsrv.8

+ 4 - 6
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 @[email protected]
     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

+ 3 - 3
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.