Skip to content

Commit f8f485b

Browse files
authored
Merge pull request #143 from devilbox/release-0.98
Release v0.98
2 parents 3ce6ed5 + 3ad0330 commit f8f485b

18 files changed

Lines changed: 89 additions & 83 deletions

Dockerfiles/prod/data/docker-entrypoint.d/301-postfix.sh

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,70 +22,83 @@ set_postfix() {
2222
local debug="${7}"
2323

2424
local php_ini_file="${php_ini_dir}/devilbox-runtime-sendmail.ini"
25-
local catch_all=
25+
local enable_mail=
2626

27+
# Verify env value
2728
if ! env_set "${env_varname}"; then
2829
log "info" "\$${env_varname} not set." "${debug}"
2930
log "info" "Postfix will not be started." "${debug}"
3031
echo "" > "${php_ini_file}"
31-
else
32-
catch_all="$( env_get "${env_varname}" )"
33-
if [ "${catch_all}" = "1" ]; then
34-
log "info" "\$${env_varname} set to 1. Enabling postfix catch-all" "${debug}"
35-
36-
# Configure PHP
37-
{
38-
echo "[mail function]";
39-
echo "sendmail_path = $( which sendmail ) -t -i";
40-
echo ";mail.force_extra_parameters =";
41-
echo "mail.add_x_header = On";
42-
echo "mail.log = ${php_mail_log}";
43-
} > "${php_ini_file}"
44-
45-
# PHP mail function logs to file
46-
if [ "${docker_logs}" != "1" ]; then
47-
# Fix PHP mail log file dir/file and permissions
48-
if [ ! -d "$( dirname "${php_mail_log}" )" ]; then
49-
run "mkdir -p $( dirname "${php_mail_log}" )" "${debug}"
50-
fi
51-
if [ ! -f "${php_mail_log}" ]; then
52-
run "touch ${php_mail_log}" "${debug}"
53-
fi
54-
run "chown ${username}:${groupname} $( dirname "${php_mail_log}" )" "${debug}"
55-
run "chown ${username}:${groupname} ${php_mail_log}" "${debug}"
56-
run "chmod 0644 ${php_mail_log}" "${debug}"
57-
fi
32+
return
33+
fi
34+
35+
# Retrieve env value
36+
enable_mail="$( env_get "${env_varname}" )"
37+
38+
# Enable postfix
39+
if [ "${enable_mail}" = "1" ] || [ "${enable_mail}" = "2" ]; then
5840

59-
# Add Mail dir/file if it does not exist
60-
if [ ! -d "/var/mail" ]; then
61-
run "mkdir /var/mail" "${debug}"
41+
if [ "${enable_mail}" = "1" ]; then
42+
log "info" "\$${env_varname} set to 1. Enabling postfix" "${debug}"
43+
else
44+
log "info" "\$${env_varname} set to 2. Enabling postfix catch-all" "${debug}"
45+
fi
46+
47+
# Configure PHP
48+
{
49+
echo "[mail function]";
50+
echo "sendmail_path = $( command -v sendmail ) -t -i";
51+
echo ";mail.force_extra_parameters =";
52+
echo "mail.add_x_header = On";
53+
echo "mail.log = ${php_mail_log}";
54+
} > "${php_ini_file}"
55+
56+
# PHP mail function logs to file
57+
if [ "${docker_logs}" != "1" ]; then
58+
# Fix PHP mail log file dir/file and permissions
59+
if [ ! -d "$( dirname "${php_mail_log}" )" ]; then
60+
run "mkdir -p $( dirname "${php_mail_log}" )" "${debug}"
6261
fi
63-
if [ ! -f "/var/mail/${username}" ]; then
64-
run "touch /var/mail/${username}" "${debug}"
62+
if [ ! -f "${php_mail_log}" ]; then
63+
run "touch ${php_mail_log}" "${debug}"
6564
fi
65+
run "chown ${username}:${groupname} $( dirname "${php_mail_log}" )" "${debug}"
66+
run "chown ${username}:${groupname} ${php_mail_log}" "${debug}"
67+
run "chmod 0644 ${php_mail_log}" "${debug}"
68+
fi
6669

67-
# Fix mail dir/file permissions after mount
68-
run "chmod 0644 /var/mail/${username}" "${debug}"
69-
run "chown ${username}:${groupname} /var/mail" "${debug}"
70-
run "chown ${username}:${groupname} /var/mail/${username}" "${debug}"
70+
# Add Mail dir/file if it does not exist
71+
if [ ! -d "/var/mail" ]; then
72+
run "mkdir /var/mail" "${debug}"
73+
fi
74+
if [ ! -f "/var/mail/${username}" ]; then
75+
run "touch /var/mail/${username}" "${debug}"
76+
fi
77+
78+
# Fix mail dir/file permissions after mount
79+
run "chmod 0644 /var/mail/${username}" "${debug}"
80+
run "chown ${username}:${groupname} /var/mail" "${debug}"
81+
run "chown ${username}:${groupname} /var/mail/${username}" "${debug}"
7182

72-
# warning: specify "strict_mailbox_ownership = no" to ignore mailbox ownership mismatch
73-
run "postconf -e 'strict_mailbox_ownership=no'" "${debug}"
83+
# warning: specify "strict_mailbox_ownership = no" to ignore mailbox ownership mismatch
84+
run "postconf -e 'strict_mailbox_ownership=no'" "${debug}"
7485

75-
# Postfix configuration
76-
run "postconf -e 'inet_protocols=ipv4'" "${debug}"
86+
# Postfix configuration
87+
run "postconf -e 'inet_protocols=ipv4'" "${debug}"
88+
89+
# Postfix catch-all
90+
if [ "${enable_mail}" = "2" ]; then
7791
run "postconf -e 'virtual_alias_maps=pcre:/etc/postfix/virtual'" "${debug}"
7892
run "echo '/.*@.*/ ${username}' >> /etc/postfix/virtual" "${debug}"
79-
8093
run "newaliases" "${debug}"
94+
fi
8195

82-
elif [ "${catch_all}" = "0" ]; then
83-
log "info" "\$${env_varname} set to 0. Disabling postfix catch-all" "${debug}"
96+
elif [ "${enable_mail}" = "0" ]; then
97+
log "info" "\$${env_varname} set to 0. Disabling postfix" "${debug}"
8498

85-
else
86-
log "err" "Invalid value for \$${env_varname}. Can only be 0 or 1. Prodived: ${catch_all}" "${debug}"
87-
exit 1
88-
fi
99+
else
100+
log "err" "Invalid value for \$${env_varname}. Can only be 0, 1 or 2. Prodived: ${enable_mail}" "${debug}"
101+
exit 1
89102
fi
90103
}
91104

Dockerfiles/prod/data/docker-entrypoint.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ DVL_PHP_INI_DIR="/usr/local/etc/php/conf.d"
2424
# php-fpm conf.d directory
2525
DVL_PHP_FPM_DIR="/usr/local/etc/php-fpm.d"
2626

27-
# This is the log file for any mail related functions
28-
DVL_PHP_MAIL_LOG="/var/log/mail.log"
29-
3027
# This file holds error and access log definitions
3128
DVL_PHP_FPM_CONF_LOGFILE="${DVL_PHP_FPM_DIR}/zzz-entrypoint-logfiles.conf"
3229
DVL_PHP_INI_CONF_LOGFILE="${DVL_PHP_INI_DIR}/zzz-entrypoint-logfiles.ini"
3330

3431
# PHP-FPM log dir
3532
DVL_FPM_LOG_DIR="/var/log/php"
3633

34+
# This is the log file for any mail related functions
35+
DVL_PHP_MAIL_LOG="${DVL_FPM_LOG_DIR}/mail.log"
36+
3737
# Custom ini dir (to be copied to actual ini dir)
3838
DVL_PHP_CUST_INI_DIR="/etc/php-custom.d"
3939

@@ -138,7 +138,7 @@ done
138138
###
139139
### Supervisor: rsyslogd & postfix
140140
###
141-
if [ "$( env_get "ENABLE_MAIL" )" = "1" ]; then
141+
if [ "$( env_get "ENABLE_MAIL" )" = "1" ] || [ "$( env_get "ENABLE_MAIL" )" = "2" ]; then
142142
supervisor_add_service "rsyslogd" "/usr/sbin/rsyslogd -n" "${DVL_SUPERVISOR_CONFD}" "${DEBUG_LEVEL}" "1"
143143
supervisor_add_service "postfix" "/usr/local/sbin/postfix.sh" "${DVL_SUPERVISOR_CONFD}" "${DEBUG_LEVEL}"
144144
fi

Dockerfiles/prod/data/postfix.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ set -o pipefail
2222
###
2323
### Variables
2424
###
25-
if [ -f "/etc/alpine-release" ]; then
26-
MAILLOG="/var/log/maillog"
27-
elif [ -f "/etc/debian_version" ]; then
28-
MAILLOG="/var/log/mail.log"
29-
else
30-
MAILLOG="/var/log/maillog"
31-
fi
32-
25+
MAILLOG="/var/log/mail.log"
3326
MAILPID="/var/spool/postfix/pid/master.pid"
3427

3528

Dockerfiles/work/Dockerfile-5.2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ RUN set -eux \
191191
\
192192
\
193193
# -------------------- mhsendmail --------------------
194-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
194+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
195195
&& chmod +x mhsendmail_linux_amd64 \
196196
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
197197
\

Dockerfiles/work/Dockerfile-5.3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ RUN set -eux \
208208
\
209209
\
210210
# -------------------- mhsendmail --------------------
211-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
211+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
212212
&& chmod +x mhsendmail_linux_amd64 \
213213
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
214214
\

Dockerfiles/work/Dockerfile-5.4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ RUN set -eux \
237237
\
238238
\
239239
# -------------------- mhsendmail --------------------
240-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
240+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
241241
&& chmod +x mhsendmail_linux_amd64 \
242242
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
243243
\

Dockerfiles/work/Dockerfile-5.5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ RUN set -eux \
241241
\
242242
\
243243
# -------------------- mhsendmail --------------------
244-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
244+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
245245
&& chmod +x mhsendmail_linux_amd64 \
246246
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
247247
\

Dockerfiles/work/Dockerfile-5.6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ RUN set -eux \
254254
\
255255
\
256256
# -------------------- mhsendmail --------------------
257-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
257+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
258258
&& chmod +x mhsendmail_linux_amd64 \
259259
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
260260
\

Dockerfiles/work/Dockerfile-7.0

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ RUN set -eux \
254254
\
255255
\
256256
# -------------------- mhsendmail --------------------
257-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
257+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
258258
&& chmod +x mhsendmail_linux_amd64 \
259259
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
260260
\

Dockerfiles/work/Dockerfile-7.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ RUN set -eux \
254254
\
255255
\
256256
# -------------------- mhsendmail --------------------
257-
&& wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
257+
&& wget https://github.com/devilbox/mhsendmail/releases/download/v0.3.0/mhsendmail_linux_amd64 \
258258
&& chmod +x mhsendmail_linux_amd64 \
259259
&& mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail \
260260
\

0 commit comments

Comments
 (0)