#!/bin/bash

#====================================================================
# Start/stop script for OpenLDAP (2.2 minimum)
# (http://www.openldap.org).
# Use BerkeleyDB utilities and save data in LDIF format.
# 
# chkconfig: 2345 27 73
# description: OpenLDAP
#
### BEGIN INIT INFO
# Provides:          slapd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $time
# Should-Stop:       $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: OpenLDAP
# Description:       OpenLDAP init script provided by LTB-project.org
### END INIT INFO
#
# Copyright (C) 2017 David COUTADEUR
# Copyright (C) 2008 Jonathan CLARKE
# Copyright (C) 2007 Olivier LI-KIANG-CHEONG
# Copyright (C) 2007 Thomas CHEMINEAU
# Copyright (C) 2005 Sebastien BAHLOUL 
# Copyright (C) 2005 Raphael OUAZANA 
# Copyright (C) 2005 Clement OUDOT
# Copyright (C) 2010 LTB-project.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# GPL License: http://www.gnu.org/licenses/gpl.txt
#
#====================================================================

#====================================================================
# Default parameters
#====================================================================
CLI_BIN="/usr/local/openldap/sbin/slapd-cli"

#====================================================================
# Action switch
#====================================================================
case $1 in
	start)
	exec ${CLI_BIN} start
	;;
	stop)
	exec ${CLI_BIN} stop
	;;
	forcestop)
	exec ${CLI_BIN} forcestop
	;;
	restart)
	exec ${CLI_BIN} restart
	;;
	debug)
	exec ${CLI_BIN} debug
	;;
	force-reload)
	exec ${CLI_BIN} force-reload
	;;
	status)
	exec ${CLI_BIN} status
	;;
	configtest)
	exec ${CLI_BIN} configtest
	;;
	*)
	echo "Usage: $0 {start|stop|forcestop|restart|debug|force-reload|status|configtest}"
	exit 1
	;;
esac

#====================================================================
# Exit
#====================================================================
exit $?


