aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/openldap/files/initscript
blob: f9c343a37d45991c40c512a56fc4246a06467146 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/sh
#
# This is an init script for openembedded
# Copy it to /etc/init.d/openldap and type
# > update-rc.d openldap defaults 60
#


slapd=/usr/libexec/slapd
test -x "$slapd" || exit 0

src_data_dir=/etc/openldap/
data_dir=%LDAP_DATADIR%
pidfile=%LDAP_DATADIR%/slapd.pid

start()
{
	need_init=0
	if [ ! -e $data_dir/DB_CONFIG ]; then
		cp $src_data_dir/DB_CONFIG.example $data_dir/DB_CONFIG
		need_init=1
	fi
	echo -n "Starting OpenLDAP: "
	start-stop-daemon --start --quiet --exec $slapd
	echo "."

	if [ $need_init -eq 1 ]; then
		sleep 1
		ldapadd -x -D "cn=Manager,%DEFAULT_DN%" -w secret -f /etc/openldap/ops-base.ldif -c
	fi
}

stop()
{
	echo -n "Stopping OpenLDAP: "
	start-stop-daemon --stop --quiet --pidfile $pidfile
	echo "."
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  reset)
    stop
    sleep 1
    rm $data_dir/*
    start
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: /etc/init.d/openldap {start|stop|reset|restart|reset}"
    exit 1
esac

exit 0