From 865f034df0f252b4c68ca91f1cef5922cb688bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E5=8D=AB=E6=98=A5?= Date: Thu, 8 Jul 2021 00:01:39 +0800 Subject: [PATCH 1/4] Disable adding syncprov module to database while there exists replicating config. --- image/service/slapd/startup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/image/service/slapd/startup.sh b/image/service/slapd/startup.sh index dae1bd2..d66a6a6 100755 --- a/image/service/slapd/startup.sh +++ b/image/service/slapd/startup.sh @@ -456,7 +456,8 @@ 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 From bd44d7a6c0de889180db0179590073ab76fa111a 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 2/4] Allow set serverid and rid in replicating deployment. --- Makefile | 4 ++-- image/service/slapd/startup.sh | 14 +++++++++----- 2 files changed, 11 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..b1cc728 100755 --- a/image/service/slapd/startup.sh +++ b/image/service/slapd/startup.sh @@ -465,14 +465,18 @@ 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" 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 From 06e99775499b4655e9ea7f4d3f32573737f4c22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E5=8D=AB=E6=98=A5?= Date: Tue, 13 Jul 2021 11:13:23 +0800 Subject: [PATCH 3/4] Allow to execute assets/config/extra/*.ldif files as the last step of the first-startup. --- image/service/slapd/startup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/image/service/slapd/startup.sh b/image/service/slapd/startup.sh index b1cc728..c352b13 100755 --- a/image/service/slapd/startup.sh +++ b/image/service/slapd/startup.sh @@ -526,6 +526,14 @@ EOF touch "$WAS_ADMIN_PASSWORD_SET" fi + if [[ -d ${CONTAINER_SERVICE_DIR}/slapd/assets/config/extra ]]; then + log-helper info "Add image bootstrap ldif..." + 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 # From e339963efaf7c8201e73267c8afb409103975abd Mon Sep 17 00:00:00 2001 From: qianweichun <45196316+qianweichun@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:06:26 +0800 Subject: [PATCH 4/4] Update startup.sh Modify improper log message. --- image/service/slapd/startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image/service/slapd/startup.sh b/image/service/slapd/startup.sh index c352b13..634da4c 100755 --- a/image/service/slapd/startup.sh +++ b/image/service/slapd/startup.sh @@ -527,7 +527,7 @@ EOF fi if [[ -d ${CONTAINER_SERVICE_DIR}/slapd/assets/config/extra ]]; then - log-helper info "Add image bootstrap ldif..." + 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"