Skip to content

Commit 90584b4

Browse files
Fix #49
Environment variables are optional, but set -eux raises an error when they are not used. Fix: assign a default value before testing the variables.
1 parent 657d012 commit 90584b4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

rootfs/etc/cont-init.d/050-openldap-populate

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ load_initial_data() {
4040
local data=$(find ${DATA_DIR} -maxdepth 1 -name \*_\*.ldif -type f | sort)
4141
for ldif in ${data}; do
4242
echo "Processing file ${ldif}..."
43-
if [ ! -z "$LDAP_BASEDN" ]; then
44-
echo "updating base dn dc=planetexpress,dc=com -> ${LDAP_BASEDN}"
45-
sed -i "s/dc=planetexpress,dc=com/${LDAP_BASEDN}/g" "${ldif}"
43+
44+
base_dn=${LDAP_BASEDN:-}
45+
if [ ! -z "${base_dn}" ]; then
46+
echo "updating base dn dc=planetexpress,dc=com -> ${base_dn}"
47+
sed -i "s/dc=planetexpress,dc=com/${base_dn}/g" "${ldif}"
4648
fi
47-
if [ "$LDAP_DOMAIN" != "planetexpress.com" ]; then
48-
echo "updating emails @planetexpress.com -> @${LDAP_DOMAIN}"
49-
sed -i "s/@planetexpress.com/@${LDAP_DOMAIN}/g" "${ldif}"
49+
50+
domain=${LDAP_DOMAIN:-}
51+
if [ "${domain}" != "planetexpress.com" ]; then
52+
echo "updating emails @planetexpress.com -> @${domain}"
53+
sed -i "s/@planetexpress.com/@${domain}/g" "${ldif}"
5054
fi
5155

5256
ldapadd -x -H ldapi:/// \

0 commit comments

Comments
 (0)