Fix check-ldap slapd start race

We start slapd in the foreground (-d0) but backgrounded in the shell,
then we wait 4 seconds.  This causes a race condition however.  This
commit makes the slapd-init script more robust and limits the wait to
however many seconds (up to 30) that slapd needs to start service.
This commit is contained in:
Nicolas Williams
2018-12-27 13:32:46 -06:00
committed by Nico Williams
parent 65ed504d21
commit e93a135765

View File

@@ -44,5 +44,15 @@ cp "`which slapd`" . || true # fails if running
echo "starting slapd"
./slapd -d0 -f "${srcdir}/slapd.conf" -h ldapi://.%2Fldap-socket &
slapd_pid=$!
sleep 4
tries=0
while kill -0 $slapd_pid && [ ! -S ldap-socket ] &&
! ldapsearch -l 2 -w '' -D '' -b "o=TEST,dc=H5L,dc=SE" -s base -H ldapi://.%2Fldap-socket >/dev/null &&
[ $tries -lt 30 ]; do
sleep 1
tries=`expr 1 + $tries`
done
kill -0 $slapd_pid || exit 1
[ -S ldap-socket ] || exit 1