]> git.sur5r.net Git - openldap/blob - tests/scripts/start-master
Update test suite
[openldap] / tests / scripts / start-master
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8 BACKEND=ldbm
9 if test $# -ge 1 ; then
10         BACKEND=$1; shift
11 fi
12
13 echo "running defines.sh"
14 . $SRCDIR/scripts/defines.sh
15
16 echo "Datadir is $DATADIR"
17
18 echo "Cleaning up in $DBDIR..."
19
20 rm -f $DBDIR/[!C]*
21
22 echo "Running slapadd to build slapd database..."
23 . $CONFFILTER $BACKEND < $CONF > $ADDCONF
24 $SLAPADD -f $ADDCONF -l $LDIFORDERED
25 RC=$?
26 if test $RC != 0 ; then
27         echo "slapadd failed ($RC)!"
28         exit $RC
29 fi
30
31 echo "Starting slapd on TCP/IP port $PORT..."
32 . $CONFFILTER $BACKEND < $CONF > $DBCONF
33 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
34 PID=$!
35
36 echo "Using ldapsearch to retrieve all the entries..."
37 for i in 0 1 2 3 4 5; do
38         $LDAPSEARCH -S "" -b "$BASEDN" -h localhost:$PORT > $SEARCHOUT 2>&1
39         RC=$?
40         if test $RC = 1 ; then
41                 echo "Waiting 5 seconds for slapd to start..."
42                 sleep 5
43         fi
44 done
45
46 # kill -HUP $PID
47
48 if test $RC != 0 ; then
49         echo "ldapsearch failed ($RC)!"
50         exit $RC
51 fi
52
53 echo "Filtering ldapsearch results..."
54 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
55 echo "Filtering original ldif used to create database..."
56 . $LDIFFILTER < $LDIF > $LDIFFLT
57 echo "Comparing filter output..."
58 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
59
60 if test $? != 0 ; then
61         echo "comparison failed - database was not created correctly"
62         exit 1
63 fi
64
65 echo ">>>>> Master (pid=$PID) started"
66
67
68 exit 0