#!/bin/sh # # ldap This shell script takes care of starting and stopping # ldap servers (slapd and slurpd). # # chkconfig: 345 39 61 # 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/ldap/slapd.pid # # Created by Christian Zoffoli <czoffoli@linux-mandrake.com> # Version 0.1b 2001-05-23 # # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi # Source an auxiliary options file if we have one, and pick up OPTIONS, # SLAPD_OPTIONS, and SLURPD_OPTIONS. if [ -r /etc/sysconfig/ldap ] ; then . /etc/sysconfig/ldap fi slapd=/usr/sbin/slapd slurpd=/usr/sbin/slurpd [ -x ${slapd} ] || exit 0 [ -x ${slurpd} ] || exit 0 check_slurpd() { if grep -q "^replogfile" /etc/openldap/slapd.conf; then return 0 fi return 1 } start() { local RETVAL=0 local RETVAL2=0 local ARGS="" # Start daemons. ARGS="-u ldap -g ldap" # Syslog if [ -n "$SLAPDSYSLOGLOCALUSER" ] ; then ARGS="$ARGS -l $SLAPDSYSLOGLOCALUSER" if [ -n "$SLAPDSYSLOGLEVEL" ] ; then ARGS="$ARGS -s $SLAPDSYSLOGLEVEL" fi fi OUT="ldap" if [ -n "$SLAPDURLLIST" ] ; then if gprintf "ldaps\n" && grep -q "^TLS" /etc/openldap/slapd.conf ; then ARGS="$ARGS -h \"$SLAPDURLLIST\"" OUT="ldap + ldaps" else ARGS="$ARGS -h \"ldap:/// \"" fi else ARGS="$ARGS -h \"ldap:/// \"" fi gprintf "Starting slapd (%s): " "$OUT" daemon ${slapd} $ARGS RETVAL=$? echo if [ $RETVAL -eq 0 ]; then if check_slurpd ; then gprintf "Starting slurpd: " daemon su ldap -c \"${slurpd}\" -s /bin/sh RETVAL2=$? echo fi fi [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/ldap || RETVAL=1 return $RETVAL } stop() { local RETVAL=0 local RETVAL2=0 # Stop daemons. gprintf "Stopping slapd: " killproc ${slapd} RETVAL=$? echo if [ $RETVAL -eq 0 ]; then if check_slurpd ; then gprintf "Stopping slurpd: " killproc ${slurpd} RETVAL2=$? echo fi fi [ $RETVAL -eq 0 -a $RETVAL2 -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} if check_slurpd ; then status ${slurpd} fi ;; restart) stop start ;; reload) killall -HUP ${slapd} RETVAL=$? if [ $RETVAL -eq 0 ]; then if check_slurpd ; then killall -HUP ${slurpd} RETVAL=$? fi fi ;; condrestart) if [ -f /var/lock/subsys/ldap ] ; then stop start fi ;; *) gprintf "Usage: %s {start|stop|restart|status|condrestart}\n" "$0" RETVAL=1 esac exit $RETVAL