Upgrade to DS 7: Setup Script

Save this as 1-setup-6.5-servers.sh:

#!/usr/bin/env bash
# Copyright 2021 ForgeRock AS. All Rights Reserved
#
# Use of this code requires a commercial software license with ForgeRock AS.
# or with one of its affiliates. All use shall be exclusively subject
# to such license between the licensee and ForgeRock AS.
set -e

# Set up two DS/RS replicas using 6.5.

ZIP=~/Downloads/DS-6.5.4.zip
CURRENT_DIR=$(pwd)
BASE_DIR=/path/to
INSTANCE_PREFIX=ds-rs-
FQDN=localhost

# Use Java 8.
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
PATH=${JAVA_HOME}bin:${PATH}

# Unpack the distribution for a single DS/RS.
# $1: instance number
unpack() {
  echo "### Unpacking ds-rs-${1}"
  unzip -q ${ZIP}
  mv opendj ds-rs-${1}
}

# Set up a single DS/RS.
# $1: instance number
setup() {
  echo "### Setting up ds-rs-${1}; LDAPS on ${1}1636"
  ./ds-rs-${1}/setup \
   directory-server \
   --rootUserDN "cn=Directory Manager" \
   --rootUserPassword password \
   --monitorUserPassword password \
   --hostname ${FQDN} \
   --ldapPort ${1}1389 \
   --enableStartTls \
   --ldapsPort ${1}1636 \
   --httpsPort ${1}8443 \
   --adminConnectorPort ${1}4444 \
   --profile ds-evaluation \
   --acceptLicense
}

# Set the server ID for a single DS/RS:
# $1: instance number
set_server_id() {
  echo "### Setting global server ID for ds-rs-${1} to ${1}"
  ./ds-rs-${1}/bin/dsconfig \
    set-global-configuration-prop \
    --hostname localhost \
    --port ${1}4444 \
    --bindDN "cn=Directory Manager" \
    --bindPassword password \
    --set server-id:${1} \
    --trustAll \
    --no-prompt
}

configure_replication() {
echo "### Configuring replication"
  ./ds-rs-1/bin/dsreplication \
    configure \
    --adminUID admin \
    --adminPassword password \
    --baseDN dc=example,dc=com \
    --host1 localhost \
    --port1 14444 \
    --bindDN1 "cn=Directory Manager" \
    --bindPassword1 password \
    --replicationPort1 18989 \
    --host2 localhost \
    --port2 24444 \
    --bindDN2 "cn=Directory Manager" \
    --bindPassword2 password \
    --replicationPort2 28989 \
    --trustAll \
    --no-prompt
}

initialize_replication() {
echo "### Initializing replication"
  ./ds-rs-1/bin/dsreplication \
    initialize-all \
    --adminUID admin \
    --adminPassword password \
    --baseDN dc=example,dc=com \
    --hostname localhost \
    --port 14444 \
    --trustAll \
    --no-prompt
}

cd "${BASE_DIR}"
for i in 1 2
do
  unpack ${i}
  setup ${i}
  set_server_id ${i}
done
configure_replication
initialize_replication

cd "${CURRENT_DIR}"