#!/usr/bin/env sh set -e set -x BASE_PATH=$( cd "`dirname $0`/../test/fixtures/openldap" && pwd ) SEED_PATH=$( cd "`dirname $0`/../test/fixtures" && pwd ) dpkg -s slapd time ldap-utils gnutls-bin ssl-cert > /dev/null ||\ DEBIAN_FRONTEND=noninteractive apt-get update -y --force-yes && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes slapd time ldap-utils gnutls-bin ssl-cert /etc/init.d/slapd stop TMPDIR=$(mktemp -d) cd $TMPDIR # Delete data and reconfigure. cp -v /var/lib/ldap/DB_CONFIG ./DB_CONFIG rm -rf /etc/ldap/slapd.d/* rm -rf /var/lib/ldap/* cp -v ./DB_CONFIG /var/lib/ldap/DB_CONFIG slapadd -F /etc/ldap/slapd.d -b "cn=config" -l $BASE_PATH/slapd.conf.ldif # Load memberof and ref-int overlays and configure them. slapadd -F /etc/ldap/slapd.d -b "cn=config" -l $BASE_PATH/memberof.ldif # Load retcode overlay and configure slapadd -F /etc/ldap/slapd.d -b "cn=config" -l $BASE_PATH/retcode.ldif # Add base domain. slapadd -F /etc/ldap/slapd.d < /etc/ssl/ldap01.info <> /etc/ssl/ldap01.info done # Create the server certificate certtool --generate-certificate \ --load-privkey /etc/ssl/private/ldap01_slapd_key.pem \ --load-ca-certificate "${CA_CERT}" \ --load-ca-privkey "${CA_KEY}" \ --template /etc/ssl/ldap01.info \ --outfile /etc/ssl/certs/ldap01_slapd_cert.pem ldapmodify -Y EXTERNAL -H ldapi:/// <> /etc/hosts grep ldap02 /etc/hosts || echo "127.0.0.1 ldap02.example.com" >> /etc/hosts grep bogus /etc/hosts || echo "127.0.0.1 bogus.example.com" >> /etc/hosts service slapd restart