|
104 | 104 |
|
105 | 105 | # start OpenLDAP |
106 | 106 | echo "Starting openldap..." |
107 | | - slapd -h "ldap://$HOSTNAME ldap://localhost ldapi:///" -u openldap -g openldap |
| 107 | + |
| 108 | + # start OpenLDAP with previous replication configuration |
| 109 | + if [ -e "$WAS_STARTED_WITH_REPLICATION" ]; then |
| 110 | + |
| 111 | + . $WAS_STARTED_WITH_REPLICATION |
| 112 | + echo "127.0.0.2 $PREVIOUS_HOSTNAME" >> /etc/hosts |
| 113 | + |
| 114 | + slapd -h "ldap://$HOSTNAME ldap://$PREVIOUS_HOSTNAME ldap://localhost ldapi:///" -u openldap -g openldap |
| 115 | + else |
| 116 | + #start openldap normaly |
| 117 | + slapd -h "ldap://$HOSTNAME ldap://localhost ldapi:///" -u openldap -g openldap -d -1 |
| 118 | + fi |
| 119 | + |
108 | 120 | echo "[ok]" |
109 | 121 |
|
110 | 122 | # set bootstrap config part 2 |
@@ -209,27 +221,23 @@ EOF |
209 | 221 |
|
210 | 222 | echo "Don't use TLS" |
211 | 223 |
|
212 | | - [[ -f "$WAS_STARTED_WITH_TLS" ]] && rm -f "$WAS_STARTED_WITH_TLS" |
213 | 224 | ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/tls/tls-disable.ldif || true |
| 225 | + [[ -f "$WAS_STARTED_WITH_TLS" ]] && rm -f "$WAS_STARTED_WITH_TLS" |
214 | 226 |
|
215 | 227 | fi |
216 | 228 |
|
217 | 229 |
|
218 | 230 | function disableReplication() { |
219 | | - |
| 231 | + echo "Try to disable replication if needed" |
220 | 232 | ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-disable.ldif || true |
221 | 233 | [[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION" |
222 | | - |
223 | 234 | } |
224 | 235 |
|
225 | 236 | # replication config |
226 | 237 | if [ "${LDAP_REPLICATION,,}" == "true" ]; then |
227 | 238 |
|
228 | 239 | echo "Use replication" |
229 | | - |
230 | | - if [ -e "$WAS_STARTED_WITH_REPLICATION" ]; then |
231 | | - disableReplication |
232 | | - fi |
| 240 | + disableReplication || true |
233 | 241 |
|
234 | 242 | LDAP_REPLICATION_HOSTS=($LDAP_REPLICATION_HOSTS) |
235 | 243 | i=1 |
|
255 | 263 | sed -i "/{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif |
256 | 264 | sed -i "/{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif |
257 | 265 |
|
258 | | - ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-enable.ldif |
259 | | - touch $WAS_STARTED_WITH_REPLICATION |
| 266 | + echo "Enable replication" |
| 267 | + ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-enable.ldif || true |
260 | 268 |
|
| 269 | + [[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION" |
| 270 | + touch $WAS_STARTED_WITH_REPLICATION |
| 271 | + echo "export PREVIOUS_HOSTNAME=${HOSTNAME}" >> $WAS_STARTED_WITH_REPLICATION |
| 272 | + chmod +x $WAS_STARTED_WITH_REPLICATION |
261 | 273 |
|
262 | 274 | else |
263 | 275 |
|
|
0 commit comments