Skip to content

feat: allow adding arbitrary postfix config, allow running post-setup script (fixes #80)#139

Open
Vosjedev wants to merge 1 commit into
juanluisbaptiste:masterfrom
Vosjedev:master
Open

feat: allow adding arbitrary postfix config, allow running post-setup script (fixes #80)#139
Vosjedev wants to merge 1 commit into
juanluisbaptiste:masterfrom
Vosjedev:master

Conversation

@Vosjedev
Copy link
Copy Markdown

@Vosjedev Vosjedev commented Apr 29, 2026

Mostly follows the suggestions from
#80

usage: environment variables can be supplied in format POSTFIX_<option>
to set them using postconf automatically.
usage: mount or copy an executable as /post-setup.sh to have it automatically be run after init, and before postfix start

Description of the change

This allows changing postfix (main.cf) options via environment variables. The code used is modified from @flojon's suggestion in #80 to be using native bash instead of invocing tr. The used syntax is bash 4+, but the image already ships bash 5+, so it's fine.
Next to that, a check has been added that executes /post-setup.sh when it exists and is executable. This doens't have to be a shellscript, it just have to be executable (maybe I should remove the .sh suffix then? idk.)

Motivation and Context

The main motivation is because I would like to add ~5 options to my main.cf, and reading the suggestions in #80, I thought I'd do the job and submit the changes as a PR.

How Has This Been Tested?

It has been tested manually, both specifying uppercase and lowercase configuration options prefixed with POSTFIX_ in the env. The script was also tested manually, by mounting a shellscript with the content #!/bin/sh\necho HELLO WORLD and seeing whether we got the text back.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • My change adds a new configuration variable and I have updated the .env.example file accordingly.

for now this PR is marked WIP, I have some more work to do (like updating docs and fixing my indentation) but I'll do that soon too.

@Vosjedev Vosjedev force-pushed the master branch 2 times, most recently from 33a3aa2 to d5f9607 Compare April 29, 2026 17:06
@Vosjedev
Copy link
Copy Markdown
Author

I've added documentation. Let me know if anything else needs to happen before this is mergeable.

@Vosjedev Vosjedev marked this pull request as ready for review April 29, 2026 17:08
@juanluisbaptiste
Copy link
Copy Markdown
Owner

Hi @Vosjedev thanks for the PR! I will review it and get back to you.

@juanluisbaptiste
Copy link
Copy Markdown
Owner

Hi @Vosjedev I left you a review, please take a look at it and adjust documentation accordingly.

@Vosjedev
Copy link
Copy Markdown
Author

Good afternoon,
I am not sure whether your review arrived correctly, I'm not seeing it anywhere (though I may just be looking incorrectly).

Sorry for the delayed response, I have gotten busier in the last week so my replies may be slow until the end of next week.

Copy link
Copy Markdown
Owner

@juanluisbaptiste juanluisbaptiste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I forgot to submit the review.

Comment thread run.sh Outdated
Comment thread run.sh Outdated
@Vosjedev
Copy link
Copy Markdown
Author

No problem, that can happen. I integrated your requests, if there is anything else wrong, just ask.

That way, the custom script would have access to run.sh functions like add_config_value and all the variables being set, including DEBUG

I was thinking maybe it's a good idea to document these two variables then, so if you think that's a good idea too I can try to come up with reasonable phrasing for that without making it too confusing for someone who doesn't need the feature. Let me know in that case!

@juanluisbaptiste
Copy link
Copy Markdown
Owner

@Vosjedev thanks, I will test and let you know.

Comment thread run.sh
# Custom configuration options

# via env vars for easy configuring
for var in "${!POSTFIX_@}"; do
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an echo before this loop, to let the user know that the options being set from this point onwards are custom. Something like "Setting custom Postfix configuration parameters using POSTFIX_* variables..." or similar.

Copy link
Copy Markdown
Owner

@juanluisbaptiste juanluisbaptiste Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vosjedev I'm not sure why I had marked this comment as resolved, but I don't see the suggested message before the loop.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my guess is that I marked it as resolved, assuming I would resolve it directly after. I guess I... didn't? I'll take another look

@juanluisbaptiste
Copy link
Copy Markdown
Owner

@Vosjedev it works fine, please add the last modification asked on my last comment and we're ready!

@Vosjedev
Copy link
Copy Markdown
Author

Sorry for the delay, I had seen your email and completely forgot about it despite having time again...
On an unrelated note, it looks like you're missing a space in your indentation on line 13. Maybe something to sneak in with a future commit? :)

@juanluisbaptiste
Copy link
Copy Markdown
Owner

On an unrelated note, it looks like you're missing a space in your indentation on line 13. Maybe something to sneak in with a future commit? :)

Sure, TY.

… script

Mostly follows the suggestions from
juanluisbaptiste#80

usage: environment variables can be supplied in format POSTFIX_<option>
to set them using postconf automatically.
usage: mount or copy an executable as `/post-setup.sh` to have it
automatically be run after init, and before postfix start

Signed-off-by: Vosjedev <vosje@vosjedev.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants