mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-30 23:54:46 +02:00
scripts: Rspamd stabilization pt. 2 (#3282)
* move modules adjustment file to new location Because we link `/tmp/docker-mailserver/rspamd/override.d` to `/etc/rspamd/override.d`, I think it makes sense to move the modules adjustment file into `/tmp/docker-mailserver/rspamd/` as well. I write the code in a way that it is backwards compatible for now, so this is NOT a breaking change. * minor improvement to `__rspamd__handle_user_modules_adjustments` The expansion of `ARGUMENT3` is now done in a way that only adds the whitespace in case the variable is set and not null. * move test file structure to respect latest changes Because we're now linking `rspamd/override.d/`, we can simplify the setup a bit. But this requires a change in directory structure. The current Rspamd test will be renamed to `rspamd_full.bats`, because I plan on adding more tests in different files for different feature sets. This is done to make this feature well-tested! * improved and added tests to Rspamd-full FYI: The line ```bats _run_in_container grep 'sieve_global_extensions.*\+vnd\.dovecot\.pipe' "${SIEVE_CONFIG_FILE}" ``` was testing a condition that should actually not be met, but when I started working on this feature, I thought this was the correct configuration. Adding the `assert_success` statements revealed this wrong line. I also added tests to check whether `override.d` is linked correctly. * renamed: `rspamd.bats` => `rspamd_full.bats` * added new tests for incomplete Rspamd feature set We now test that warnings are emitted & features are disabled correctly. * update documentation
This commit is contained in:
parent
638975922e
commit
cd1721334c
10 changed files with 155 additions and 31 deletions
|
@ -292,7 +292,7 @@ function __rspamd__handle_user_modules_adjustments
|
|||
# Adds an option with a corresponding value to a module, or, in case the option
|
||||
# is already present, overwrites it.
|
||||
#
|
||||
# @param ${1} = file name in /etc/rspamd/override.d/
|
||||
# @param ${1} = file name in ${RSPAMD_OVERRIDE_D}/
|
||||
# @param ${2} = module name as it should appear in the log
|
||||
# @patam ${3} = option name in the module
|
||||
# @param ${4} = value of the option
|
||||
|
@ -324,10 +324,21 @@ function __rspamd__handle_user_modules_adjustments
|
|||
fi
|
||||
}
|
||||
|
||||
local RSPAMD_CUSTOM_COMMANDS_FILE='/tmp/docker-mailserver/rspamd-modules.conf'
|
||||
local RSPAMD_CUSTOM_COMMANDS_FILE="${RSPAMD_DMS_D}/custom-commands.conf"
|
||||
local RSPAMD_CUSTOM_COMMANDS_FILE_OLD="${RSPAMD_DMS_D}-modules.conf"
|
||||
|
||||
# We check for usage of the previous location of the commands file.
|
||||
# This can be removed after the release of v14.0.0.
|
||||
if [[ -f ${RSPAMD_CUSTOM_COMMANDS_FILE_OLD} ]]
|
||||
then
|
||||
__rspamd__log 'warn' "Detected usage of old file location for modules adjustment ('${RSPAMD_CUSTOM_COMMANDS_FILE_OLD}') - please use the new location ('${RSPAMD_CUSTOM_COMMANDS_FILE}')"
|
||||
__rspamd__log 'warn' "Using old file location now (deprecated) - this will prevent startup in v13.0.0"
|
||||
RSPAMD_CUSTOM_COMMANDS_FILE=${RSPAMD_CUSTOM_COMMANDS_FILE_OLD}
|
||||
fi
|
||||
|
||||
if [[ -f "${RSPAMD_CUSTOM_COMMANDS_FILE}" ]]
|
||||
then
|
||||
__rspamd__log 'debug' "Found file 'rspamd-modules.conf' - parsing and applying it"
|
||||
__rspamd__log 'debug' "Found file '${RSPAMD_CUSTOM_COMMANDS_FILE}' - parsing and applying it"
|
||||
|
||||
while read -r COMMAND ARGUMENT1 ARGUMENT2 ARGUMENT3
|
||||
do
|
||||
|
@ -359,7 +370,7 @@ function __rspamd__handle_user_modules_adjustments
|
|||
|
||||
('add-line')
|
||||
__rspamd__log 'trace' "Adding complete line to '${ARGUMENT1}'"
|
||||
echo "${ARGUMENT2} ${ARGUMENT3:-}" >>"/etc/rspamd/override.d/${ARGUMENT1}"
|
||||
echo "${ARGUMENT2}${ARGUMENT3+ ${ARGUMENT3}}" >>"${RSPAMD_OVERRIDE_D}/${ARGUMENT1}"
|
||||
;;
|
||||
|
||||
(*)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue