ldb: make ldb a top level library for Samba 4.0
[kai/samba-autobuild/.git] / lib / ldb / tests / init_slapd.sh
1 #!/bin/sh 
2
3 if [ -z "$LDBDIR" ]; then
4     LDBDIR=`dirname $0`/..
5     export LDBDIR
6 fi
7
8 rm -rf tests/tmp/db
9 mkdir -p tests/tmp/db
10
11 if [ -f tests/tmp/slapd.pid ]; then
12     kill `cat tests/tmp/slapd.pid`
13     sleep 1
14 fi
15 if [ -f tests/tmp/slapd.pid ]; then
16     kill -9 `cat tests/tmp/slapd.pid`
17     rm -f tests/tmp/slapd.pid
18 fi
19
20 # we don't consider a slapadd failure as a test suite failure, as it
21 # has nothing to do with ldb
22
23 MODCONF=tests/tmp/modules.conf
24 rm -f $MODCONF
25 touch $MODCONF || exit 1
26
27 slaptest -u -f $LDBDIR/tests/slapd.conf > /dev/null 2>&1 || {
28  echo "enabling sladp modules"
29 cat > $MODCONF <<EOF
30 modulepath      /usr/lib/ldap
31 moduleload      back_bdb
32 EOF
33 }
34
35 slaptest -u -f $LDBDIR/tests/slapd.conf || {
36     echo "slaptest failed - skipping ldap tests"
37     exit 0
38 }
39
40 slapadd -f $LDBDIR/tests/slapd.conf < $LDBDIR/tests/init.ldif || exit 0
41