mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-06-23 17:29:08 +02:00
HOSTNAME and DOMAINNAME setting improvements (#2175)
Centralize the collection of the HOSTNAME and DOMAINAME so that it's predictable and uniform across the various scripts (using the helper). Ensure it supports the various configurations users can have (both subdomain and without subdomain, override and no override). --- * using _obtain_hostname_and_domainname helper + covers when not a subdomain doc: OVERRIDE_HOSTNAME takes priority * added tests for non-subdomain hostname + further improvements * moved SRS DOMAINANME tests into hostname test file + Allowing DOMAINNAME ENV to override what would be automatically set --- Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
parent
8e91251d8c
commit
c267d8a990
10 changed files with 239 additions and 150 deletions
|
@ -209,6 +209,31 @@ function _monitored_files_checksums
|
|||
}
|
||||
export -f _monitored_files_checksums
|
||||
|
||||
# ? --------------------------------------------- General
|
||||
|
||||
function _obtain_hostname_and_domainname
|
||||
{
|
||||
if [[ -n "${OVERRIDE_HOSTNAME}" ]]
|
||||
then
|
||||
export HOSTNAME="${OVERRIDE_HOSTNAME}"
|
||||
export DOMAINNAME="${DOMAINNAME:-${HOSTNAME#*.}}"
|
||||
# Handle situations where the hostname is name.tld and hostname -d ends up just showing "tld"
|
||||
if [[ ! "${DOMAINNAME}" =~ .*\..* ]]
|
||||
then
|
||||
DOMAINNAME="${HOSTNAME}"
|
||||
fi
|
||||
else
|
||||
# These hostname commands will fail with "hostname: Name or service not known"
|
||||
# if the hostname is not valid (important for tests)
|
||||
HOSTNAME="$(hostname -f)"
|
||||
DOMAINNAME="${DOMAINNAME:-$(hostname -d)}"
|
||||
if [[ ! "${DOMAINNAME}" =~ .*\..* ]]
|
||||
then
|
||||
DOMAINNAME="${HOSTNAME}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function _shutdown
|
||||
{
|
||||
_notify 'err' "Shutting down.."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue