|
|
@@ -215,49 +215,56 @@ EOF
|
|
|
fi
|
|
|
|
|
|
|
|
|
+ function disableReplication() {
|
|
|
+
|
|
|
+ ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-disable.ldif || true
|
|
|
+ [[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION"
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
# replication config
|
|
|
if [ "${LDAP_REPLICATION,,}" == "true" ]; then
|
|
|
|
|
|
+ echo "Use replication"
|
|
|
+
|
|
|
if [ -e "$WAS_STARTED_WITH_REPLICATION" ]; then
|
|
|
- echo "Replication already set"
|
|
|
- else
|
|
|
- echo "Use replication"
|
|
|
+ disableReplication
|
|
|
+ fi
|
|
|
|
|
|
- LDAP_REPLICATION_HOSTS=($LDAP_REPLICATION_HOSTS)
|
|
|
- i=1
|
|
|
- for host in "${LDAP_REPLICATION_HOSTS[@]}"
|
|
|
- do
|
|
|
|
|
|
- # host var contain a variable name, we access to the variable value
|
|
|
- host=${!host}
|
|
|
|
|
|
- sed -i "s|{{ LDAP_REPLICATION_HOSTS }}|olcServerID: $i ${host}\n{{ LDAP_REPLICATION_HOSTS }}|g" /container/service/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/slapd/assets/config/replication/replication-enable.ldif
|
|
|
- sed -i "s|{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}|olcSyncRepl: rid=10$i provider=${host} ${LDAP_REPLICATION_HDB_SYNCPROV}\n{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ LDAP_REPLICATION_HOSTS=($LDAP_REPLICATION_HOSTS)
|
|
|
+ i=1
|
|
|
+ for host in "${LDAP_REPLICATION_HOSTS[@]}"
|
|
|
+ do
|
|
|
|
|
|
- ((i++))
|
|
|
- done
|
|
|
+ # host var contain a variable name, we access to the variable value
|
|
|
+ host=${!host}
|
|
|
|
|
|
- get_ldap_base_dn
|
|
|
- sed -i "s|\$LDAP_BASE_DN|$LDAP_BASE_DN|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
- sed -i "s|\$LDAP_ADMIN_PASSWORD|$LDAP_ADMIN_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
- sed -i "s|\$LDAP_CONFIG_PASSWORD|$LDAP_CONFIG_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ sed -i "s|{{ LDAP_REPLICATION_HOSTS }}|olcServerID: $i ${host}\n{{ LDAP_REPLICATION_HOSTS }}|g" /container/service/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/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ sed -i "s|{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}|olcSyncRepl: rid=10$i provider=${host} ${LDAP_REPLICATION_HDB_SYNCPROV}\n{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
|
|
|
- sed -i "/{{ LDAP_REPLICATION_HOSTS }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
- sed -i "/{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
- sed -i "/{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ ((i++))
|
|
|
+ done
|
|
|
+
|
|
|
+ get_ldap_base_dn
|
|
|
+ sed -i "s|\$LDAP_BASE_DN|$LDAP_BASE_DN|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ sed -i "s|\$LDAP_ADMIN_PASSWORD|$LDAP_ADMIN_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ sed -i "s|\$LDAP_CONFIG_PASSWORD|$LDAP_CONFIG_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+
|
|
|
+ sed -i "/{{ LDAP_REPLICATION_HOSTS }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ sed -i "/{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ sed -i "/{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+
|
|
|
+ ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
+ touch $WAS_STARTED_WITH_REPLICATION
|
|
|
|
|
|
- ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-enable.ldif
|
|
|
- touch $WAS_STARTED_WITH_REPLICATION
|
|
|
- fi
|
|
|
|
|
|
else
|
|
|
|
|
|
echo "Don't use replication"
|
|
|
- [[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION"
|
|
|
- ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-disable.ldif || true
|
|
|
-
|
|
|
- rm -f $WAS_STARTED_WITH_REPLICATION
|
|
|
+ disableReplication
|
|
|
|
|
|
fi
|
|
|
|