xref: /netbsd-src/crypto/external/bsd/heimdal/dist/tests/ldap/slapd-init.in (revision b9d004c6cc8d38329417ae29768c81e5f2a296cf)
1#!/bin/sh
2# Id
3
4srcdir=@srcdir@
5
6rm -rf db schema
7mkdir db
8
9# kill of old slapd if running
10sh "${srcdir}/slapd-stop" > /dev/null
11
12SCHEMA_NEEDED="hdb core nis cosine inetorgperson openldap samba"
13
14SCHEMA_PATHS="${srcdir}/../../lib/hdb ${srcdir} /etc/ldap/schema /etc/openldap/schema /private/etc/openldap/schema /usr/share/openldap/schema"
15
16test -d schema || mkdir schema
17
18# setup needed schema files
19for f in $SCHEMA_NEEDED; do
20    if [ ! -r schema/$f.schema ]; then
21	for d in $SCHEMA_PATHS ; do
22	    if [ -r $d/$f.schema ] ; then
23		cp $d/$f.schema schema/$f.schema
24		continue 2
25	    fi
26	done
27	echo "SKIPPING TESTS: you need the following schema file: $f.schema"
28	exit 1
29    fi
30done
31
32touch modules.conf || exit 1
33
34if ! slapadd -d 0 -f "${srcdir}/slapd.conf" < "${srcdir}/init.ldif"; then
35    echo "moduleload back_bdb.la"   >> modules.conf
36    if ! slapadd -d 0 -f "${srcdir}/slapd.conf" < "${srcdir}/init.ldif"; then
37        echo "modulepath /usr/lib/ldap"  > modules.conf
38        echo "moduleload back_bdb.la"   >> modules.conf
39        slapadd -d 0 -f "${srcdir}/slapd.conf" < "${srcdir}/init.ldif" || exit 1
40    fi
41fi
42
43cp "`which slapd`" . || true # fails if running
44
45echo "starting slapd"
46./slapd -d0 -f "${srcdir}/slapd.conf" -h ldapi://.%2Fldap-socket &
47
48sleep 4
49