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

postfix custom.sh working? #76

Closed
OliverPA77 opened this issue Sep 12, 2021 · 5 comments
Closed

postfix custom.sh working? #76

OliverPA77 opened this issue Sep 12, 2021 · 5 comments

Comments

@OliverPA77
Copy link
Contributor

Whereas e.g. custom dovecot configs get applied, I cannot get custom.sh working for postfix.
I also couldn't find anywhere such a custom.sh would get called.

ll in custom postfix path:
root@mail:/# ll /opt/iredmail/custom/postfix/custom* -rwxr-x--x 1 root postfix 165 Sep 9 09:03 /opt/iredmail/custom/postfix/custom.sh*

custom.sh content:
root@mail:/# cat /opt/iredmail/custom/postfix/custom.sh #!/bin/bash postconf -e smtpd_upstream_proxy_protocol=haproxy postconf -e postscreen_upstream_proxy_protocol=haproxy postconf -e mynetworks='127.0.0.1 192.168.2.3'

However as soon as I added this patch to entrypoints/postfix.sh it starts getting applied:
if [ -f ${POSTFIX_CUSTOM_CONF_DIR}/custom.sh ]; then LOG "Found and use custom config script: ${POSTFIX_CUSTOM_CONF_DIR}/custom.sh." bash ${POSTFIX_CUSTOM_CONF_DIR}/custom.sh fi

Could it be that this is missing?

@NikolayDachev
Copy link

Thank you @OliverPA77

my pr #93 is exactly for the same !

I believe will be a good option for docker container entrypoint

1.) similar to this one
or
2) general entrypoint script which execute custom scripts (as last step)

@NikolayDachev
Copy link

@OliverPA77
I tested your solution, work as expected :)

@iredmail team please consider it or consider more general docker entrypoint to execute custom script !
If this fix is ok @OliverPA77 or I can do a pull request ?!

@iredmail
Copy link
Owner

On a server (VM, VPS, etc), we have cron job like this:

@reboot /bin/bash /opt/iredmail/bin/apply_all_custom_settings

And full content of this apply_all_custom_settings script is:

#!/usr/bin/env bash
{{ ansible_managed | comment }}

# Purpose: Run all `/opt/iredmail/custom/<PROGRAM>/custom.sh` scripts to apply
#          custom settings after system reboot.
# Author: Zhang Huangbin <zhb@iredmail.org>

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"

# Hard-code the directories we should run instead of using `find`.
PROGRAMS="firewall openldap postfix nginx fail2ban sogo dovecot firewall roundcube "

# Directory that stores all application custom configuration files / scripts.
CUSTOM_CONF_DIR="/opt/iredmail/custom"

for prog in ${PROGRAMS}; do
    d="${CUSTOM_CONF_DIR}/${prog}"
    f="${d}/custom.sh"

    if [[ -f ${f} ]]; then
        cd ${d} && {{ shell_bash }} ${f} >> custom.log 2>&1
    fi
done

@dachevn
Copy link

dachevn commented Jan 28, 2022

look as a good option !

but docker container don't have it !

# docker exec -it iredmail ls -lah /opt/iredmail/bin
total 24K
drwxr-xr-x 1 root root 4.0K Jan 28 11:05 .
drwxr-xr-x 1 root root 4.0K Jan 28 12:33 ..
-rwxr-xr-x 1 root root 3.0K Jan 28 11:05 create_user
drwxr-xr-x 1 root root 4.0K Jan 28 12:33 dovecot
drwxr-xr-x 2 root root 4.0K Jan 28 11:05 fail2ban
-rwxr-xr-x 1 root root  721 Jan 28 11:05 find_top_sasl_usernames

@iredmail
Copy link
Owner

Last commit added script /opt/iredmail/bin/apply_all_custom_settings and cron job for @reboot, but i'm not sure whether it works insider docker container, it's rush and no time to test it yet.

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

No branches or pull requests

4 participants