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