Apply shfmt on docker-entrypoint

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-03-14 16:08:08 +01:00
parent ae3b721b32
commit 005b43c4e4
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -10,7 +10,7 @@ declare -a dc_parts=(${SLAPD_DOMAIN:-example.com})
unset IFS
for dc_part in "${dc_parts[@]}"; do
dc_string="${dc_string:-},dc=${dc_part}"
dc_string="${dc_string:-},dc=${dc_part}"
done
export SLAPD_SUFFIX=${dc_string#,}
@ -20,63 +20,63 @@ cp -r /config/modules /etc/openldap/
# Configure and start slapd
if [ "${1:-}" = 'slapd' ]; then
# When not limiting the open file descritors limit, the memory consumption of
# slapd is absurdly high. See https://github.com/docker/docker/issues/8231
ulimit -n 8192
# When not limiting the open file descritors limit, the memory consumption of
# slapd is absurdly high. See https://github.com/docker/docker/issues/8231
ulimit -n 8192
# Fix missing directory
mkdir -p /run/openldap && chown ldap:ldap /run/openldap
# Fix missing directory
mkdir -p /run/openldap && chown ldap:ldap /run/openldap
# Generate templates
korvike -i /config/slapd.conf -o /etc/openldap/slapd.conf
korvike -i /config/slapd.ldif -o /etc/openldap/slapd.ldif
korvike -i /config/init.ldif -o /tmp/init.ldif
# Generate templates
korvike -i /config/slapd.conf -o /etc/openldap/slapd.conf
korvike -i /config/slapd.ldif -o /etc/openldap/slapd.ldif
korvike -i /config/init.ldif -o /tmp/init.ldif
if ! [ -d "${SLAPD_CONFDIR}/cn=config" ]; then
# Generate basic configuration
mkdir -p ${SLAPD_CONFDIR}
slapadd -n 0 -F ${SLAPD_CONFDIR} -l /etc/openldap/slapd.ldif
slapadd -F ${SLAPD_CONFDIR} -b ${SLAPD_SUFFIX} -l /tmp/init.ldif
if ! [ -d "${SLAPD_CONFDIR}/cn=config" ]; then
# Generate basic configuration
mkdir -p ${SLAPD_CONFDIR}
slapadd -n 0 -F ${SLAPD_CONFDIR} -l /etc/openldap/slapd.ldif
slapadd -F ${SLAPD_CONFDIR} -b ${SLAPD_SUFFIX} -l /tmp/init.ldif
# Load schemas into configuration database
if [ -n "$SLAPD_ADDITIONAL_SCHEMAS" ]; then
IFS=","
declare -a schemas=($SLAPD_ADDITIONAL_SCHEMAS)
unset IFS
# Load schemas into configuration database
if [ -n "$SLAPD_ADDITIONAL_SCHEMAS" ]; then
IFS=","
declare -a schemas=($SLAPD_ADDITIONAL_SCHEMAS)
unset IFS
for schema in "${schemas[@]}"; do
slapadd -n 0 -F ${SLAPD_CONFDIR} -l "/etc/openldap/schema/${schema}.ldif"
done
fi
for schema in "${schemas[@]}"; do
slapadd -n 0 -F ${SLAPD_CONFDIR} -l "/etc/openldap/schema/${schema}.ldif"
done
fi
# Activate module configurations
if [ -n "$SLAPD_ADDITIONAL_MODULES" ]; then
IFS=","
declare -a modules=($SLAPD_ADDITIONAL_MODULES)
unset IFS
# Activate module configurations
if [ -n "$SLAPD_ADDITIONAL_MODULES" ]; then
IFS=","
declare -a modules=($SLAPD_ADDITIONAL_MODULES)
unset IFS
for module in "${modules[@]}"; do
module_file="/etc/openldap/modules/${module}.ldif"
for module in "${modules[@]}"; do
module_file="/etc/openldap/modules/${module}.ldif"
if [ "$module" == 'ppolicy' ]; then
SLAPD_PPOLICY_DN_PREFIX="${SLAPD_PPOLICY_DN_PREFIX:-cn=default,ou=policies}"
if [ "$module" == 'ppolicy' ]; then
SLAPD_PPOLICY_DN_PREFIX="${SLAPD_PPOLICY_DN_PREFIX:-cn=default,ou=policies}"
sed -i "s/\(olcPPolicyDefault: \)PPOLICY_DN/\1${SLAPD_PPOLICY_DN_PREFIX}$dc_string/g" $module_file
fi
sed -i "s/\(olcPPolicyDefault: \)PPOLICY_DN/\1${SLAPD_PPOLICY_DN_PREFIX}$dc_string/g" $module_file
fi
slapadd -n0 -F ${SLAPD_CONFDIR} -l "$module_file"
done
fi
slapadd -n0 -F ${SLAPD_CONFDIR} -l "$module_file"
done
fi
chown -R ldap:ldap ${SLAPD_CONFDIR} ${SLAPD_DATADIR}
else
# Check for configuration variables when container is already configured
if (env | grep -q "SLAPD_"); then
echo "Info: LDAP container is already configured, SLAPD_* env variables are ignored."
fi
fi
chown -R ldap:ldap ${SLAPD_CONFDIR} ${SLAPD_DATADIR}
else
# Check for configuration variables when container is already configured
if (env | grep -q "SLAPD_"); then
echo "Info: LDAP container is already configured, SLAPD_* env variables are ignored."
fi
fi
exec "$@"
exec "$@"
fi
# Other binary was called, execute directly