Enable set up of environment with data in specific dirs, used by PLA
This commit is contained in:
parent
ccc9750b60
commit
400b2b8444
@ -14,7 +14,7 @@ ADD tls /etc/openldap/tls
|
|||||||
RUN sed -i -e 's/dc=my-domain,dc=com/c=AU/' /etc/openldap/slapd.ldif \
|
RUN sed -i -e 's/dc=my-domain,dc=com/c=AU/' /etc/openldap/slapd.ldif \
|
||||||
&& sed -i -e 's/openldap-data/data/' /etc/openldap/slapd.ldif \
|
&& sed -i -e 's/openldap-data/data/' /etc/openldap/slapd.ldif \
|
||||||
&& mv /var/lib/openldap/openldap-data /var/lib/openldap/data \
|
&& mv /var/lib/openldap/openldap-data /var/lib/openldap/data \
|
||||||
&& mkdir /etc/openldap/slapd.d /etc/openldap/schema/add.d /etc/openldap/schema/modify.d \
|
&& mkdir /etc/openldap/slapd.d /etc/openldap/schema/add.d /etc/openldap/schema/modify.d /etc/openldap/schema/data.d \
|
||||||
&& ln -s ../misc.ldif /etc/openldap/schema/add.d/01-misc.ldif \
|
&& ln -s ../misc.ldif /etc/openldap/schema/add.d/01-misc.ldif \
|
||||||
&& ln -s ../custom/samba.ldif /etc/openldap/schema/add.d/02-samba.ldif \
|
&& ln -s ../custom/samba.ldif /etc/openldap/schema/add.d/02-samba.ldif \
|
||||||
&& ln -s ../custom/wurley.ldif /etc/openldap/schema/add.d/10-wurley.ldif \
|
&& ln -s ../custom/wurley.ldif /etc/openldap/schema/add.d/10-wurley.ldif \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
NAME="OPENLDAP"
|
NAME="OPENLDAP"
|
||||||
@ -9,6 +9,11 @@ SLAPD_INIT=${SLAPD_INIT:="/etc/openldap/slapd.ldif"}
|
|||||||
SLAPD_DEBUG=${SLAPD_DEBUG:-0}
|
SLAPD_DEBUG=${SLAPD_DEBUG:-0}
|
||||||
SLAPD_URLS=${SLAPD_URLS:-"ldapi:/// ldap:/// ldaps:///"}
|
SLAPD_URLS=${SLAPD_URLS:-"ldapi:/// ldap:/// ldaps:///"}
|
||||||
SLAPD_OPTIONS="${SLAPD_OPTIONS} -d ${SLAPD_DEBUG}"
|
SLAPD_OPTIONS="${SLAPD_OPTIONS} -d ${SLAPD_DEBUG}"
|
||||||
|
SLAPD_SCHEMA_BASE=${SLAPD_SCHEMA_BASE:-"/etc/openldap/schema"}
|
||||||
|
|
||||||
|
SLAPD_CUSTOM_BASES=${SLAPD_CUSTOM_BASES:-"/ldap/bases"}
|
||||||
|
SLAPD_CUSTOM_SCHEMA=${SLAPD_CUSTOM_SCHEMA:-"/ldap/schema"}
|
||||||
|
SLAPD_CUSTOM_DATA=${SLAPD_CUSTOM_DATA:-"/ldap/data"}
|
||||||
|
|
||||||
function stop {
|
function stop {
|
||||||
echo "Stopping ${NAME}"
|
echo "Stopping ${NAME}"
|
||||||
@ -19,7 +24,7 @@ function mp() {
|
|||||||
set +e
|
set +e
|
||||||
mountpoint -q $1
|
mountpoint -q $1
|
||||||
local mp=$?
|
local mp=$?
|
||||||
set -e
|
set -
|
||||||
return ${mp}
|
return ${mp}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,36 +34,56 @@ if [ -z "$@" ]; then
|
|||||||
# If /etc/openldap is an external mount point
|
# If /etc/openldap is an external mount point
|
||||||
if [ -e ${SLAPD_CONFIG}/olcDatabase=\{0\}config.ldif ]; then
|
if [ -e ${SLAPD_CONFIG}/olcDatabase=\{0\}config.ldif ]; then
|
||||||
echo "* [${SLAPD_CONFIG}] exists, ready to go"
|
echo "* [${SLAPD_CONFIG}] exists, ready to go"
|
||||||
else
|
|
||||||
|
|
||||||
|
else
|
||||||
|
shopt -s nullglob
|
||||||
echo "- [${SLAPD_CONFIG}] rebuilding schema configuration"
|
echo "- [${SLAPD_CONFIG}] rebuilding schema configuration"
|
||||||
|
|
||||||
|
# Check if we have any custom schema to add
|
||||||
|
[ -d ${SLAPD_SCHEMA_BASE}/add.d ] || mkdir ${SLAPD_SCHEMA_BASE}/add.d
|
||||||
|
if [ -d ${SLAPD_CUSTOM_SCHEMA} ]; then
|
||||||
|
for f in ${SLAPD_CUSTOM_SCHEMA}/*.ldif; do
|
||||||
|
echo "- Adding SCHEMA item [${f}]"
|
||||||
|
ln -s ${f} ${SLAPD_SCHEMA_BASE}/add.d
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if we have any custom data to add
|
||||||
|
[ -d ${SLAPD_SCHEMA_BASE}/data.d ] || mkdir ${SLAPD_SCHEMA_BASE}/data.d
|
||||||
|
if [ -d ${SLAPD_CUSTOM_DATA} ]; then
|
||||||
|
for f in ${SLAPD_CUSTOM_DATA}/*.ldif; do
|
||||||
|
echo "- Adding DATA item [${f}]"
|
||||||
|
ln -s ${f} ${SLAPD_SCHEMA_BASE}/data.d
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add our bases
|
||||||
|
for f in ${SLAPD_CUSTOM_BASES}/*.ldif; do
|
||||||
|
echo "- Processing BASE item [${f}]"
|
||||||
|
echo "" >> ${SLAPD_INIT}
|
||||||
|
cat ${f} >> ${SLAPD_INIT}
|
||||||
|
done
|
||||||
slapadd -n 0 -F ${SLAPD_BASE} -l ${SLAPD_INIT}
|
slapadd -n 0 -F ${SLAPD_BASE} -l ${SLAPD_INIT}
|
||||||
|
|
||||||
# Add custom schema definitions
|
# Add custom schema definitions
|
||||||
for f in /etc/openldap/schema/add.d/*.ldif; do
|
for f in ${SLAPD_SCHEMA_BASE}/add.d/*.ldif; do
|
||||||
[ -e "${f}" ] || continue
|
echo "- Processing SCHEMA add item [${f}]"
|
||||||
|
|
||||||
echo "- Processing SCHEMA item [${f}]"
|
|
||||||
slapadd -b cn=config -l ${f}
|
slapadd -b cn=config -l ${f}
|
||||||
done
|
done
|
||||||
|
|
||||||
for f in /etc/openldap/schema/modify.d/*.ldif; do
|
[ -d ${SLAPD_SCHEMA_BASE}/modify.d ] || mkdir ${SLAPD_SCHEMA_BASE}/modify.d
|
||||||
[ -e "${f}" ] || continue
|
for f in ${SLAPD_SCHEMA_BASE}/modify.d/*.ldif; do
|
||||||
|
echo "- Processing SCHEMA modify item [${f}]"
|
||||||
echo "- Processing SCHEMA item [${f}]"
|
|
||||||
slapmodify -b cn=config -l ${f}
|
slapmodify -b cn=config -l ${f}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add custom data definitions
|
# Add custom data definitions
|
||||||
for f in /etc/openldap/data/init.d/*.ldif; do
|
for i in 01 03 04 05 06 07; do
|
||||||
[ -e "${f}" ] || continue
|
echo "- Processing DATABASE item(s) for DB [${i}]"
|
||||||
|
cat ${SLAPD_SCHEMA_BASE}/data.d/${i}-* | slapadd -n ${i}
|
||||||
echo "- Processing DATA items [${f}]"
|
|
||||||
slapadd -b cn=config -l ${f}
|
|
||||||
done
|
done
|
||||||
|
|
||||||
chown -R ldap:ldap ${SLAPD_CONFIG}*
|
chown -R ldap:ldap ${SLAPD_CONFIG}* /var/lib/openldap/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -x /usr/sbin/slapd ] && /usr/sbin/slapd -u ldap -h "${SLAPD_URLS}" $SLAPD_OPTIONS &
|
[ -x /usr/sbin/slapd ] && /usr/sbin/slapd -u ldap -h "${SLAPD_URLS}" $SLAPD_OPTIONS &
|
||||||
|
Loading…
Reference in New Issue
Block a user