#!/bin/sh

exec 2>&1
set -eux

echo -n "slapd slapd/password1 password testpwd" | debconf-set-selections
echo -n "slapd slapd/password2 password testpwd" | debconf-set-selections
echo -n "slapd slapd/domain string example.com" | debconf-set-selections
echo -n "slapd slapd/organization string test" | debconf-set-selections

export DEBIAN_FRONTEND='noninteractive'
apt-get --yes install slapd ldap-utils

ldapmodify -Y EXTERNAL -H ldapi:/// -f test/add-phonetic-attribute-options-to-slapd.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/dyngroup.ldif
ldapmodify -Y EXTERNAL -H ldapi:/// -f test/enable-dynamic-groups.ldif

su $AUTOPKGTEST_NORMAL_USER -c "gem2deb-test-runner --autopkgtest --check-dependencies"

