1#! /bin/sh
2# $OpenLDAP$
3## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4##
5## Copyright 1998-2021 The OpenLDAP Foundation.
6## All rights reserved.
7##
8## Redistribution and use in source and binary forms, with or without
9## modification, are permitted only as authorized by the OpenLDAP
10## Public License.
11##
12## A copy of this license is available in the file LICENSE in the
13## top-level directory of the distribution or, alternatively, at
14## <http://www.OpenLDAP.org/license.html>.
15
16echo "running defines.sh"
17. $SRCDIR/scripts/defines.sh
18
19mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
20
21$SLAPPASSWD -g -n >$CONFIGPWF
22echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
23
24echo "Starting slapd on TCP/IP port $PORT2..."
25. $CONFFILTER $BACKEND < $SCHEMACONF > $CONF2
26$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
27PID=$!
28if test $WAIT != 0 ; then
29    echo PID $PID
30    read foo
31fi
32KILLPIDS="$PID"
33
34echo "Starting a second slapd on TCP/IP port $PORT3..."
35sed -e "s,$DBDIR1,$DBDIR2," < $CONF2 > $CONF3
36$SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
37PID=$!
38if test $WAIT != 0 ; then
39    echo PID $PID
40    read foo
41fi
42KILLPIDS="$KILLPIDS $PID"
43
44echo "Starting a third slapd on TCP/IP port $PORT4..."
45sed -e "s,$DBDIR1,$DBDIR3," < $CONF2 > $CONF4
46$SLAPD -f $CONF4 -h $URI4 -d $LVL > $LOG4 2>&1 &
47PID=$!
48if test $WAIT != 0 ; then
49    echo PID $PID
50    read foo
51fi
52KILLPIDS="$KILLPIDS $PID"
53
54echo "Starting lloadd on TCP/IP port $PORT1..."
55. $CONFFILTER $BACKEND < $LLOADDANONCONF > $CONF1.lloadd
56if test $AC_lloadd = lloaddyes; then
57    $LLOADD -f $CONF1.lloadd -h $URI1 -d $LVL > $LOG1 2>&1 &
58else
59    . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd
60    # FIXME: this won't work on Windows, but lloadd doesn't support Windows yet
61    $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 &
62fi
63PID=$!
64if test $WAIT != 0 ; then
65    echo PID $PID
66    read foo
67fi
68KILLPIDS="$KILLPIDS $PID"
69
70sleep $SLEEP0
71
72echo "Using ldapsearch to retrieve the root DSE..."
73for i in 0 1 2 3 4 5; do
74    $LDAPSEARCH -b "" -s base -H $URI1 \
75        '@extensibleObject' > $SEARCHOUT 2>&1
76    RC=$?
77    if test $RC = 0 ; then
78        break
79    fi
80    echo "Waiting $SLEEP1 seconds for lloadd to start..."
81    sleep $SLEEP1
82done
83
84if test $RC = 0 ; then
85    echo "Using ldapsearch to retrieve the cn=Subschema..."
86    $LDAPSEARCH -b "cn=Subschema" -s base -H $URI1 \
87        '(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
88        >> $SEARCHOUT  2>&1
89    RC=$?
90
91fi
92
93if test $RC = 0 ; then
94    echo "Using ldapsearch to retrieve the cn=Monitor..."
95    $LDAPSEARCH -b "cn=Monitor" -s base -H $URI1 \
96        '@monitor' >> $SEARCHOUT 2>&1
97    RC=$?
98fi
99
100test $KILLSERVERS != no && kill -HUP $KILLPIDS
101
102count=3
103if test $RC != 0 ; then
104    echo ">>>>> Test failed"
105else
106    RC=`grep '^dn:' $SEARCHOUT | wc -l`
107    if test $RC != $count ; then
108        echo ">>>>> Test failed: expected $count entries, got" $RC
109        RC=1
110    else
111        echo ">>>>> Test succeeded"
112        RC=0
113    fi
114fi
115
116test $KILLSERVERS != no && wait
117
118exit $RC
119