#!/bin/bash # # slapd This shell script takes care of starting and stopping # ldap servers (slapd and slurpd). # # chkconfig: 345 70 30 # description: Start and stop the LDAP servers. LDAP stands for \ # Lightweight Directory Access Protocol, used for \ # implementing the industry standard directory services. # description(fr): Demarre et arrete le demon slapd # processname: slapd # config: /etc/openldap/slapd.conf # pidfile: /var/run/slapd.pid # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -f /usr/sbin/slapd ] || exit 0 [ -f /usr/sbin/slurpd ] || exit 0 # Source function library. . /etc/rc.d/init.d/functions RETVAL=0 # See how we were called. case "$1" in start) # Start daemons echo -n "Starting slapd daemon: " daemon slapd RETVAL=$? if [ $RETVAL -eq 0 ]; then if grep -q "^replica" /etc/openldap/slapd.conf; then echo echo -n "Starting slurpd daemon: " daemon slurpd -t /var/lib/openldap RETVAL=$? [ $RETVAL -eq 0 ] && pidof slurpd | cut -f 1 -d " " > /var/run/slurpd fi fi echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/slapd ;; stop) # Stop daemons echo -n "Shutting down slapd daemon: " killproc slapd RETVAL=$? if [ $RETVAL -eq 0 ]; then if grep -q "^replica" /etc/openldap/slapd.conf; then echo echo -n "Shutting down slurpd daemon: " killproc slurpd RETVAL=$? fi fi echo if [ $RETVAL -eq 0 ]; then rm -f /var/lock/subsys/slapd rm -f /var/run/openldap/slapd.args fi ;; restart) $0 stop $0 start RETVAL=$? ;; reload) killproc -HUP slapd RETVAL=$? if [ $RETVAL -eq 0 ]; then if grep -q "^replica" /etc/openldap/slapd.conf; then killproc -HUP slurpd RETVAL=$? fi fi ;; status) status slapd RETVAL=$? if [ $RETVAL -eq 0 ]; then if grep -q "^replica" /etc/openldap/slapd.conf; then status slurpd RETVAL=$? fi fi ;; *) echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 ;; esac exit $RETVAL