scripts: improve custom user-supplied Postfix configuration (#2598)

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
Georg Lauterbach 2022-06-06 09:30:10 +02:00 committed by GitHub
parent 1f3e672018
commit 0010786d18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 34 deletions

View file

@ -731,20 +731,15 @@ function _setup_postfix_virtual_transport
function _setup_postfix_override_configuration
{
_log 'trace' 'Setting up Postfix Override configuration'
_log 'debug' 'Overriding / adjusting Postfix configuration with user-supplied values'
if [[ -f /tmp/docker-mailserver/postfix-main.cf ]]
then
while read -r LINE
do
# all valid postfix options start with a lower case letter
# http://www.postfix.org/postconf.5.html
if [[ ${LINE} =~ ^[a-z] ]]
then
postconf -e "${LINE}"
fi
done < /tmp/docker-mailserver/postfix-main.cf
_log 'trace' "Loaded '/tmp/docker-mailserver/postfix-main.cf'"
cat /tmp/docker-mailserver/postfix-main.cf >>/etc/postfix/main.cf
# do not directly output to 'main.cf' as this causes a read-write-conflict
postconf -n >/tmp/postfix-main-new.cf 2>/dev/null
mv /tmp/postfix-main-new.cf /etc/postfix/main.cf
_log 'trace' "Adjusted '/etc/postfix/main.cf' according to '/tmp/docker-mailserver/postfix-main.cf'"
else
_log 'trace' "No extra Postfix settings loaded because optional '/tmp/docker-mailserver/postfix-main.cf' was not provided"
fi
@ -758,7 +753,7 @@ function _setup_postfix_override_configuration
postconf -P "${LINE}"
fi
done < /tmp/docker-mailserver/postfix-master.cf
_log 'trace' "Loaded '/tmp/docker-mailserver/postfix-master.cf'"
_log 'trace' "Adjusted '/etc/postfix/master.cf' according to '/tmp/docker-mailserver/postfix-master.cf'"
else
_log 'trace' "No extra Postfix settings loaded because optional '/tmp/docker-mailserver/postfix-master.cf' was not provided"
fi