Skip to content

Commit

Permalink
Allow set serverid and rid in replicating deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
qianwch committed Jul 12, 2021
1 parent 865f034 commit 555b95b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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
16 changes: 11 additions & 5 deletions image/service/slapd/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,21 @@ EOF
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"
cat ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
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
cat ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif

get_ldap_base_dn
sed -i "s|\$LDAP_BASE_DN|$LDAP_BASE_DN|g" ${CONTAINER_SERVICE_DIR}/slapd/assets/config/replication/replication-enable.ldif
Expand Down

0 comments on commit 555b95b

Please sign in to comment.