#!/bin/sh
#
# slurpd	This shell script takes care of starting and stopping
#	       OpenLDAP replication servers (slurpd).
#
# chkconfig: 345 39 61
#
# description:	LDAP stands for Lightweight Directory Access Protocol, used
#               for implementing the industry standard directory services.
# processname: slurpd
#
# Version 3.1.1 for OpenLDAP 2.1.22
# (modify by vserge For ALT Linux Team Sisyphus)
#
# From version of this script 3.1.0 SLURPD removed to different script
#

WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
# Check that networking is up.
SourceIfNotEmpty /etc/sysconfig/network

# Source an auxiliary options file if we have one, and pick up OPTIONS,
# SLAPD_OPTIONS.
SourceIfNotEmpty /etc/sysconfig/ldap

SLURPD=/usr/sbin/slurpd
CONFIG=/etc/openldap/slapd.conf

[ -x "$SLURPD" -a -s "$CONFIG" ] || exit

PIDFILE=/var/run/slurpd.pid
RETVAL=0

start()
{
	is_yes "$NETWORKING" || return 0
	start_daemon --pidfile "$PIDFILE" $SLURPD $SLURPDURLLIST
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" $SLURPD
	RETVAL=$?
	return $RETVAL
}

reload()
{
	msg_reloading $SLURPD
	stop_daemon --pidfile "$PIDFILE" --expect-user root -HUP $SLURPD
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status --name slurpd --pidfile "$PIDFILE" --expect-user root $SLURPD
		RETVAL=$?
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	*)
		msg_usage "${0##*/} {start|stop|status|restart|condstop|condrestart}"
		RETVAL=1
esac

exit $RETVAL
