Skip to content

Commit eb439bd

Browse files
committed
Merge branch 'hotfix-1.0.5' into stable
2 parents c280273 + 14bccb5 commit eb439bd

File tree

4 files changed

+54
-33
lines changed

4 files changed

+54
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.5
4+
- Use light-baseimage:0.1.4
5+
- Fix replication bug when the hostname was changed
6+
37
## 1.0.4
48
- Use light-baseimage:0.1.3
59

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NAME = osixia/openldap
2-
VERSION = 1.0.4
2+
VERSION = 1.0.5
33

44
.PHONY: all build test tag_latest release
55

image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM osixia/light-baseimage:0.1.3
1+
FROM osixia/light-baseimage:0.1.4
22
MAINTAINER Bertrand Gouny <[email protected]>
33

44
# Use baseimage's init system.

image/service/slapd/container-start.sh

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,19 @@ EOF
104104

105105
# start OpenLDAP
106106
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
118+
fi
119+
108120
echo "[ok]"
109121

110122
# set bootstrap config part 2
@@ -209,55 +221,60 @@ EOF
209221

210222
echo "Don't use TLS"
211223

212-
[[ -f "$WAS_STARTED_WITH_TLS" ]] && rm -f "$WAS_STARTED_WITH_TLS"
213224
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"
214226

215227
fi
216228

217229

230+
function disableReplication() {
231+
echo "Try to disable replication if needed"
232+
ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-disable.ldif || true
233+
[[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION"
234+
}
235+
218236
# replication config
219237
if [ "${LDAP_REPLICATION,,}" == "true" ]; then
220238

221-
if [ -e "$WAS_STARTED_WITH_REPLICATION" ]; then
222-
echo "Replication already set"
223-
else
224-
echo "Use replication"
239+
echo "Use replication"
240+
disableReplication || true
225241

226-
LDAP_REPLICATION_HOSTS=($LDAP_REPLICATION_HOSTS)
227-
i=1
228-
for host in "${LDAP_REPLICATION_HOSTS[@]}"
229-
do
242+
LDAP_REPLICATION_HOSTS=($LDAP_REPLICATION_HOSTS)
243+
i=1
244+
for host in "${LDAP_REPLICATION_HOSTS[@]}"
245+
do
230246

231-
# host var contain a variable name, we access to the variable value
232-
host=${!host}
247+
# host var contain a variable name, we access to the variable value
248+
host=${!host}
233249

234-
sed -i "s|{{ LDAP_REPLICATION_HOSTS }}|olcServerID: $i ${host}\n{{ LDAP_REPLICATION_HOSTS }}|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
235-
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
236-
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
250+
sed -i "s|{{ LDAP_REPLICATION_HOSTS }}|olcServerID: $i ${host}\n{{ LDAP_REPLICATION_HOSTS }}|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
251+
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
252+
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
237253

238-
((i++))
239-
done
254+
((i++))
255+
done
240256

241-
get_ldap_base_dn
242-
sed -i "s|\$LDAP_BASE_DN|$LDAP_BASE_DN|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
243-
sed -i "s|\$LDAP_ADMIN_PASSWORD|$LDAP_ADMIN_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
244-
sed -i "s|\$LDAP_CONFIG_PASSWORD|$LDAP_CONFIG_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
257+
get_ldap_base_dn
258+
sed -i "s|\$LDAP_BASE_DN|$LDAP_BASE_DN|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
259+
sed -i "s|\$LDAP_ADMIN_PASSWORD|$LDAP_ADMIN_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
260+
sed -i "s|\$LDAP_CONFIG_PASSWORD|$LDAP_CONFIG_PASSWORD|g" /container/service/slapd/assets/config/replication/replication-enable.ldif
245261

246-
sed -i "/{{ LDAP_REPLICATION_HOSTS }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
247-
sed -i "/{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
248-
sed -i "/{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
262+
sed -i "/{{ LDAP_REPLICATION_HOSTS }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
263+
sed -i "/{{ LDAP_REPLICATION_HOSTS_CONFIG_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
264+
sed -i "/{{ LDAP_REPLICATION_HOSTS_HDB_SYNC_REPL }}/d" /container/service/slapd/assets/config/replication/replication-enable.ldif
249265

250-
ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-enable.ldif
251-
touch $WAS_STARTED_WITH_REPLICATION
252-
fi
266+
echo "Enable replication"
267+
ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-enable.ldif || true
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
253273

254274
else
255275

256276
echo "Don't use replication"
257-
[[ -f "$WAS_STARTED_WITH_REPLICATION" ]] && rm -f "$WAS_STARTED_WITH_REPLICATION"
258-
ldapmodify -c -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/replication/replication-disable.ldif || true
259-
260-
rm -f $WAS_STARTED_WITH_REPLICATION
277+
disableReplication || true
261278

262279
fi
263280

0 commit comments

Comments
 (0)