mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
scripts: remove PostSRSD wrapper (#3128)
* remove PostSRSD wrapper The setup is now completely done during _actual_ setup phase. The wrapper did not even catch signals (SIGINT, etc.), which I think is strange. I also added all the ENVs the wrapper relied on (which previously could have been unset) to the variables script. * forgot adjusting the `Dockerfile`
This commit is contained in:
parent
b451742f0a
commit
9e2f96448a
|
@ -252,7 +252,6 @@ COPY \
|
||||||
target/bin/* \
|
target/bin/* \
|
||||||
target/scripts/*.sh \
|
target/scripts/*.sh \
|
||||||
target/scripts/startup/*.sh \
|
target/scripts/startup/*.sh \
|
||||||
target/scripts/wrapper/*.sh \
|
|
||||||
/usr/local/bin/
|
/usr/local/bin/
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/*
|
RUN chmod +x /usr/local/bin/*
|
||||||
|
|
|
@ -142,6 +142,51 @@ function _setup_SRS
|
||||||
postconf "sender_canonical_classes = ${SRS_SENDER_CLASSES}"
|
postconf "sender_canonical_classes = ${SRS_SENDER_CLASSES}"
|
||||||
postconf 'recipient_canonical_maps = tcp:localhost:10002'
|
postconf 'recipient_canonical_maps = tcp:localhost:10002'
|
||||||
postconf 'recipient_canonical_classes = envelope_recipient,header_recipient'
|
postconf 'recipient_canonical_classes = envelope_recipient,header_recipient'
|
||||||
|
|
||||||
|
function __generate_secret
|
||||||
|
{
|
||||||
|
(
|
||||||
|
umask 0077
|
||||||
|
dd if=/dev/urandom bs=24 count=1 2>/dev/null | base64 -w0 >"${1}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
local POSTSRSD_SECRET_FILE POSTSRSD_STATE_DIR POSTSRSD_STATE_SECRET_FILE
|
||||||
|
|
||||||
|
sed -i "s/localdomain/${SRS_DOMAINNAME}/g" /etc/default/postsrsd
|
||||||
|
|
||||||
|
POSTSRSD_SECRET_FILE='/etc/postsrsd.secret'
|
||||||
|
POSTSRSD_STATE_DIR='/var/mail-state/etc-postsrsd'
|
||||||
|
POSTSRSD_STATE_SECRET_FILE="${POSTSRSD_STATE_DIR}/postsrsd.secret"
|
||||||
|
|
||||||
|
if [[ -n ${SRS_SECRET} ]]
|
||||||
|
then
|
||||||
|
(
|
||||||
|
umask 0077
|
||||||
|
echo "${SRS_SECRET}" | tr ',' '\n' >"${POSTSRSD_SECRET_FILE}"
|
||||||
|
)
|
||||||
|
else
|
||||||
|
if [[ ${ONE_DIR} -eq 1 ]]
|
||||||
|
then
|
||||||
|
if [[ ! -f ${POSTSRSD_STATE_SECRET_FILE} ]]
|
||||||
|
then
|
||||||
|
install -d -m 0775 "${POSTSRSD_STATE_DIR}"
|
||||||
|
__generate_secret "${POSTSRSD_STATE_SECRET_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -m 0400 "${POSTSRSD_STATE_SECRET_FILE}" "${POSTSRSD_SECRET_FILE}"
|
||||||
|
elif [[ ! -f ${POSTSRSD_SECRET_FILE} ]]
|
||||||
|
then
|
||||||
|
__generate_secret "${POSTSRSD_SECRET_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${SRS_EXCLUDE_DOMAINS} ]]
|
||||||
|
then
|
||||||
|
sed -i \
|
||||||
|
"s/^#\?(SRS_EXCLUDE_DOMAINS=).*$/\1=${SRS_EXCLUDE_DOMAINS}/g" \
|
||||||
|
/etc/default/postsrsd
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setup_postfix_hostname
|
function _setup_postfix_hostname
|
||||||
|
|
|
@ -107,6 +107,13 @@ function __environment_variables_general_setup
|
||||||
VARS[POSTFIX_MESSAGE_SIZE_LIMIT]="${POSTFIX_MESSAGE_SIZE_LIMIT:=10240000}" # ~10 MB
|
VARS[POSTFIX_MESSAGE_SIZE_LIMIT]="${POSTFIX_MESSAGE_SIZE_LIMIT:=10240000}" # ~10 MB
|
||||||
VARS[POSTFIX_DAGENT]="${POSTFIX_DAGENT:=}"
|
VARS[POSTFIX_DAGENT]="${POSTFIX_DAGENT:=}"
|
||||||
|
|
||||||
|
_log 'trace' 'Setting SRS specific environment variables'
|
||||||
|
|
||||||
|
VARS[SRS_DOMAINNAME]="${SRS_DOMAINNAME:=${DOMAINNAME}}"
|
||||||
|
VARS[SRS_EXCLUDE_DOMAINS]="${SRS_EXCLUDE_DOMAINS:=}"
|
||||||
|
VARS[SRS_SECRET]="${SRS_SECRET:=}"
|
||||||
|
VARS[SRS_SENDER_CLASSES]="${SRS_SENDER_CLASSES:=envelope_sender}"
|
||||||
|
|
||||||
_log 'trace' 'Setting miscellaneous environment variables'
|
_log 'trace' 'Setting miscellaneous environment variables'
|
||||||
|
|
||||||
VARS[ACCOUNT_PROVISIONER]="${ACCOUNT_PROVISIONER:=FILE}"
|
VARS[ACCOUNT_PROVISIONER]="${ACCOUNT_PROVISIONER:=FILE}"
|
||||||
|
@ -123,7 +130,6 @@ function __environment_variables_general_setup
|
||||||
VARS[PFLOGSUMM_SENDER]="${PFLOGSUMM_SENDER:=${REPORT_SENDER}}"
|
VARS[PFLOGSUMM_SENDER]="${PFLOGSUMM_SENDER:=${REPORT_SENDER}}"
|
||||||
VARS[PFLOGSUMM_TRIGGER]="${PFLOGSUMM_TRIGGER:=none}"
|
VARS[PFLOGSUMM_TRIGGER]="${PFLOGSUMM_TRIGGER:=none}"
|
||||||
VARS[SMTP_ONLY]="${SMTP_ONLY:=0}"
|
VARS[SMTP_ONLY]="${SMTP_ONLY:=0}"
|
||||||
VARS[SRS_SENDER_CLASSES]="${SRS_SENDER_CLASSES:=envelope_sender}"
|
|
||||||
VARS[SUPERVISOR_LOGLEVEL]="${SUPERVISOR_LOGLEVEL:=warn}"
|
VARS[SUPERVISOR_LOGLEVEL]="${SUPERVISOR_LOGLEVEL:=warn}"
|
||||||
VARS[TZ]="${TZ:=}"
|
VARS[TZ]="${TZ:=}"
|
||||||
VARS[UPDATE_CHECK_INTERVAL]="${UPDATE_CHECK_INTERVAL:=1d}"
|
VARS[UPDATE_CHECK_INTERVAL]="${UPDATE_CHECK_INTERVAL:=1d}"
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# shellcheck source=../helpers/index.sh
|
|
||||||
source /usr/local/bin/helpers/index.sh
|
|
||||||
|
|
||||||
function _generate_secret { ( umask 0077 ; dd if=/dev/urandom bs=24 count=1 2>/dev/null | base64 -w0 > "${1}" ; ) ; }
|
|
||||||
|
|
||||||
_obtain_hostname_and_domainname
|
|
||||||
|
|
||||||
if [[ -n "${SRS_DOMAINNAME}" ]]
|
|
||||||
then
|
|
||||||
NEW_DOMAIN_NAME="${SRS_DOMAINNAME}"
|
|
||||||
else
|
|
||||||
NEW_DOMAIN_NAME="${DOMAINNAME}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i -e "s/localdomain/${NEW_DOMAIN_NAME}/g" /etc/default/postsrsd
|
|
||||||
|
|
||||||
POSTSRSD_SECRET_FILE='/etc/postsrsd.secret'
|
|
||||||
POSTSRSD_STATE_DIR='/var/mail-state/etc-postsrsd'
|
|
||||||
POSTSRSD_STATE_SECRET_FILE="${POSTSRSD_STATE_DIR}/postsrsd.secret"
|
|
||||||
|
|
||||||
if [[ -n ${SRS_SECRET} ]]
|
|
||||||
then
|
|
||||||
( umask 0077 ; echo "${SRS_SECRET}" | tr ',' '\n' > "${POSTSRSD_SECRET_FILE}" ; )
|
|
||||||
else
|
|
||||||
if [[ ${ONE_DIR} -eq 1 ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f ${POSTSRSD_STATE_SECRET_FILE} ]]
|
|
||||||
then
|
|
||||||
install -d -m 0775 "${POSTSRSD_STATE_DIR}"
|
|
||||||
_generate_secret "${POSTSRSD_STATE_SECRET_FILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
install -m 0400 "${POSTSRSD_STATE_SECRET_FILE}" "${POSTSRSD_SECRET_FILE}"
|
|
||||||
elif [[ ! -f ${POSTSRSD_SECRET_FILE} ]]
|
|
||||||
then
|
|
||||||
_generate_secret "${POSTSRSD_SECRET_FILE}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n ${SRS_EXCLUDE_DOMAINS} ]]
|
|
||||||
then
|
|
||||||
sed -i -e "s/^#\?SRS_EXCLUDE_DOMAINS=.*$/SRS_EXCLUDE_DOMAINS=${SRS_EXCLUDE_DOMAINS}/g" /etc/default/postsrsd
|
|
||||||
fi
|
|
||||||
|
|
||||||
/etc/init.d/postsrsd start
|
|
|
@ -148,7 +148,7 @@ autostart=false
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
command=/usr/local/bin/postsrsd-wrapper.sh
|
command=/etc/init.d/postsrsd start
|
||||||
|
|
||||||
[program:update-check]
|
[program:update-check]
|
||||||
startsecs=0
|
startsecs=0
|
||||||
|
|
Loading…
Reference in a new issue