#!/bin/sh set -eu status () { echo "---> ${@}" >&2 } if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then status "configuring slapd for first run" set -x : LDAP_ADMIN_PWD=${LDAP_ADMIN_PWD} : LDAP_DOMAIN=${LDAP_DOMAIN} : LDAP_ORGANISATION=${LDAP_ORGANISATION} # 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` unset LDAP_ADMIN_PWD 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