#!/bin/bash
# Begin $rc_base/init.d/openldap

# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans  - gerard@linuxfromscratch.org

#$LastChangedBy: bdubbs $
#$Date: 2006-09-10 19:41:47 -0500 (Sun, 10 Sep 2006) $

. /etc/sysconfig/rc
. $rc_functions

pid_file=/srv/ldap/run/slapd.pid

case "$1" in
	start)
		boot_mesg "Starting LDAP slapd Server..."
		PIDFILE="/srv/ldap/run/slapd.pid"
		loadproc /usr/sbin/slapd
		# Return PIDFILE to null (for slurpd)
		PIDFILE=""

		boot_mesg "Starting LDAP slurpd Server..."
		loadproc /usr/sbin/slurpd                                        
		;;

	stop)
		boot_mesg "Stopping LDAP slapd Server..."
		PIDFILE="/srv/ldap/run/slapd.pid"
		# slapd needs SIGINT
		killproc -p ${PIDFILE} /usr/sbin/slapd INT

		# return PIDFILE to nothing for slurpd
		PIDFILE=""

		boot_mesg "Stopping LDAP slurpd Server..."
		killproc /usr/sbin/slurpd
		;;

	restart)
		$0 stop
		sleep 1
		$0 start
		;;

	status)
		statusproc /usr/sbin/slapd
		statusproc /usr/sbin/slurpd
		;;

	*)
		echo "Usage: $0 {start|stop|restart|status}"
		exit 1
		;;
esac

# End $rc_base/init.d/openldap
