ldap-server/slapd.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2022-12-14 11:19:32 +01:00
#!/bin/sh
set -eu
set -x
: LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
: LDAP_DOMAIN=${LDAP_DOMAIN}
: LDAP_ORGANISATION=${LDAP_ORGANISATION}
if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then
2022-12-14 21:57:05 +01:00
echo "configuring slapd for first run"
2022-12-14 11:19:32 +01:00
cat <<EOF | debconf-set-selections
slapd slapd/internal/generated_adminpw password ${LDAP_ADMIN_PASSWORD}
slapd slapd/internal/adminpw password ${LDAP_ADMIN_PASSWORD}
slapd slapd/password2 password ${LDAP_ADMIN_PASSWORD}
slapd slapd/password1 password ${LDAP_ADMIN_PASSWORD}
slapd slapd/dump_database_destdir string /var/backups/slapd-VERSION
slapd slapd/domain string ${LDAP_DOMAIN}
slapd shared/organization string ${LDAP_ORGANISATION}
slapd slapd/backend string HDB
slapd slapd/purge_database boolean true
slapd slapd/move_old_database boolean true
slapd slapd/allow_ldap_v2 boolean false
slapd slapd/no_configuration boolean false
slapd slapd/dump_database select when needed
EOF
dpkg-reconfigure -f noninteractive slapd
touch /var/lib/ldap/docker_bootstrapped
else
2022-12-14 21:57:05 +01:00
echo "found already-configured slapd"
2022-12-14 11:19:32 +01:00
fi
2022-12-14 21:57:05 +01:00
echo "starting slapd"
2022-12-14 11:19:32 +01:00
set -x
2022-12-14 21:57:05 +01:00
exec $@