This repository has been archived on 2024-11-07. You can view files and clone it, but cannot push or open issues or pull requests.
openldap25/openldap-initscript

84 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
#
# ldap This shell script takes care of starting and stopping ldap server (slapd).
#
# chkconfig: 2345 35 65
# description: LDAP stands for Lightweight Directory Access Protocol, used \
# for implementing the industry standard directory services.
# processname: slapd
# config: /etc/openldap/slapd.conf
# pidfile: /var/run/slapd.pid
# source function library
. /etc/init.d/functions
[ -x /usr/bin/db_recover-51 ] && DB_RECOVER=db_recover-51 || DB_RECOVER=db_recover
# source an auxiliary options file if we have one, and pick up OPTIONS,
# SLAPD_OPTIONS, and SLURPD_OPTIONS
[ -r /etc/sysconfig/ldap ] && . /etc/sysconfig/ldap
slapd=/usr/sbin/slapd
[ -x ${slapd} ] || exit 0
RETVAL=0
function start() {
# fix bdb errors
[ -e "/var/lib/ldap/openldap-data/__db.001" ] && \
$DB_RECOVER -h /var/lib/ldap/openldap-data
# start daemons
prog=`basename ${slapd}`
echo -n $"Starting $prog: "
if grep -q ^TLS /etc/openldap/slapd.conf; then
${slapd} -u ldap -h "ldaps:/// ldap:///" $OPTIONS $SLAPD_OPTIONS
else
${slapd} -u ldap $OPTIONS $SLAPD_OPTIONS
fi
evaluate_retval
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ldap
return $RETVAL
}
function stop() {
# stop daemons
prog=`basename ${slapd}`
echo -n $"Stopping $prog: "
killproc ${slapd}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] &&
rm -f /var/lock/subsys/ldap /var/run/ldap/slapd.args
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status ${slapd}
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/ldap ]; then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|status|condrestart}"
RETVAL=1
esac
exit $RETVAL