summaryrefslogtreecommitdiffstats
path: root/abs/core/openldap/slapd
blob: 4f212da66f8c2c8d546b135d79a43549a2ad4d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

[ -f "/etc/conf.d/slapd" ] && . /etc/conf.d/slapd

PID=`pidof -o %PPID /usr/sbin/slapd`
case "$1" in
  start)
    stat_busy "Starting OpenLDAP"
    [ ! -d /run/openldap ] && install -d -m755 -o ldap -g ldap /run/openldap
    if [ -z "$PID" ]; then
      if [ -z "$SLAPD_SERVICES" ]; then
        /usr/sbin/slapd -u ldap -g ldap $SLAPD_OPTIONS
      else
        /usr/sbin/slapd -u ldap -g ldap -h "$SLAPD_SERVICES" $SLAPD_OPTIONS
      fi
      if [ $? -gt 0 ]; then
        stat_fail
      else
        stat_done
      fi
      add_daemon slapd
    else
      stat_fail
    fi
    ;;
  stop)
    stat_busy "Stopping OpenLDAP"
    [ ! -z "$PID" ] && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm -f /run/openldap/slapd.pid
      rm -f /run/openldap/slapd.args
      rm_daemon slapd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0