kubernetes fix (#484)

* Allow OVERRIDE_HOSTNAME
* Document the new environment variable
This commit is contained in:
Kevin Crawley 2017-01-20 16:30:29 -06:00 committed by Thomas VIAL
parent 480113901e
commit 16c90fc52a
4 changed files with 31 additions and 14 deletions

View file

@ -47,8 +47,9 @@ run:
-v "`pwd`/test/config":/tmp/docker-mailserver \
-v "`pwd`/test":/tmp/docker-mailserver-test \
-e SMTP_ONLY=1 \
-e PERMIT_DOCKER=network\
-h mail.my-domain.com -t $(NAME)
-e PERMIT_DOCKER=network \
-e OVERRIDE_HOSTNAME=mail.my-domain.com \
-t $(NAME)
sleep 15
docker run -d --name mail_fail2ban \
-v "`pwd`/test/config":/tmp/docker-mailserver \

View file

@ -201,6 +201,11 @@ Otherwise, `iptables` won't be able to ban IPs.
- **empty** => admin
- => Specify the password to bind against ldap
##### OVERRIDE_HOSTNAE
- **empty** => uses the `hostname` command to get the mail server's canonical hostname
- => Specify a fully-qualified domainname to serve mail for. This is used for many of the config features so if you can't set your hostname (e.g. you're in a container platform that doesn't let you) specify it in this environment variable.
##### POSTMASTER_ADDRESS
- **empty** => postmaster@domain.com

View file

@ -18,6 +18,7 @@ DEFAULT_VARS["ENABLE_SASLAUTHD"]="${ENABLE_SASLAUTHD:="0"}"
DEFAULT_VARS["SMTP_ONLY"]="${SMTP_ONLY:="0"}"
DEFAULT_VARS["VIRUSMAILS_DELETE_DELAY"]="${VIRUSMAILS_DELETE_DELAY:="7"}"
DEFAULT_VARS["DMS_DEBUG"]="${DMS_DEBUG:="0"}"
DEFAULT_VARS["OVERRIDE_HOSTNAME"]="${OVERRIDE_HOSTNAME}"
##########################################################################
# << DEFAULT VARS
##########################################################################
@ -94,6 +95,7 @@ function register_functions() {
_register_setup_function "_setup_docker_permit"
_register_setup_function "_setup_mailname"
_register_setup_function "_setup_amavis"
_register_setup_function "_setup_postfix_override_configuration"
_register_setup_function "_setup_postfix_sasl_password"
@ -158,7 +160,7 @@ function register_functions() {
_register_start_daemon "_start_daemons_clamav"
fi
_register_start_daemon "_start_daemons_amavis"
_register_start_daemon "_start_daemons_amavis"
################### << daemon funcs
}
##########################################################################
@ -315,12 +317,18 @@ function check() {
}
function _check_hostname() {
notify "task" "Check that hostname/domainname is provided (no default docker hostname) [$FUNCNAME]"
notify "task" "Check that hostname/domainname is provided or overidden (no default docker hostname/kubernetes) [$FUNCNAME]"
if [[ ! -z ${DEFAULT_VARS["OVERRIDE_HOSTNAME"]} ]]; then
export HOSTNAME=${DEFAULT_VARS["OVERRIDE_HOSTNAME"]}
export DOMAINNAME=$(echo $HOSTNAME | sed s/[^.]*.//)
fi
if ( ! echo $HOSTNAME | grep -E '^(\S+[.]\S+)$' > /dev/null ); then
notify 'err' "Setting hostname/domainname is required"
return 1
else
notify 'inf' "Domain has been set to $DOMAINNAME"
notify 'inf' "Hostname has been set to $HOSTNAME"
return 0
fi
@ -364,6 +372,13 @@ function _setup_mailname() {
echo $DOMAINNAME > /etc/mailname
}
function _setup_amavis() {
notify 'task' 'Setting up Amavis'
notify 'inf' "Applying hostname to /etc/amavis/conf.d/05-node_id"
sed -i 's/^#\$myhostname = "mail.example.com";/\$myhostname = "'$HOSTNAME'";/' /etc/amavis/conf.d/05-node_id
}
function _setup_dovecot() {
notify 'task' 'Setting up Dovecot'
@ -1011,17 +1026,8 @@ function _start_daemons_clamav() {
function _start_daemons_amavis() {
notify 'task' 'Starting amavis' 'n'
display_startup_daemon "/etc/init.d/amavis start"
# @TODO fix: on integration test of mail_with_ldap amavis fails because of:
# Starting amavisd: The value of variable $myhostname is "ldap", but should have been
# a fully qualified domain name; perhaps uname(3) did not provide such.
# You must explicitly assign a FQDN of this host to variable $myhostname
# in /etc/amavis/conf.d/05-node_id, or fix what uname(3) provides as a host's
# network name!
# > temporary workaround to pass integration test
return 0
}
##########################################################################
# << Start Daemons
##########################################################################

View file

@ -9,6 +9,11 @@ load 'test_helper/bats-assert/load'
assert_failure
}
@test "checking configuration: hostname/domainname override" {
run docker exec mail_smtponly /bin/bash -c "cat /etc/mailname | grep my-domain.com"
assert_success
}
#
# processes
#