Browse Source

Ticket #48144 - Add /usr/sbin/status-dirsrv script to get the status of the directory server instance.

Description: New script status-dirsrv and its man page status-dirsrv.8 was
missing in commit 44333d1ae7d619fe800ef9a8d8550d2fdcf7c553.
Noriko Hosoi 10 years ago
parent
commit
6566d89d97
2 changed files with 142 additions and 0 deletions
  1. 87 0
      ldap/admin/src/scripts/status-dirsrv.in
  2. 55 0
      man/man8/status-dirsrv.8

+ 87 - 0
ldap/admin/src/scripts/status-dirsrv.in

@@ -0,0 +1,87 @@
+#!/bin/sh
+
+# Script that reports the status of the ns-slapd server.
+
+. @datadir@/@package_name@/data/DSSharedLib
+
+# Get the status of a single instance
+status_instance() {
+    # The first argument is the server ID.  Anything
+    # after that is an argument to ns-slapd.
+    SERV_ID=$1
+    shift
+
+    initfile=`get_init_file $initconfig_dir $SERV_ID` || { echo Instance $SERV_ID not found. ; return -1 ; }
+
+    # source env. for this instance
+    if [ -f $initfile ] ; then
+        . $initfile
+    else
+        echo Instance $SERV_ID not found.
+        return -1
+    fi
+
+    prefix="$DS_ROOT"
+
+    libpath_add "$prefix$SERVER_DIR"
+    libpath_add "$prefix@nss_libdir@"
+    libpath_add "$prefix@libdir@"
+    libpath_add "@nss_libdir@"
+    libpath_add "$prefix@pcre_libdir@"
+
+    export LD_LIBRARY_PATH
+    SHLIB_PATH=$LD_LIBRARY_PATH
+    export SHLIB_PATH
+
+    #
+    # Use systemctl if available.
+    #
+    if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
+        @bindir@/systemctl status @package_name@@$SERV_ID.service
+        rv=$?
+        if [ $rv -ne 0 ]; then
+            return $rv
+        fi
+    fi
+    return 0
+}
+
+# source env. for all instances
+[ -f @initconfigdir@/@package_name@ ] && . @initconfigdir@/@package_name@
+
+while getopts "d:" flag
+do
+    case "$flag" in
+        d) initconfig_dir="$OPTARG";;
+    esac
+done
+shift $(($OPTIND-1))
+
+if [ -z "$initconfig_dir" ]; then
+    initconfig_dir=@initconfigdir@
+fi
+
+found=0
+if [ $# -eq 0 ]; then
+    # We're reporting the status of all instances.
+    ret=-1
+    @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
+        inst=`normalize_server_id $i`
+        echo Status of instance \"$inst\"
+        status_instance $inst
+        rv=$?
+        #if one of them is successful, return 0.
+        if [ $ret -gt -1 ]; then
+            ret=`expr $ret \& $rv`
+        else
+            ret=$rv
+        fi
+    done
+    exit $ret
+else
+    # We're getting the status of a single instance.
+    status_instance $@
+    exit $?
+fi

+ 55 - 0
man/man8/status-dirsrv.8

@@ -0,0 +1,55 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH STATUS-DIRSRV 8 "Jan 20, 2016"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+status-dirsrv \- script for showing the status of Directory Server
+.SH SYNOPSIS
+.B status-dirsrv
+.RI [\fI<instance>\fR]
+.SH DESCRIPTION
+status-dirsrv shows all the status of Directory Server instances on a system, or
+of a single instance if specified
+.PP
+.\" TeX users may be more comfortable with the \fB<whatever>\fP and
+.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
+.\" respectively.
+.SH OPTIONS
+.TP
+.B <instance>
+Specifies a single Directory Server instance to show the status
+.br
+.SH USAGE
+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.
+
+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.
+.br
+.SH AUTHOR
+status\-dirsrv was written by the 389 Project.
+.SH "REPORTING BUGS"
+Report bugs to https://fedorahosted.org/389/newticket.
+.SH COPYRIGHT
+Copyright \(co 2016 Red Hat, Inc.
+.br
+This is free software.  You may redistribute copies of it under the terms of
+the Directory Server license found in the LICENSE file of this
+software distribution.  This license is essentially the GNU General Public
+License version 2 with an exception for plug-in distribution.