Here is the proposed patch:
(l)mathiaz@mathiaz-srv:~/src/openldap/pkg-branches/lucid.dev/debian$ bzr diff --old ../../lucid/ slapd.init === modified file 'debian/slapd.init' --- debian/slapd.init 2009-08-11 14:48:56 +0000 +++ debian/slapd.init 2010-04-12 23:21:40 +0000 @@ -189,6 +189,27 @@ echo . }
+# Check OpenLDAP status +status_slapd() { + # No PID + if [ ! -f $SLAPD_PIDFILE ]; then + echo "OpenLDAP is NOT running" + exit 3 + fi + + # Bogus PID + for pid in $(cat $SLAPD_PIDFILE) ; do + if ! ps --noheaders p "$pid" | grep $SLAPD > /dev/null ; then + echo "OpenLDAP is NOT running, bogus pidfile found: '$SLAPD_PIDFILE'" + exit 1 + fi + done + + # Running PID + echo "OpenLDAP is running" + exit 0 +} + case "$1" in start) check_for_no_start @@ -200,8 +221,10 @@ stop_ldap start_ldap ;; + status) + status_slapd ;; *) - echo "Usage: $0 {start|stop|restart|force-reload}" + echo "Usage: $0 {start|stop|restart|force-reload|status}" exit 1 ;; esac
Here is the proposed patch:
(l)mathiaz@ mathiaz- srv:~/src/ openldap/ pkg-branches/ lucid.dev/ debian$ bzr diff --old ../../lucid/ slapd.init
=== modified file 'debian/slapd.init'
--- debian/slapd.init 2009-08-11 14:48:56 +0000
+++ debian/slapd.init 2010-04-12 23:21:40 +0000
@@ -189,6 +189,27 @@
echo .
}
+# Check OpenLDAP status
check_ for_no_ start stop|restart| force-reload} " stop|restart| force-reload| status} "
+status_slapd() {
+ # No PID
+ if [ ! -f $SLAPD_PIDFILE ]; then
+ echo "OpenLDAP is NOT running"
+ exit 3
+ fi
+
+ # Bogus PID
+ for pid in $(cat $SLAPD_PIDFILE) ; do
+ if ! ps --noheaders p "$pid" | grep $SLAPD > /dev/null ; then
+ echo "OpenLDAP is NOT running, bogus pidfile found: '$SLAPD_PIDFILE'"
+ exit 1
+ fi
+ done
+
+ # Running PID
+ echo "OpenLDAP is running"
+ exit 0
+}
+
case "$1" in
start)
@@ -200,8 +221,10 @@
stop_ldap
start_ldap
;;
+ status)
+ status_slapd ;;
*)
- echo "Usage: $0 {start|
+ echo "Usage: $0 {start|
exit 1
;;
esac