Customize additional config for postfix's main.cf

Is there a way to add some config directives to /etc/postfix/main.cf in a way that would be compatible with the regen-conftool.

I want to keep smtp_address_preference = ipv4 at the bottom of my /etc/postfix/main.cf but some package is updated, the conf file won’t get updated (same if issueing yunohost tools regen-conf postfix). Then my locally customized file will stay behind what should be necessary :-/

Would there be a way to make sure either my config is in a separate file not touched by regen-conf, or somewhere in a regen-conf file so that it is applied at every updates ?

Is there a kind of placeholder in YuNoHost conf tools for such local configuration “patches” ?

Thanks in advance.

1 Like

cf Share your "hooks" to apply custom configurations- Partagez vos "hooks" pour appliquer des configurations personnelles

1 Like

I’ve added the following hook in /etc/yunohost/hooks.d/conf_regen/20-postfix_smtp_address_preference_ipv4:

#!/bin/bash

# Sets IPv4 preferred on outgoing mail to avoid IPv6 blacklisting

action=$1
pending_dir=$4
postfix_conf=$pending_dir/../postfix/etc/postfix/main.cf

[[ "$action" == "pre" ]] || exit 0
[[ -e $postfix_conf ]] || exit 0
echo '

# ipv4 preferred on outgoing mail to avoid IPv6 blacklisting
smtp_address_preference = ipv4
' >> $postfix_conf

Applying yunohost tools regen-conf -n -d postfix to check if that suits you, and yunohost tools regen-conf --force postfix whenever ready to apply

Not sure if that config is to be recommended, but at least it won’t mess with the rest of the updates of the postfix config, for me.

FWIW, there’s already a switch for ipv6 if you need something more global, in the Mail settings of Yunohost. See Share your "hooks" to apply custom configurations- Partagez vos "hooks" pour appliquer des configurations personnelles - #16 by metyun