summaryrefslogtreecommitdiffstats
path: root/third_party/heimdal/tests/ldap/slapd-init.in
blob: f6e9fe93acac5ae9ddb4ad62ed30f89575714d10 (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
#!/bin/sh 
# $Id$

srcdir=@srcdir@

rm -rf db schema
mkdir db

# kill of old slapd if running
sh "${srcdir}/slapd-stop" > /dev/null

SCHEMA_NEEDED="hdb core nis cosine inetorgperson openldap samba"

SCHEMA_PATHS="${srcdir}/../../lib/hdb ${srcdir} /etc/ldap/schema /etc/openldap/schema /private/etc/openldap/schema /usr/share/openldap/schema"

test -d schema || mkdir schema

# setup needed schema files
for f in $SCHEMA_NEEDED; do
    if [ ! -r schema/$f.schema ]; then
	for d in $SCHEMA_PATHS ; do
	    if [ -r $d/$f.schema ] ; then
		cp $d/$f.schema schema/$f.schema
		continue 2
	    fi
	done
	echo "SKIPPING TESTS: you need the following schema file: $f.schema"
	exit 1
    fi
done

touch modules.conf || exit 1

if ! slapadd -d 0 -f "${srcdir}/slapd.conf" < "${srcdir}/init.ldif"; then
    echo "moduleload back_bdb.la"   >> modules.conf
    if ! slapadd -d 0 -f "${srcdir}/slapd.conf" < "${srcdir}/init.ldif"; then
        echo "modulepath /usr/lib/ldap"  > modules.conf
        echo "moduleload back_bdb.la"   >> modules.conf
        slapadd -d 0 -f "${srcdir}/slapd.conf" < "${srcdir}/init.ldif" || exit 1
    fi
fi

cp "`which slapd`" . || true # fails if running

echo "starting slapd"
./slapd -d0 -f "${srcdir}/slapd.conf" -h ldapi://.%2Fldap-socket &
slapd_pid=$!

tries=0
while kill -0 $slapd_pid && [ ! -S ldap-socket ] && 
      ! ldapsearch -l 2 -w '' -D '' -b "o=TEST,dc=H5L,dc=SE" -s base -H ldapi://.%2Fldap-socket >/dev/null &&
      [ $tries -lt 30 ]; do
    sleep 1
    tries=`expr 1 + $tries`
done

kill -0 $slapd_pid || exit 1
[ -S ldap-socket ] || exit 1