feat: Configurable number of rotated log files (#3907)

This commit is contained in:
Dominic Germain 2024-02-28 09:34:30 -05:00 committed by GitHub
parent 2c1faa7244
commit 512f39c7eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 2 deletions

View File

@ -60,6 +60,11 @@ The most noteworthy change of this release is the update of the container's base
- `undef` was previously supported as an opt-out with `SA_SPAM_SUBJECT`. This is no longer valid, the equivalent opt-out value is now an empty value (_or rather the omission of this ENV being configured_).
- The feature to include [`_SCORE_` tag](https://spamassassin.apache.org/full/4.0.x/doc/Mail_SpamAssassin_Conf.html#rewrite_header-subject-from-to-STRING) in your value to be replaced by the associated spam score is no longer available.
### Added
- **Environment Variables:**
- `LOGROTATE_COUNT` defines the number of files kept by logrotate ([#3907](https://github.com/docker-mailserver/docker-mailserver/pull/3907))
### Updates
- **Environment Variables:**

View File

@ -545,6 +545,12 @@ Changes the interval in which log files are rotated.
This variable can also determine the interval for Postfix's log summary reports, see [`PFLOGSUMM_TRIGGER`](#pflogsumm_trigger).
##### LOGROTATE_COUNT
Defines how many files are kept by logrotate.
- **4** => Number of files
#### SpamAssassin
##### ENABLE_SPAMASSASSIN

View File

@ -346,6 +346,9 @@ REPORT_SENDER=
# Note: This variable can also determine the interval for Postfix's log summary reports, see [`PFLOGSUMM_TRIGGER`](#pflogsumm_trigger).
LOGROTATE_INTERVAL=weekly
# Defines how many log files are kept by logrorate
LOGROTATE_COUNT=4
# If enabled, employs `reject_unknown_client_hostname` to sender restrictions in Postfix's configuration.
#

View File

@ -19,13 +19,19 @@ function _setup_logrotate() {
_dms_panic__invalid_value 'LOGROTATE_INTERVAL' 'Setup -> Logrotate'
fi
if [[ ${LOGROTATE_COUNT} =~ ^[0-9]+$ ]]; then
_log 'trace' "Logrotate count set to ${LOGROTATE_COUNT}"
else
_dms_panic__invalid_value 'LOGROTATE_COUNT' 'Setup -> Logrotate'
fi
cat >/etc/logrotate.d/maillog << EOF
/var/log/mail/mail.log
{
compress
copytruncate
delaycompress
rotate 4
rotate ${LOGROTATE_COUNT}
${LOGROTATE_INTERVAL}
}
EOF

View File

@ -109,7 +109,7 @@ function __rspamd__setup_logfile() {
compress
copytruncate
delaycompress
rotate 4
rotate ${LOGROTATE_COUNT}
${LOGROTATE_INTERVAL}
}
EOF

View File

@ -145,6 +145,7 @@ function __environment_variables_general_setup() {
VARS[GETMAIL_POLL]="${GETMAIL_POLL:=5}"
VARS[LOG_LEVEL]="${LOG_LEVEL:=info}"
VARS[LOGROTATE_INTERVAL]="${LOGROTATE_INTERVAL:=weekly}"
VARS[LOGROTATE_COUNT]="${LOGROTATE_COUNT:=4}"
VARS[LOGWATCH_INTERVAL]="${LOGWATCH_INTERVAL:=none}"
VARS[LOGWATCH_RECIPIENT]="${LOGWATCH_RECIPIENT:=${REPORT_RECIPIENT}}"
VARS[LOGWATCH_SENDER]="${LOGWATCH_SENDER:=${REPORT_SENDER}}"