Upgrade to DS 7: Add 3 New Servers

Save this as 2a-1-add-ds-7-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.
#!/usr/bin/env bash
set -e

# Add v7 DS/RS, standalone DS, and standalone RS to a deployment with 2 DS/RS 6.5.

ZIP=~/Downloads/DS-7.0.1.zip
CURRENT_DIR=$(pwd)
BASE_DIR=/path/to
FQDN=localhost
DEPLOYMENT_KEY=AMdhPkZJxwoEjwx3zV1IGOccAHNvvQ5CBVN1bkVDdmCLA99ueRm6Cg
DEPLOYMENT_PASSWORD=password

unpack() {
    echo "### Unpacking files for ${server}"
    unzip -q ${ZIP}
    mv opendj ${server}
}

addDsRs() {
    echo "### Adding ds-rs-7 to DS 6.5 topology"

    ./ds-rs-7/setup \
    --serverId 3 \
    --deploymentKey ${DEPLOYMENT_KEY} \
    --deploymentKeyPassword password \
    --rootUserDN uid=admin \
    --rootUserPassword password \
    --adminConnectorPort 34444 \
    --hostname ${FQDN} \
    --ldapPort 31389 \
    --enableStartTls \
    --ldapsPort 31636 \
    --httpsPort 38443 \
    --replicationPort 38989 \
    --profile ds-evaluation \
    --acceptLicense

    ./ds-rs-7/bin/dsconfig \
    set-password-storage-scheme-prop \
    --scheme-name PBKDF2 \
    --set enabled:true \
    --offline \
    --configFile /path/to/ds-rs-7/config/config.ldif \
    --no-prompt

    ./ds-rs-7/bin/dsconfig \
    set-password-storage-scheme-prop \
    --scheme-name "Salted SHA-512" \
    --set enabled:true \
    --offline \
    --configFile /path/to/ds-rs-7/config/config.ldif \
    --no-prompt

    ./ds-rs-7/bin/dsrepl \
    add-local-server-to-pre-7-0-topology \
    --hostname localhost \
    --port 14444 \
    --bindDn "cn=admin,cn=Administrators,cn=admin data" \
    --bindPassword password \
    --baseDn dc=example,dc=com \
    --trustAll \
    --no-prompt

    ./ds-rs-7/bin/start-ds

    ./ds-rs-7/bin/dsrepl \
    initialize \
    --fromServer 1 \
    --hostname localhost \
    --port 34444 \
    --baseDn "cn=admin data" \
    --baseDn "dc=example,dc=com" \
    --baseDn "cn=schema" \
    --bindDN uid=admin \
    --bindPassword password \
    --trustStorePath /path/to/ds-rs-7/config/keystore \
    --trustStorePassword:file /path/to/ds-rs-7/config/keystore.pin \
    --no-prompt
}

addStandaloneDs() {
    echo "### Adding ds-7 to DS 6.5 topology"

    ./ds-7/setup \
    --serverId 4 \
    --deploymentKey ${DEPLOYMENT_KEY} \
    --deploymentKeyPassword password \
    --rootUserDN uid=admin \
    --rootUserPassword password \
    --adminConnectorPort 44444 \
    --hostname ${FQDN} \
    --ldapPort 41389 \
    --enableStartTls \
    --ldapsPort 41636 \
    --httpsPort 48443 \
    --profile ds-evaluation \
    --acceptLicense

    ./ds-7/bin/dsconfig \
    set-password-storage-scheme-prop \
    --scheme-name PBKDF2 \
    --set enabled:true \
    --offline \
    --configFile /path/to/ds-7/config/config.ldif \
    --no-prompt

    ./ds-7/bin/dsconfig \
    set-password-storage-scheme-prop \
    --scheme-name "Salted SHA-512" \
    --set enabled:true \
    --offline \
    --configFile /path/to/ds-7/config/config.ldif \
    --no-prompt

    ./ds-7/bin/dsrepl \
    add-local-server-to-pre-7-0-topology \
    --hostname localhost \
    --port 14444 \
    --bindDn "cn=admin,cn=Administrators,cn=admin data" \
    --bindPassword password \
    --baseDn dc=example,dc=com \
    --trustAll \
    --no-prompt

    ./ds-7/bin/start-ds

    ./ds-7/bin/dsrepl \
    initialize \
    --fromServer 1 \
    --hostname localhost \
    --port 44444 \
    --baseDn "cn=admin data" \
    --baseDn "dc=example,dc=com" \
    --baseDn "cn=schema" \
    --bindDN uid=admin \
    --bindPassword password \
    --trustStorePath /path/to/ds-7/config/keystore \
    --trustStorePassword:file /path/to/ds-7/config/keystore.pin \
    --no-prompt
}

addStandaloneRs() {
    echo "### Adding rs-7 to DS 6.5 topology"

    ./rs-7/setup \
    --serverId 5 \
    --deploymentKey $DEPLOYMENT_KEY \
    --deploymentKeyPassword password \
    --rootUserDN uid=admin \
    --rootUserPassword password \
    --adminConnectorPort 54444 \
    --hostname ${FQDN} \
    --ldapPort 51389 \
    --enableStartTls \
    --ldapsPort 51636 \
    --httpsPort 58443 \
    --replicationPort 58989 \
    --acceptLicense

    ./rs-7/bin/dsconfig \
    set-password-storage-scheme-prop \
    --scheme-name PBKDF2 \
    --set enabled:true \
    --offline \
    --configFile /path/to/rs-7/config/config.ldif \
    --no-prompt

    ./rs-7/bin/dsconfig \
    set-password-storage-scheme-prop \
    --scheme-name "Salted SHA-512" \
    --set enabled:true \
    --offline \
    --configFile /path/to/rs-7/config/config.ldif \
    --no-prompt

    ./rs-7/bin/dsrepl \
    add-local-server-to-pre-7-0-topology \
    --hostname localhost \
    --port 14444 \
    --bindDn "cn=admin,cn=Administrators,cn=admin data" \
    --bindPassword password \
    --baseDn "dc=example,dc=com" \
    --trustAll \
    --no-prompt

    ./rs-7/bin/start-ds

    ./rs-7/bin/dsrepl \
    initialize \
    --fromServer 1 \
    --hostname localhost \
    --port 54444 \
    --baseDn "cn=admin data" \
    --bindDN uid=admin \
    --bindPassword password \
    --trustStorePath /path/to/rs-7/config/keystore \
    --trustStorePassword:file /path/to/rs-7/config/keystore.pin \
    --no-prompt
}

cd "${BASE_DIR}"

for server in ds-rs-7 ds-7 rs-7
do
    unpack ${server}
done

addDsRs
addStandaloneDs
addStandaloneRs

cd "${CURRENT_DIR}"