Hide Forgot
Description of problem: Add /usr/sbin/status-dirsrv script to get the status of the directory server instance. Currently, we have these scripts :: /usr/sbin/start-dirsrv /usr/sbin/stop-dirsrv /usr/sbin/restart-dirsrv It is good to have status-dirsrv script which can give current status of directory server that is it started or stopped.
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune@redhat.com with any questions
Additional future. When one or more ns-slapd are down, the exit value or status-dirsrv shows the number of the down servers. Example: There are 3 DS instances are installed. 1) If all are up, $ status-dirsrv $ echo $? 0 2) If 2 is down, $ status-dirsrv $ echo $? 2 2) If all are down, $ status-dirsrv $ echo $? 3
^future^feature^
RFE Verified 1) [root@test slapd-test]# status-dirsrv gave detail information about status of Directory server and Instance 2) [root@test slapd-test]# status-dirsrv 'instance name' gave information about the instance 3) [root@test slapd-test]# man status-dirsrv show man page for this command 4) Check addition feature mention in comment 5 give result as mention
As mention in the Man page Exit code 255 is returned if the instance does not exist. but it return the 2 as exit code [root@rhel7ds ~]# status-dirsrv rhel7dssfsf Instance rhel7dssfsf not found. /usr/sbin/status-dirsrv: line 14: return: -1: invalid option return: usage: return [n] [root@rhel7ds ~]# echo $? 2
Can't reproduce the problem. # status-dirsrv rhel7dssfsf Instance rhel7dssfsf not found. # echo $? 255 Could you provide the output of "sh -x status-dirsrv rhel7dssfsf"? Thanks.
The error comes from bash built-in `return`. bash version prior to 4.3 didn't support negative numbers as argument for `return`. See for reference: http://wiki.bash-hackers.org/scripting/bashchanges reproducer.sh: #!/bin/bash set -x main() { return -1 } main echo $? On RHEL7 with bash-4.2.46-19.el7.x86_64: $ bash reproducer.sh + main + return -1 reproducer.sh: line 4: return: -1: invalid option return: usage: return [n] + echo 2 2 On Fedora24 with bash-4.3.42-5.fc24.x86_64: $ bash reproducer.sh + main + return -1 + echo 255 255 So in RHEL we need explicitly specify error code 255.
Agh... Thanks a lot, Viktor!
Bug Verified [root@test ~]# status-dirsrv test ● dirsrv@test.service - 389 Directory Server test. Loaded: loaded (/usr/lib/systemd/system/dirsrv@.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2016-07-18 14:16:51 IST; 1h 26min ago Main PID: 3836 (ns-slapd) Status: "slapd started: Ready to process requests" CGroup: /system.slice/system-dirsrv.slice/dirsrv@test.service └─3836 /usr/sbin/ns-slapd -D /etc/dirsrv/slapd-test -i /var/run/dirsrv/slapd-test.pid Jul 18 14:16:51 test.example.com systemd[1]: Starting 389 Directory Server test.... Jul 18 14:16:51 test.example.com ns-slapd[3836]: [18/Jul/2016:14:16:51.178734301 +051800] 389-Directory/1.3.5.10 B2016.197.39 starting up Jul 18 14:16:51 test.example.com ns-slapd[3836]: [18/Jul/2016:14:16:51.572105005 +051800] slapd started. Listening on All Interfaces port 389 for LDAP requests Jul 18 14:16:51 test.example.com systemd[1]: Started 389 Directory Server test.. [root@test ~]# echo $? 0 [root@test ~]# status-dirsrv NoInstace Instance NoInstace not found. [root@test ~]# echo $? 255
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2594.html