From 50f34b051ff0e598ad5a8caa206e6548160d0837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E5=8D=AB=E6=98=A5?= Date: Mon, 12 Jul 2021 17:30:46 +0800 Subject: [PATCH] Allow set serverid and rid in replicating deployment. --- Makefile | 4 ++-- image/service/slapd/startup.sh | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 6d97ee9..5c88094 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/image/service/slapd/startup.sh b/image/service/slapd/startup.sh index d66a6a6..1ab43f9 100755 --- a/image/service/slapd/startup.sh +++ b/image/service/slapd/startup.sh @@ -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_SERVER_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 $((L_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