While trying to configure a Multi-Master OpenLDAP cluster on top of
Corosync/Pacemaker I noticed that the default slapd init script
packaged with slapd in Lucid (2.4.21-0ubuntu3) doesn't contain a
status function. I'm currently using the standard LSB function with
slapd Corosync/Pacemaker, perhaps I create an OCF compatible script in
the near future.

For now the attached path shows some basic status info with LSB
compatible exit codes.
--- slapd	2010-03-29 16:02:52.000000000 +0200
+++ slapd.status	2010-04-04 00:13:14.924948045 +0200
@@ -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
-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

Reply via email to