mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
* Add submodule docker-configomat * Add configomat.sh to Dockerfile * Replaced override_config with configomat.sh
This commit is contained in:
parent
21fb3f3c86
commit
dbf65789f2
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -7,3 +7,6 @@
|
|||
[submodule "test/test_helper/bats-assert"]
|
||||
path = test/test_helper/bats-assert
|
||||
url = https://github.com/ztombol/bats-assert
|
||||
[submodule "target/docker-configomat"]
|
||||
path = target/docker-configomat
|
||||
url = https://github.com/alinmear/docker-configomat
|
||||
|
|
|
@ -144,7 +144,7 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem > /et
|
|||
|
||||
COPY ./target/bin /usr/local/bin
|
||||
# Start-mailserver script
|
||||
COPY ./target/start-mailserver.sh /usr/local/bin/
|
||||
COPY ./target/start-mailserver.sh ./target/docker-configomat/configomat.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/*
|
||||
|
||||
EXPOSE 25 587 143 993 110 995 4190
|
||||
|
|
1
target/docker-configomat
Submodule
1
target/docker-configomat
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit e3e84ded29d88b2945c0782dbb43237c561a54a9
|
|
@ -316,50 +316,6 @@ function display_startup_daemon() {
|
|||
return $res
|
||||
}
|
||||
|
||||
function override_config() {
|
||||
notify "task" "Starting do do overrides"
|
||||
|
||||
declare -A config_overrides
|
||||
|
||||
_env_variable_prefix=$1
|
||||
[ -z ${_env_variable_prefix} ] && return 1
|
||||
|
||||
|
||||
IFS=" " read -r -a _config_files <<< $2
|
||||
|
||||
# dispatch env variables
|
||||
for env_variable in $(printenv | grep $_env_variable_prefix);do
|
||||
# get key
|
||||
# IFS not working because values like ldap_query_filter or search base consists of several '='
|
||||
# IFS="=" read -r -a __values <<< $env_variable
|
||||
# key="${__values[0]}"
|
||||
# value="${__values[1]}"
|
||||
key=$(echo $env_variable | cut -d "=" -f1)
|
||||
key=${key#"${_env_variable_prefix}"}
|
||||
# make key lowercase
|
||||
key=${key,,}
|
||||
# get value
|
||||
value=$(echo $env_variable | cut -d "=" -f2-)
|
||||
|
||||
config_overrides[$key]=$value
|
||||
done
|
||||
|
||||
for f in "${_config_files[@]}"
|
||||
do
|
||||
if [ ! -f "${f}" ];then
|
||||
echo "Can not find ${f}. Skipping override"
|
||||
else
|
||||
for key in ${!config_overrides[@]}
|
||||
do
|
||||
[ -z $key ] && echo -e "\t no key provided" && return 1
|
||||
|
||||
sed -i -e "s|^${key}[[:space:]]\+.*|${key} = ${config_overrides[$key]//&/\\&}|g" \
|
||||
${f}
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
# ! CARE --> DON'T CHANGE, except you know exactly what you are doing
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
@ -579,7 +535,7 @@ function _setup_ldap() {
|
|||
[[ $f =~ ldap-user ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_USER}"
|
||||
[[ $f =~ ldap-group ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_GROUP}"
|
||||
[[ $f =~ ldap-aliases ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_ALIAS}"
|
||||
override_config "LDAP_" "${f}"
|
||||
configomat.sh "LDAP_" "${f}"
|
||||
done
|
||||
|
||||
notify 'inf' "Configuring dovecot LDAP"
|
||||
|
@ -598,7 +554,7 @@ function _setup_ldap() {
|
|||
export $var=${_dovecot_ldap_mapping[$var]}
|
||||
done
|
||||
|
||||
override_config "DOVECOT_" "/etc/dovecot/dovecot-ldap.conf.ext"
|
||||
configomat.sh "DOVECOT_" "/etc/dovecot/dovecot-ldap.conf.ext"
|
||||
|
||||
# Add domainname to vhost.
|
||||
echo $DOMAINNAME >> /tmp/vhost.tmp
|
||||
|
@ -763,7 +719,8 @@ function _setup_ssl() {
|
|||
case $SSL_TYPE in
|
||||
"letsencrypt" )
|
||||
# letsencrypt folders and files mounted in /etc/letsencrypt
|
||||
if [ -e "/etc/letsencrypt/live/$HOSTNAME/fullchain.pem" ]; then
|
||||
if [ -e "/etc/letsencrypt/live/$HOSTNAME/cert.pem" ] \
|
||||
&& [ -e "/etc/letsencrypt/live/$HOSTNAME/fullchain.pem" ]; then
|
||||
KEY=""
|
||||
if [ -e "/etc/letsencrypt/live/$HOSTNAME/privkey.pem" ]; then
|
||||
KEY="privkey"
|
||||
|
|
Loading…
Reference in a new issue