#!/bin/sh set -eu status () { echo "---> ${@}" >&2 } set -x : LDAP_ADMIN_PWD=${LDAP_ADMIN_PWD} : LDAP_DOMAIN=${LDAP_DOMAIN} : LDAP_ORGANISATION=${LDAP_ORGANISATION} if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then status "configuring slapd for first run" # permission error on /etc/ldap/slapd.conf if not set?! :'( adduser openldap root ############ Base config ############ cat <> /etc/dhosts fi # Replication # todo # Other config files for f in $(find /etc/ldap/config -maxdepth 1 -name \*.ldif -type f); do status "Processing file ${f}" ldapmodify -Y EXTERNAL -H ldapi:/// -f $f -Q done kill -INT `cat /run/slapd/slapd.pid` touch /var/lib/ldap/docker_bootstrapped else status "found already-configured slapd" fi status "starting slapd on default port 389" set -x exec /usr/sbin/slapd -h "ldap:///" -u openldap -g openldap -d -1