Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable passing FQDN via environment variable #581

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
image: osixia/openldap:1.5.0
container_name: openldap
environment:
#FQDN: "ldap-server.example.org"
LDAP_LOG_LEVEL: "256"
LDAP_ORGANISATION: "Example Inc."
LDAP_DOMAIN: "example.org"
Expand Down Expand Up @@ -39,9 +40,10 @@ services:
ports:
- "389:389"
- "636:636"
# For replication to work correctly, domainname and hostname must be
# For replication to work correctly, either domainname and hostname must be
# set correctly so that "hostname"."domainname" equates to the
# fully-qualified domain name for the host.
# fully-qualified domain name for the host
# or the FQDN is provided directly as environment variable (see above).
domainname: "example.org"
hostname: "ldap-server"
phpldapadmin:
Expand Down
8 changes: 5 additions & 3 deletions image/service/slapd/process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ log-helper level eq trace && set -x
# see https://github.com/docker/docker/issues/8231
ulimit -n $LDAP_NOFILE

# Call hostname to determine the fully qualified domain name. We want OpenLDAP to listen
# to the named host for the ldap:// and ldaps:// protocols.
FQDN="$(/bin/hostname --fqdn)"
# We want OpenLDAP to listen to the named host for the ldap:// and ldaps:// protocols.
if [ -z "$FQDN" ]; then
# Only call hostname if the fully qualified domain name wasn't provided as environment variable.
FQDN="$(/bin/hostname --fqdn)"
fi
HOST_PARAM="ldap://$FQDN:$LDAP_PORT ldaps://$FQDN:$LDAPS_PORT"
exec /usr/sbin/slapd -h "$HOST_PARAM ldapi:///" -u openldap -g openldap -d "$LDAP_LOG_LEVEL"
6 changes: 4 additions & 2 deletions image/service/slapd/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,10 @@ ln -sf ${CONTAINER_SERVICE_DIR}/slapd/assets/ldap.conf /etc/ldap/ldap.conf
# force OpenLDAP to listen on all interfaces
# We need to make sure that /etc/hosts continues to include the
# fully-qualified domain name and not just the specified hostname.
# Without the FQDN, /bin/hostname --fqdn stops working.
FQDN="$(/bin/hostname --fqdn)"
if [ -z "$FQDN" ]; then
# Only call hostname if the fully qualified domain name wasn't provided as environment variable.
FQDN="$(/bin/hostname --fqdn)"
fi
if [ "$FQDN" != "$HOSTNAME" ]; then
FQDN_PARAM="$FQDN"
else
Expand Down