[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: SYSV initscript for slapd (ITS#548)



You might want to try this one, which is a modified version of the Debian
GNU/Linux script. Note, "killall" is not very portable outside of the
Linux expected usage, so change that for outside of this. The special
thing about this version is that it will start slurpd if there are any
replicas defined.

Ben

#! /bin/sh
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Debian by Christoph Lameter <clameter@debian.org>
# Modified for OpenLDAP by Ben Collins <bcollins@debian.org>

PATH=/bin:/usr/bin:/sbin:/usr/sbin
SLAPD=/usr/sbin/slapd
SLURPD=/usr/sbin/slurpd

pidfile=`grep ^pidfile /etc/openldap/slapd.conf | awk '{print $2}'`
if [ -z "$pidfile" ]; then
    pidfile="/var/run/slapd.pid"
fi

test -x $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting ldap server(s):"
    echo -n " slapd"
    $SLAPD
    replicas=`grep ^replica /etc/openldap/slapd.conf`
    test -z "$replicas" || (echo -n " slurpd" && $SLURPD)
    echo "."
    ;;
  stop)
    echo -n "Stopping ldap server(s):"
    echo -n " slapd"
    if [ -f "$pidfile" ]; then
        kill `cat /var/run/slapd.pid` > /dev/null 2>&1
    fi
    replicas=`grep ^replica /etc/openldap/slapd.conf`
    test -z "$replicas" || (echo -n " slurpd" && killall slurpd > /dev/null 2>&1)
    echo "."
    ;;
  restart|force-reload)
    echo "Restarting ldap server(s):"
    echo -n "  "
    $0 stop
    sleep 2 # give it some time to die
    echo -n "  "
    $0 start
    ;;
  force-stop)
    echo -n "Stopping ldap servers (force): "
    killall slapd slurpd > /dev/null 2>&1
    echo "done."
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-stop}"
    exit 1
    ;;
esac

exit 0

-- 
 -----------=======-=-======-=========-----------=====------------=-=------
/  Ben Collins  --  ...on that fantastic voyage...  --  Debian GNU/Linux   \
`  bcollins@debian.org  --  bcollins@openldap.org  --  bcollins@linux.com  '
 `---=========------=======-------------=-=-----=-===-======-------=--=---'