Archived
new ldif schema
This commit is contained in:
1 parent
e893fff3c8
commit
09b8595d62
10 files changed
+17
-110
No files matched your search
+6
-20
@@ -1,4 +1,4 @@
|
||||
FROM osixia/baseimage:0.6.0
|
||||
FROM osixia/baseimage:0.8.2
|
||||
MAINTAINER Bertrand Gouny <bertrand.gouny@osixia.fr>
|
||||
|
||||
# From Nick Stenning's work
|
||||
@@ -9,8 +9,6 @@ ENV LDAP_ADMIN_PWD toor
|
||||
ENV LDAP_ORGANISATION Example Inc.
|
||||
ENV LDAP_DOMAIN example.com
|
||||
|
||||
ENV WITH_MMC_AGENT false
|
||||
|
||||
# /!\ To store the data outside the container,
|
||||
# mount /var/lib/ldap and /etc/ldap/slapd.d as a data volume add
|
||||
# -v /some/host/directory:/var/lib/ldap and -v /some/other/host/directory:/etc/ldap/slapd.d
|
||||
@@ -25,33 +23,21 @@ RUN /sbin/enable-service dnsmasq
|
||||
# Use baseimage-docker's init system.
|
||||
CMD ["/sbin/my_init"]
|
||||
|
||||
# Add Mandriva MDS repository
|
||||
RUN echo "deb http://mds.mandriva.org/pub/mds/debian wheezy main" >> /etc/apt/sources.list
|
||||
|
||||
# Resynchronize the package index files from their sources
|
||||
RUN apt-get -y update
|
||||
|
||||
# Install openldap (slapd),ldap-utils and mmc tools
|
||||
RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends mmc-agent python-mmc-mail slapd ldap-utils
|
||||
# Install openldap (slapd) and ldap-utils
|
||||
RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends slapd ldap-utils
|
||||
|
||||
# Expose ldap and mmc-agent default ports
|
||||
EXPOSE 389 7080
|
||||
# Expose ldap default port
|
||||
EXPOSE 389
|
||||
|
||||
# Create TLS certificats directory
|
||||
RUN mkdir /etc/ldap/ssl
|
||||
|
||||
# Add config directory
|
||||
RUN mkdir /etc/ldap/config
|
||||
ADD service/slapd/config /etc/ldap/config
|
||||
ADD service/mmc-agent/assets /etc/ldap/config
|
||||
|
||||
# mmc-agent config on container start
|
||||
RUN mkdir -p /etc/my_init.d
|
||||
ADD service/mmc-agent/install.sh /etc/my_init.d/mmc-agent.sh
|
||||
|
||||
# Add mmc-agent deamon
|
||||
RUN mkdir /etc/service/mmc-agent
|
||||
ADD service/mmc-agent/mmc-agent.sh /etc/service/mmc-agent/run
|
||||
ADD service/slapd/assets/config /etc/ldap/config
|
||||
|
||||
# Add slapd deamon
|
||||
RUN mkdir /etc/service/slapd
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[userdefault]
|
||||
mailbox = /home/vmail/%uid%/
|
||||
mailuserquota = 204800
|
||||
@@ -1,6 +0,0 @@
|
||||
include /etc/ldap/schema/core.schema
|
||||
include /etc/ldap/schema/cosine.schema
|
||||
include /etc/ldap/schema/nis.schema
|
||||
include /etc/ldap/schema/inetorgperson.schema
|
||||
include /usr/share/doc/mmc/contrib/base/mmc.schema
|
||||
include /usr/share/doc/mmc/contrib/mail/mail.schema
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# -e Exit immediately if a command exits with a non-zero status
|
||||
set -e
|
||||
|
||||
WITH_MMC_AGENT=${WITH_MMC_AGENT}
|
||||
LDAP_DOMAIN=${LDAP_DOMAIN}
|
||||
LDAP_ADMIN_PWD=${LDAP_ADMIN_PWD}
|
||||
|
||||
if [ "$WITH_MMC_AGENT" = true ]; then
|
||||
|
||||
mkdir -p /etc/ldap/schema/converted
|
||||
slaptest -f /etc/ldap/config/convert_to_ldif -F /etc/ldap/schema/converted
|
||||
|
||||
sed -i -e 's/^dn:.*$/dn: cn=mmc,cn=schema,cn=config/; s/^cn:.*$/cn: mmc/; /^structuralObjectClass:.*$/d; /^entryUUID:.*$/d; /^creatorsName:.*$/d; /^createTimestamp:.*$/d; /^entryCSN:.*$/d; /^modifiersName:.*$/d; /^modifyTimestamp:.*$/d' /etc/ldap/schema/converted/cn\=config/cn\=schema/cn=\{4\}mmc.ldif
|
||||
|
||||
sed -i -e 's/^dn:.*$/dn: cn=mail,cn=schema,cn=config/; s/^cn:.*$/cn: mail/; /^structuralObjectClass:.*$/d; /^entryUUID:.*$/d; /^creatorsName:.*$/d; /^createTimestamp:.*$/d; /^entryCSN:.*$/d; /^modifiersName:.*$/d; /^modifyTimestamp:.*$/d' /etc/ldap/schema/converted/cn\=config/cn\=schema/cn=\{5\}mail.ldif
|
||||
|
||||
# Base config
|
||||
getBaseDn () {
|
||||
IFS="."
|
||||
export IFS
|
||||
|
||||
domain=$1
|
||||
init=1
|
||||
|
||||
for s in $domain; do
|
||||
dc="dc=$s"
|
||||
if [ "$init" -eq 1 ]; then
|
||||
baseDn=$dc
|
||||
init=0
|
||||
else
|
||||
baseDn="$baseDn,$dc"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Get base dn from ldap domain
|
||||
getBaseDn ${LDAP_DOMAIN}
|
||||
|
||||
sed -i -e "s/dc=mandriva, dc=com/$baseDn/" /etc/mmc/plugins/base.ini
|
||||
sed -i -e "s/password = secret/password = $LDAP_ADMIN_PWD/" /etc/mmc/plugins/base.ini
|
||||
|
||||
mkdir /home/archives
|
||||
|
||||
# Mail plugin
|
||||
sed -i -e 's/vDomainSupport = 0/vDomainSupport = 1/g' /etc/mmc/plugins/mail.ini
|
||||
sed -i -e 's/vAliasesSupport = 0/vAliasesSupport = 1/g' /etc/mmc/plugins/mail.ini
|
||||
cat /etc/ldap/config/append_to_mail.ini >> /etc/mmc/plugins/mail.ini
|
||||
|
||||
fi
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# -e Exit immediately if a command exits with a non-zero status
|
||||
set -e
|
||||
|
||||
WITH_MMC_AGENT=${WITH_MMC_AGENT}
|
||||
|
||||
if [ "$WITH_MMC_AGENT" = true ]; then
|
||||
|
||||
if [ -e /etc/ldap/config/docker_bootstrapped ]; then
|
||||
exec /usr/sbin/mmc-agent -d
|
||||
else
|
||||
sleep 3s
|
||||
fi
|
||||
else
|
||||
sleep 1d
|
||||
fi
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+11
-13
@@ -43,20 +43,12 @@ fi
|
||||
|
||||
|
||||
############ Custom config ############
|
||||
if [ ! -e /etc/ldap/config/docker_bootstrapped ]; then
|
||||
if [ ! -e /etc/ldap/slapd.d/docker_bootstrapped ]; then
|
||||
status "Custom config"
|
||||
|
||||
slapd -h "ldapi:///" -u openldap -g openldap
|
||||
chown -R openldap:openldap /etc/ldap
|
||||
|
||||
if [ "$WITH_MMC_AGENT" = true ]; then
|
||||
|
||||
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/converted/cn\=config/cn\=schema/cn=\{4\}mmc.ldif -Q
|
||||
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/converted/cn\=config/cn\=schema/cn=\{5\}mail.ldif -Q
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# TLS
|
||||
if [ -e /etc/ldap/ssl/ldap.crt ] && [ -e /etc/ldap/ssl/ldap.key ] && [ -e /etc/ldap/ssl/ca.crt ]; then
|
||||
status "certificates found"
|
||||
@@ -66,7 +58,7 @@ if [ ! -e /etc/ldap/config/docker_bootstrapped ]; then
|
||||
# create DHParamFile if not found
|
||||
[ -f /etc/ldap/ssl/dhparam.pem ] || openssl dhparam -out /etc/ldap/ssl/dhparam.pem 2048
|
||||
|
||||
ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/ldap/config/auto/tls.ldif -Q
|
||||
ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/ldap/config/modify/auto/tls.ldif -Q
|
||||
|
||||
# add fake dnsmasq route to certificate cn
|
||||
cn=$(openssl x509 -in /etc/ldap/ssl/ldap.crt -subject -noout | sed -n 's/.*CN=\(.*\)\/*\(.*\)/\1/p')
|
||||
@@ -77,15 +69,21 @@ if [ ! -e /etc/ldap/config/docker_bootstrapped ]; then
|
||||
# Replication
|
||||
# todo :)
|
||||
|
||||
# Other config files
|
||||
for f in $(find /etc/ldap/config -maxdepth 1 -name \*.ldif -type f); do
|
||||
# Add config
|
||||
for f in $(find /etc/ldap/config/add -maxdepth 1 -name \*.ldif -type f); do
|
||||
status "Processing file ${f}"
|
||||
ldapadd -Y EXTERNAL -H ldapi:/// -f $f -Q
|
||||
done
|
||||
|
||||
# Modify config
|
||||
for f in $(find /etc/ldap/config/modify -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 /etc/ldap/config/docker_bootstrapped
|
||||
touch /etc/ldap/slapd.d/docker_bootstrapped
|
||||
|
||||
else
|
||||
status "found already-configured slapd"
|
||||
|
||||
Reference in new issue
Block a user