Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some features those I need. #574

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = osixia/openldap
VERSION = 1.5.0
NAME ?= osixia/openldap
VERSION ?= 1.5.1

.PHONY: build build-nocache test tag-latest push push-latest release git-tag-version

Expand Down
25 changes: 19 additions & 6 deletions image/service/slapd/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -456,22 +456,27 @@ EOF
function disableReplication() {
sed -i "s|{{ LDAP_BACKEND }}|${LDAP_BACKEND}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-disable.ldif
ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-disable.ldif 2>&1 | log-helper debug || true
[[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION"
[[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION" && \
sed -i '/^# Add syncprov/,/^$/d' ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
}

if [ "${LDAP_REPLICATION,,}" == "true" ]; then

log-helper info "Add replication config..."
disableReplication || true

i=1
i=0
LDAP_SERVER_ID_FROM=${LDAP_SERVER_ID_FROM:-1}
LDAP_CONFIG_REPL_ID_FROM=${LDAP_CONFIG_REPL_ID_FROM:-1}
LDAP_DB_REPL_ID_FROM=${LDAP_DB_REPL_ID_FROM:-101}
log-helper debug "$LDAP_REPLICATION_HOSTS"
for host in $(complex-bash-env iterate LDAP_REPLICATION_HOSTS)
do
sed -i "s|{{ LDAP_REPLICATION_HOSTS }}|olcServerID: $i ${!host}\n{{ LDAP_REPLICATION_HOSTS }}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
sed -i "s|{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}|olcSyncRepl: rid=00$i provider=${!host} ${LDAP_REPLICATION_CONFIG_SYNCPROV}\n{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
sed -i "s|{{ LDAP_REPLICATION_HOSTS_DB_SYNC_REPL }}|olcSyncRepl: rid=10$i provider=${!host} ${LDAP_REPLICATION_DB_SYNCPROV}\n{{ LDAP_REPLICATION_HOSTS_DB_SYNC_REPL }}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
sed -i "s|{{ LDAP_REPLICATION_HOSTS }}|olcServerID: $((LDAP_SERVER_ID_FROM+i)) ${!host}\n{{ LDAP_REPLICATION_HOSTS }}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
sed -i "s|{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}|olcSyncRepl: rid=$(printf %03d $((LDAP_CONFIG_REPL_ID_FROM+i))) provider=${!host} ${LDAP_REPLICATION_CONFIG_SYNCPROV}\n{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
sed -i "s|{{ LDAP_REPLICATION_HOSTS_DB_SYNC_REPL }}|olcSyncRepl: rid=$(printf %03d $((LDAP_DB_REPL_ID_FROM+i))) provider=${!host} ${LDAP_REPLICATION_DB_SYNCPROV}\n{{ LDAP_REPLICATION_HOSTS_DB_SYNC_REPL }}|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif

((i++))
((++i))
done

get_ldap_base_dn
Expand Down Expand Up @@ -521,6 +526,14 @@ EOF
touch "$WAS_ADMIN_PASSWORD_SET"
fi

if [[ -d ${CONTAINER_SERVICE_DIR}/slapd/assets/config/extra ]]; then
log-helper info "Run extra ldif files..."
for f in $(find ${CONTAINER_SERVICE_DIR}/slapd/assets/config/extra -mindepth 1 -maxdepth 1 -type f -name \*.ldif | sort); do
log-helper debug "Processing file ${f}"
ldap_add_or_modify "$f"
done
fi

#
# stop OpenLDAP
#
Expand Down