Commit 59c1d03b authored by Christian Luginbühl's avatar Christian Luginbühl
Browse files

Configuration now actually survives a restart

parent ddc52042
......@@ -14,7 +14,7 @@ RUN apt-get update && \
EXPOSE 389
VOLUME ["/var/lib/ldap", "/etc/ldap"]
VOLUME ["/var/lib/ldap"]
COPY entrypoint.sh /entrypoint.sh
......
......@@ -67,7 +67,8 @@ envirnonment variables are not evaluated anymore.
Data persistence
----------------
The image exposes the directory, where the data is written
(`VOLUME ["/var/lib/ldap"`). Please make sure that
these directories are saved (in a data-only container or alike) in order to make
sure that everything is restored after a new restart of the application.
The image exposes one directory (`VOLUME ["/var/lib/ldap"]`). It both holds the
database and the configuration (which is symlinked in a pretty hacky way - see
the `entrypoint.sh` file if interested). Please make sure that this directory is
saved (in a data-only container or alike) in order to make sure that everything
is restored after a new restart of the container.
#!/bin/bash
set -e
chown -R openldap:openldap /var/lib/ldap/
chown openldap:openldap /var/lib/ldap/
if [[ -d /var/lib/ldap/config ]]; then
rm -rf /etc/ldap
ln -s /var/lib/ldap/config /etc/ldap
else
if [[ ! -f /etc/ldap/docker-configured ]]; then
if [[ -z "$SLAPD_PASSWORD" ]]; then
echo >&2 "Error: slapd not configured and SLAPD_PASSWORD not set"
echo >&2 "Did you forget to add -e SLAPD_PASSWORD=... ?"
......@@ -47,7 +53,9 @@ EOF
if [[ -n "$SLAPD_CONFIG_PASSWORD" ]]; then
password_hash=`slappasswd -s "${SLAPD_CONFIG_PASSWORD}"`
sed_safe_password_hash=${password_hash/\//\\\/}
sed_safe_password_hash=${password_hash//\//\\\/}
echo $sed_safe_password_hash
slapcat -n0 -F /etc/ldap/slapd.d -l /tmp/config.ldif
sed -i "s/\(olcRootDN: cn=admin,cn=config\)/\1\nolcRootPW: ${sed_safe_password_hash}/g" /tmp/config.ldif
......@@ -55,7 +63,8 @@ EOF
slapadd -n0 -F /etc/ldap/slapd.d -l /tmp/config.ldif >/dev/null 2>&1
fi
touch /etc/ldap/docker-configured
mv /etc/ldap /var/lib/ldap/config
ln -s /var/lib/ldap/config /etc/ldap
fi
exec "$@"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment