mirror of
https://github.com/luzifer-docker/openldap.git
synced 2024-11-14 20:22:41 +00:00
Configuration now actually survives a restart
This commit is contained in:
parent
ddc5204228
commit
59c1d03bf3
3 changed files with 19 additions and 9 deletions
|
@ -14,7 +14,7 @@ RUN apt-get update && \
|
||||||
|
|
||||||
EXPOSE 389
|
EXPOSE 389
|
||||||
|
|
||||||
VOLUME ["/var/lib/ldap", "/etc/ldap"]
|
VOLUME ["/var/lib/ldap"]
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@ envirnonment variables are not evaluated anymore.
|
||||||
Data persistence
|
Data persistence
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
The image exposes the directory, where the data is written
|
The image exposes one directory (`VOLUME ["/var/lib/ldap"]`). It both holds the
|
||||||
(`VOLUME ["/var/lib/ldap"`). Please make sure that
|
database and the configuration (which is symlinked in a pretty hacky way - see
|
||||||
these directories are saved (in a data-only container or alike) in order to make
|
the `entrypoint.sh` file if interested). Please make sure that this directory is
|
||||||
sure that everything is restored after a new restart of the application.
|
saved (in a data-only container or alike) in order to make sure that everything
|
||||||
|
is restored after a new restart of the container.
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
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
|
if [[ -z "$SLAPD_PASSWORD" ]]; then
|
||||||
echo >&2 "Error: slapd not configured and SLAPD_PASSWORD not set"
|
echo >&2 "Error: slapd not configured and SLAPD_PASSWORD not set"
|
||||||
echo >&2 "Did you forget to add -e SLAPD_PASSWORD=... ?"
|
echo >&2 "Did you forget to add -e SLAPD_PASSWORD=... ?"
|
||||||
|
@ -47,7 +53,9 @@ EOF
|
||||||
if [[ -n "$SLAPD_CONFIG_PASSWORD" ]]; then
|
if [[ -n "$SLAPD_CONFIG_PASSWORD" ]]; then
|
||||||
password_hash=`slappasswd -s "${SLAPD_CONFIG_PASSWORD}"`
|
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
|
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
|
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
|
slapadd -n0 -F /etc/ldap/slapd.d -l /tmp/config.ldif >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch /etc/ldap/docker-configured
|
mv /etc/ldap /var/lib/ldap/config
|
||||||
|
ln -s /var/lib/ldap/config /etc/ldap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
Loading…
Reference in a new issue