Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting arbitrary postfix configuration values #80

Open
telmich opened this issue Apr 23, 2022 · 3 comments
Open

Add support for setting arbitrary postfix configuration values #80

telmich opened this issue Apr 23, 2022 · 3 comments

Comments

@telmich
Copy link

telmich commented Apr 23, 2022

Situation

Postfix has a lot of options and it is hard/impossible to support all of them in the image.
However, we can add rather generic support for any kind of option the following way.

Looking for POSTFIX_* and setting it

I suggest to add to run.sh something on the line of:

for var in $(set | grep POSTFIX_); do
   keyname=${var#POSTFIX_}
   eval value=\$$var
  postconf -e "$keyname = $value"
done

This should work for arbitrary values .

@Speeder2000
Copy link

Speeder2000 commented Apr 26, 2022

I'd echo the request but beyond just variables.

I wanted to add some custom header re-writes due to n HP printer issue. I ended up mounting a path within the docker with script.sh and executing the script via scheduled docker exec.

Maybe it's worth adding a line in run.sh that checks for presence of an /external/script.sh and executes it if it's present? That way users can simply add their postconf commands, echo, etc. to script.sh and it gets run on compose?

@juanluisbaptiste
Copy link
Owner

Hi @telmich and @Speeder2000, thanks for your input.

This container started as a simple way to use a relay to allow docker containers to send email, but it has grown beyond that goal since then. I agree that it would be nice to make this image more generic to allow it to be used in more use cases, but we should not make it more complex to use.

This means that current configuration cannot be broken, the image must continue to work as it currently does, to avoid breaking current installations. For example, handling of cases where there is already an env variable for a config option, but it is also present in a custom configuration variable.

Currently, I do not have the time to work on this, if you are willing to send a PR implementing this, prior to a discussion on how you plan on doing it, I will be happy to review it and then merge it.

@flojon
Copy link

flojon commented Jul 23, 2022

Hi,

I took a shot at improving @telmich suggestion.

This should be working. It will make keyname lowercase. So, e.g.,
POSTFIX_VIRTUAL_TRANSPORT=xyz becomes virtual_transport = xyz

for var in "${!POSTFIX_@}"; do
    keyname=$(echo ${var#POSTFIX_} | tr '[:upper:]' '[:lower:]')
    value=${!var}
    postconf -e "$keyname = $value"
done

If we want to avoid these POSTFIX_ environment variables overwriting any of the existing environment variables we could have a list of reserved keynames and check against that one before calling postconf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants