From 804560786243ccd4aecc0bef1b1ea12e4f8a5a4f Mon Sep 17 00:00:00 2001
From: Tobias Gesellchen <tobias@gesellix.de>
Date: Mon, 02 May 2022 08:25:18 +0000
Subject: [PATCH] Support to load plain ldif files during container setup (#223)

---
 opendj-packages/opendj-docker/bootstrap/replicate.sh |  140 ++++++++++++++++++++++++----------------------
 1 files changed, 72 insertions(+), 68 deletions(-)

diff --git a/opendj-packages/opendj-docker/bootstrap/replicate.sh b/opendj-packages/opendj-docker/bootstrap/replicate.sh
index 0fbfad9..b59416e 100755
--- a/opendj-packages/opendj-docker/bootstrap/replicate.sh
+++ b/opendj-packages/opendj-docker/bootstrap/replicate.sh
@@ -6,7 +6,7 @@
 # The hostname has to be a fully resolvable DNS name in the cluster
 # If the service is called
 
-MYHOSTNAME=${MYHOSTNAME:-`hostname -f`}
+MYHOSTNAME=${MYHOSTNAME:-$(hostname -f)}
 export PATH=/opt/opendj/bin:$PATH
 
 echo "Setting up replication from $MYHOSTNAME to $MASTER_SERVER"
@@ -15,8 +15,8 @@
 
 # K8s puts the service name in /etc/hosts
 if grep ${MASTER_SERVER} /etc/hosts; then
- echo "We are the master. Skipping replication setup to ourself"
- exit 0
+  echo "We are the master. Skipping replication setup to ourself"
+  exit 0
 fi
 
 # Comment out
@@ -31,12 +31,16 @@
 
 if [ "$OPENDJ_REPLICATION_TYPE" == "simple" ]; then
   echo "Enabling Standard Replication..."
-  /opt/opendj/bin/dsreplication enable --host1 $MASTER_SERVER --port1 4444 \
+  /opt/opendj/bin/dsreplication \
+    enable \
+    --host1 $MASTER_SERVER \
+    --port1 4444 \
     --bindDN1 "$ROOT_USER_DN" \
     --bindPassword1 $ROOT_PASSWORD --replicationPort1 8989 \
     --host2 $MYHOSTNAME --port2 4444 --bindDN2 "$ROOT_USER_DN" \
     --bindPassword2 $ROOT_PASSWORD --replicationPort2 8989 \
-    --adminUID admin --adminPassword $ROOT_PASSWORD --baseDN $BASE_DN -X -n
+    --adminUID admin --adminPassword $ROOT_PASSWORD \
+    --baseDN $BASE_DN -X -n
 
   echo "initializing replication"
 
@@ -49,84 +53,84 @@
 elif [ "$OPENDJ_REPLICATION_TYPE" == "srs" ]; then
   echo "Enabling Standalone Replication Servers..."
   dsreplication enable \
-   --adminUID admin \
-   --adminPassword $ROOT_PASSWORD \
-   --baseDN $BASE_DN \
-   --host1 $MYHOSTNAME \
-   --port1 4444 \
-   --bindDN1 "$ROOT_USER_DN" \
-   --bindPassword1 $ROOT_PASSWORD \
-   --noReplicationServer1 \
-   --host2 $MASTER_SERVER \
-   --port2 4444 \
-   --bindDN2 "$ROOT_USER_DN" \
-   --bindPassword2 $ROOT_PASSWORD \
-   --replicationPort2 8989 \
-   --onlyReplicationServer2 \
-   --trustAll \
-   --no-prompt;
+    --adminUID admin \
+    --adminPassword $ROOT_PASSWORD \
+    --baseDN $BASE_DN \
+    --host1 $MYHOSTNAME \
+    --port1 4444 \
+    --bindDN1 "$ROOT_USER_DN" \
+    --bindPassword1 $ROOT_PASSWORD \
+    --noReplicationServer1 \
+    --host2 $MASTER_SERVER \
+    --port2 4444 \
+    --bindDN2 "$ROOT_USER_DN" \
+    --bindPassword2 $ROOT_PASSWORD \
+    --replicationPort2 8989 \
+    --onlyReplicationServer2 \
+    --trustAll \
+    --no-prompt
 
   echo "initializing replication"
 
   dsreplication \
-   initialize-all \
-   --adminUID admin \
-   --adminPassword $ROOT_PASSWORD \
-   --baseDN $BASE_DN \
-   --hostname $MYHOSTNAME \
-   --port 4444 \
-   --trustAll \
-   --no-prompt
+    initialize-all \
+    --adminUID admin \
+    --adminPassword $ROOT_PASSWORD \
+    --baseDN $BASE_DN \
+    --hostname $MYHOSTNAME \
+    --port 4444 \
+    --trustAll \
+    --no-prompt
 
 elif [ "$OPENDJ_REPLICATION_TYPE" == "sdsr" ]; then
   echo "Enabling Standalone Directory Server Replicas...."
   dsreplication \
-   enable \
-   --adminUID admin \
-   --adminPassword $ROOT_PASSWORD \
-   --baseDN $BASE_DN \
-   --host1 $MASTER_SERVER \
-   --port1 4444 \
-   --bindDN1 "$ROOT_USER_DN" \
-   --bindPassword1 $ROOT_PASSWORD \
-   --host2 $MYHOSTNAME \
-   --port2 4444 \
-   --bindDN2 "$ROOT_USER_DN" \
-   --bindPassword2 $ROOT_PASSWORD \
-   --noReplicationServer2 \
-   --trustAll \
-   --no-prompt
+    enable \
+    --adminUID admin \
+    --adminPassword $ROOT_PASSWORD \
+    --baseDN $BASE_DN \
+    --host1 $MASTER_SERVER \
+    --port1 4444 \
+    --bindDN1 "$ROOT_USER_DN" \
+    --bindPassword1 $ROOT_PASSWORD \
+    --host2 $MYHOSTNAME \
+    --port2 4444 \
+    --bindDN2 "$ROOT_USER_DN" \
+    --bindPassword2 $ROOT_PASSWORD \
+    --noReplicationServer2 \
+    --trustAll \
+    --no-prompt
 
- echo "initializing replication"
+  echo "initializing replication"
 
- dsreplication \
-   initialize \
-   --adminUID admin \
-   --adminPassword $ROOT_PASSWORD \
-   --baseDN $BASE_DN \
-   --hostSource $MASTER_SERVER \
-   --portSource 4444 \
-   --hostDestination $MYHOSTNAME \
-   --portDestination 4444 \
-   --trustAll \
-   --no-prompt
+  dsreplication \
+    initialize \
+    --adminUID admin \
+    --adminPassword $ROOT_PASSWORD \
+    --baseDN $BASE_DN \
+    --hostSource $MASTER_SERVER \
+    --portSource 4444 \
+    --hostDestination $MYHOSTNAME \
+    --portDestination 4444 \
+    --trustAll \
+    --no-prompt
 
 elif [ "$OPENDJ_REPLICATION_TYPE" == "rg" ]; then
   echo "Enabling Replication Groups..."
 
   dsconfig \
-   set-replication-domain-prop \
-   --port 4444 \
-   --hostname $MYHOSTNAME \
-   --bindDN "$ROOT_USER_DN" \
-   --bindPassword $ROOT_PASSWORD \
-   --provider-name "Multimaster Synchronization" \
-   --domain-name $BASE_DN \
-   --set group-id:$OPENDJ_REPLICATION_GROUP_ID \
-   --trustAll \
-   --no-prompt
+    set-replication-domain-prop \
+    --port 4444 \
+    --hostname $MYHOSTNAME \
+    --bindDN "$ROOT_USER_DN" \
+    --bindPassword $ROOT_PASSWORD \
+    --provider-name "Multimaster Synchronization" \
+    --domain-name $BASE_DN \
+    --set group-id:$OPENDJ_REPLICATION_GROUP_ID \
+    --trustAll \
+    --no-prompt
 
-   dsconfig \
+  dsconfig \
     set-replication-server-prop \
     --port 4444 \
     --hostname $MASTER_SERVER \
@@ -138,5 +142,5 @@
     --no-prompt
 
 else
-  echo "Unknown replication type, skiping replication..."
+  echo "Unknown replication type, skipping replication..."
 fi

--
Gitblit v1.10.0