mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Change 'for' style (#3368)
This commit is contained in:
parent
8512dba8ad
commit
8bfe8424fc
|
@ -14,7 +14,6 @@ else
|
|||
GETMAILDIR=/tmp/docker-mailserver/getmail
|
||||
fi
|
||||
|
||||
for FILE in /etc/getmailrc.d/getmailrc*
|
||||
do
|
||||
for FILE in /etc/getmailrc.d/getmailrc*; do
|
||||
/usr/local/bin/getmail --getmaildir "${GETMAILDIR}" --rcfile "${FILE}" --dump | tail -n +7
|
||||
done
|
||||
|
|
|
@ -7,8 +7,7 @@ function _main() {
|
|||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
# Actual command to perform:
|
||||
for MAIL_ACCOUNT in "${@}"
|
||||
do
|
||||
for MAIL_ACCOUNT in "${@}"; do
|
||||
_manage_accounts_dovecotmaster_delete "${MAIL_ACCOUNT}" \
|
||||
|| _exit_with_error "'${MAIL_ACCOUNT}' could not be deleted"
|
||||
done
|
||||
|
|
|
@ -16,8 +16,7 @@ function _main() {
|
|||
_create_lock
|
||||
|
||||
# Actual command to perform:
|
||||
for MAIL_ACCOUNT in "${@}"
|
||||
do
|
||||
for MAIL_ACCOUNT in "${@}"; do
|
||||
_account_should_already_exist
|
||||
|
||||
[[ ${MAILDEL} -eq 1 ]] && _remove_maildir "${MAIL_ACCOUNT}"
|
||||
|
|
|
@ -13,16 +13,14 @@ fail2ban-client ping &>/dev/null || _exit_with_error "Fail2ban not running"
|
|||
unset JAILS
|
||||
declare -a JAILS
|
||||
|
||||
for LIST in $(fail2ban-client status | grep "Jail list" | cut -f2- | sed 's/,/ /g')
|
||||
do
|
||||
for LIST in $(fail2ban-client status | grep "Jail list" | cut -f2- | sed 's/,/ /g'); do
|
||||
JAILS+=("${LIST}")
|
||||
done
|
||||
|
||||
if [[ -z ${1} ]]; then
|
||||
IPS_BANNED=0
|
||||
|
||||
for JAIL in "${JAILS[@]}"
|
||||
do
|
||||
for JAIL in "${JAILS[@]}"; do
|
||||
BANNED_IPS=$(fail2ban-client status "${JAIL}" | grep -oP '(?<=Banned IP list:\s).+')
|
||||
|
||||
if [[ -n ${BANNED_IPS} ]]; then
|
||||
|
@ -58,8 +56,7 @@ else
|
|||
shift
|
||||
if [[ -n ${1} ]]; then
|
||||
|
||||
for JAIL in "${JAILS[@]}"
|
||||
do
|
||||
for JAIL in "${JAILS[@]}"; do
|
||||
RESULT=$(fail2ban-client set "${JAIL}" unbanip "${@}" 2>&1)
|
||||
|
||||
[[ ${RESULT} != *"is not banned"* ]] && [[ ${RESULT} != *"NOK"* ]] && echo "Unbanned IP from ${JAIL}: ${RESULT}"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#! /bin/bash
|
||||
|
||||
for FILE in /etc/getmailrc.d/getmailrc*
|
||||
do
|
||||
for FILE in /etc/getmailrc.d/getmailrc*; do
|
||||
if ! pgrep -f "${FILE}$" &>/dev/null; then
|
||||
/usr/local/bin/getmail --getmaildir /var/lib/getmail --rcfile "${FILE}"
|
||||
fi
|
||||
|
|
|
@ -64,8 +64,7 @@ function _monitored_files_checksums() {
|
|||
|
||||
# If the file actually exists, add to CHANGED_FILES
|
||||
# and generate a content hash entry:
|
||||
for FILE in "${STAGING_FILES[@]}"
|
||||
do
|
||||
for FILE in "${STAGING_FILES[@]}"; do
|
||||
[[ -f "${FILE}" ]] && CHANGED_FILES+=("${FILE}")
|
||||
done
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ function _sanitize_ipv4_to_subnet_cidr() {
|
|||
declare -a MASKED_DIGITS DIGITS
|
||||
IFS='.' ; read -r -a DIGITS < <(echo "${1%%/*}") ; unset IFS
|
||||
|
||||
for ((i = 0 ; i < 4 ; i++))
|
||||
do
|
||||
for ((i = 0 ; i < 4 ; i++)); do
|
||||
MASKED_DIGITS[i]=$(_mask_ip_digit "${DIGIT_PREFIX_LENGTH}" "${DIGITS[i]}")
|
||||
DIGIT_PREFIX_LENGTH=$((DIGIT_PREFIX_LENGTH - 8))
|
||||
done
|
||||
|
|
|
@ -9,8 +9,7 @@ function _register_check_function() {
|
|||
|
||||
function _check() {
|
||||
_log 'info' 'Checking configuration'
|
||||
for FUNC in "${FUNCS_CHECK[@]}"
|
||||
do
|
||||
for FUNC in "${FUNCS_CHECK[@]}"; do
|
||||
${FUNC}
|
||||
done
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ function _register_start_daemon() {
|
|||
function _start_daemons() {
|
||||
_log 'info' 'Starting daemons'
|
||||
|
||||
for FUNCTION in "${DAEMONS_START[@]}"
|
||||
do
|
||||
for FUNCTION in "${DAEMONS_START[@]}"; do
|
||||
${FUNCTION}
|
||||
done
|
||||
}
|
||||
|
@ -56,8 +55,7 @@ function _start_daemon_postfix() {
|
|||
function _start_daemon_fetchmail() {
|
||||
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]; then
|
||||
local COUNTER=0
|
||||
for _ in /etc/fetchmailrc.d/fetchmail-*.rc
|
||||
do
|
||||
for _ in /etc/fetchmailrc.d/fetchmail-*.rc; do
|
||||
COUNTER=$(( COUNTER + 1 ))
|
||||
_default_start_daemon "fetchmail-${COUNTER}"
|
||||
done
|
||||
|
|
|
@ -10,15 +10,13 @@ function _register_setup_function() {
|
|||
function _setup() {
|
||||
# Requires `shopt -s globstar` because of `**` which in
|
||||
# turn is required as we're decending through directories
|
||||
for FILE in /usr/local/bin/setup.d/**/*.sh
|
||||
do
|
||||
for FILE in /usr/local/bin/setup.d/**/*.sh; do
|
||||
# shellcheck source=/dev/null
|
||||
source "${FILE}"
|
||||
done
|
||||
|
||||
_log 'info' 'Configuring mail server'
|
||||
for FUNC in "${FUNCS_SETUP[@]}"
|
||||
do
|
||||
for FUNC in "${FUNCS_SETUP[@]}"; do
|
||||
${FUNC}
|
||||
done
|
||||
|
||||
|
|
|
@ -146,8 +146,7 @@ function _setup_dovecot_local_user() {
|
|||
function __wait_until_an_account_is_added_or_shutdown() {
|
||||
local SLEEP_PERIOD='10'
|
||||
|
||||
for (( COUNTER = 11 ; COUNTER >= 0 ; COUNTER-- ))
|
||||
do
|
||||
for (( COUNTER = 11 ; COUNTER >= 0 ; COUNTER-- )); do
|
||||
if [[ $(grep -cE '.+@.+\|' /tmp/docker-mailserver/postfix-accounts.cf 2>/dev/null || printf '%s' '0') -ge 1 ]]; then
|
||||
return 0
|
||||
else
|
||||
|
|
|
@ -76,8 +76,7 @@ function _setup_fetchmail_parallel() {
|
|||
_fetchmailrc_split
|
||||
|
||||
local COUNTER=0
|
||||
for RC in /etc/fetchmailrc.d/fetchmail-*.rc
|
||||
do
|
||||
for RC in /etc/fetchmailrc.d/fetchmail-*.rc; do
|
||||
COUNTER=$(( COUNTER + 1 ))
|
||||
cat >"/etc/supervisor/conf.d/fetchmail-${COUNTER}.conf" << EOF
|
||||
[program:fetchmail-${COUNTER}]
|
||||
|
|
|
@ -13,8 +13,7 @@ function _setup_getmail() {
|
|||
|
||||
# Generate getmailrc configs, starting with the `/etc/getmailrc_general` base config,
|
||||
# Add a unique `message_log` config, then append users own config to the end.
|
||||
for FILE in /tmp/docker-mailserver/getmail-*.cf
|
||||
do
|
||||
for FILE in /tmp/docker-mailserver/getmail-*.cf; do
|
||||
if [[ -f ${FILE} ]]; then
|
||||
CONFIGS=1
|
||||
ID=$(cut -d '-' -f 3 <<< "${FILE}" | cut -d '.' -f 1)
|
||||
|
|
|
@ -4,8 +4,7 @@ function _setup_ldap() {
|
|||
_log 'debug' 'Setting up LDAP'
|
||||
_log 'trace' 'Checking for custom configs'
|
||||
|
||||
for i in 'users' 'groups' 'aliases' 'domains'
|
||||
do
|
||||
for i in 'users' 'groups' 'aliases' 'domains'; do
|
||||
local FPATH="/tmp/docker-mailserver/ldap-${i}.cf"
|
||||
if [[ -f ${FPATH} ]]; then
|
||||
cp "${FPATH}" "/etc/postfix/ldap-${i}.cf"
|
||||
|
@ -23,8 +22,7 @@ function _setup_ldap() {
|
|||
/etc/postfix/maps/sender_login_maps.ldap
|
||||
)
|
||||
|
||||
for FILE in "${FILES[@]}"
|
||||
do
|
||||
for FILE in "${FILES[@]}"; do
|
||||
[[ ${FILE} =~ ldap-user ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_USER}"
|
||||
[[ ${FILE} =~ ldap-group ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_GROUP}"
|
||||
[[ ${FILE} =~ ldap-aliases ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_ALIAS}"
|
||||
|
@ -51,8 +49,7 @@ function _setup_ldap() {
|
|||
# Default DOVECOT_PASS_FILTER to the same value as DOVECOT_USER_FILTER
|
||||
DOVECOT_LDAP_MAPPING['DOVECOT_PASS_FILTER']="${DOVECOT_PASS_FILTER:="${DOVECOT_USER_FILTER}"}"
|
||||
|
||||
for VAR in "${!DOVECOT_LDAP_MAPPING[@]}"
|
||||
do
|
||||
for VAR in "${!DOVECOT_LDAP_MAPPING[@]}"; do
|
||||
export "${VAR}=${DOVECOT_LDAP_MAPPING[${VAR}]}"
|
||||
done
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ function _setup_save_states() {
|
|||
# Single service files
|
||||
[[ ${ENABLE_SRS} -eq 1 ]] && SERVICEFILES+=('/etc/postsrsd.secret')
|
||||
|
||||
for SERVICEFILE in "${SERVICEFILES[@]}";
|
||||
do
|
||||
for SERVICEFILE in "${SERVICEFILES[@]}"; do
|
||||
DEST="${STATEDIR}/${SERVICEFILE}"
|
||||
DESTDIR="${DEST%/*}"
|
||||
|
||||
|
@ -55,8 +54,7 @@ function _setup_save_states() {
|
|||
ln -s "${DEST}" "${SERVICEFILE}"
|
||||
done
|
||||
|
||||
for SERVICEDIR in "${SERVICEDIRS[@]}"
|
||||
do
|
||||
for SERVICEDIR in "${SERVICEDIRS[@]}"; do
|
||||
DEST="${STATEDIR}/${SERVICEDIR//\//-}"
|
||||
SERVICEDIR="/var/${SERVICEDIR}"
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ function _setup_docker_permit() {
|
|||
;;
|
||||
|
||||
( 'connected-networks' )
|
||||
for CONTAINER_NETWORK in "${CONTAINER_NETWORKS[@]}"
|
||||
do
|
||||
for CONTAINER_NETWORK in "${CONTAINER_NETWORKS[@]}"; do
|
||||
CONTAINER_NETWORK=$(_sanitize_ipv4_to_subnet_cidr "${CONTAINER_NETWORK}")
|
||||
__add_to_postfix_mynetworks 'Docker Network' "${CONTAINER_NETWORK}"
|
||||
done
|
||||
|
|
|
@ -158,8 +158,7 @@ function __setup__security__clamav() {
|
|||
_log 'debug' 'Enabling and configuring ClamAV'
|
||||
|
||||
local FILE
|
||||
for FILE in /var/log/mail/{clamav,freshclam}.log
|
||||
do
|
||||
for FILE in /var/log/mail/{clamav,freshclam}.log; do
|
||||
touch "${FILE}"
|
||||
chown clamav:adm "${FILE}"
|
||||
chmod 640 "${FILE}"
|
||||
|
|
|
@ -179,8 +179,7 @@ function __rspamd__setup_default_modules() {
|
|||
metric_exporter
|
||||
)
|
||||
|
||||
for MODULE in "${DISABLE_MODULES[@]}"
|
||||
do
|
||||
for MODULE in "${DISABLE_MODULES[@]}"; do
|
||||
__rspamd__helper__enable_disable_module "${MODULE}" 'false'
|
||||
done
|
||||
}
|
||||
|
|
|
@ -212,8 +212,7 @@ function _environment_variables_export() {
|
|||
: >/etc/dms-settings # this file can be sourced by other scripts
|
||||
|
||||
local VAR
|
||||
for VAR in "${!VARS[@]}"
|
||||
do
|
||||
for VAR in "${!VARS[@]}"; do
|
||||
echo "export ${VAR}='${VARS[${VAR}]}'" >>/root/.bashrc
|
||||
echo "${VAR}='${VARS[${VAR}]}'" >>/etc/dms-settings
|
||||
done
|
||||
|
|
|
@ -29,8 +29,7 @@ function __initialize_variables() {
|
|||
'CONTAINER_NAME'
|
||||
)
|
||||
|
||||
for VARIABLE in "${REQUIRED_VARIABLES_FOR_TESTS[@]}"
|
||||
do
|
||||
for VARIABLE in "${REQUIRED_VARIABLES_FOR_TESTS[@]}"; do
|
||||
__check_if_set "${VARIABLE}"
|
||||
done
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ function _should_succesfully_negotiate_tls() {
|
|||
assert_success
|
||||
|
||||
local PORTS=(25 587 465 143 993)
|
||||
for PORT in "${PORTS[@]}"
|
||||
do
|
||||
for PORT in "${PORTS[@]}"; do
|
||||
_negotiate_tls "${FQDN}" "${PORT}"
|
||||
done
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ function teardown_file() {
|
|||
}
|
||||
|
||||
@test "fail2ban-jail.cf overrides" {
|
||||
for FILTER in 'dovecot' 'postfix' 'postfix-sasl'
|
||||
do
|
||||
for FILTER in 'dovecot' 'postfix' 'postfix-sasl'; do
|
||||
_run_in_container fail2ban-client get "${FILTER}" bantime
|
||||
assert_output 1234
|
||||
|
||||
|
|
|
@ -89,8 +89,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "argument 'domain' is applied correctly" {
|
||||
for DOMAIN in 'blabla.org' 'someother.com' 'random.de'
|
||||
do
|
||||
for DOMAIN in 'blabla.org' 'someother.com' 'random.de'; do
|
||||
_run_in_container setup config dkim domain "${DOMAIN}"
|
||||
assert_success
|
||||
assert_line --partial "Domain set to '${DOMAIN}'"
|
||||
|
@ -107,8 +106,7 @@ function teardown_file() { _default_teardown ; }
|
|||
assert_failure
|
||||
assert_line --partial "Unknown keytype 'foobar'"
|
||||
|
||||
for KEYTYPE in 'rsa' 'ed25519'
|
||||
do
|
||||
for KEYTYPE in 'rsa' 'ed25519'; do
|
||||
_run_in_container setup config dkim keytype "${KEYTYPE}"
|
||||
assert_success
|
||||
assert_line --partial "Keytype set to '${KEYTYPE}'"
|
||||
|
@ -127,8 +125,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "argument 'selector' is applied correctly" {
|
||||
for SELECTOR in 'foo' 'bar' 'baz'
|
||||
do
|
||||
for SELECTOR in 'foo' 'bar' 'baz'; do
|
||||
__create_key 'rsa' "${SELECTOR}"
|
||||
assert_success
|
||||
assert_line --partial "Selector set to '${SELECTOR}'"
|
||||
|
@ -146,8 +143,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "argument 'keysize' is applied correctly for RSA keys" {
|
||||
for KEYSIZE in 512 1024 2048 4096
|
||||
do
|
||||
for KEYSIZE in 512 1024 2048 4096; do
|
||||
__create_key 'rsa' 'mail' "${DOMAIN_NAME}" "${KEYSIZE}"
|
||||
assert_success
|
||||
__log_is_free_of_warnings_and_errors
|
||||
|
@ -234,8 +230,7 @@ function __check_rsa_keys() {
|
|||
# @param ${1} = base file name that all DKIM key files have
|
||||
function __check_key_files_are_present() {
|
||||
local BASE_FILE_NAME="${1:?Base file name must be supplied to __check_key_files_are_present}"
|
||||
for FILE in ${BASE_FILE_NAME}.{public.txt,public.dns.txt,private.txt}
|
||||
do
|
||||
for FILE in ${BASE_FILE_NAME}.{public.txt,public.dns.txt,private.txt}; do
|
||||
_run_in_container_bash "[[ -f ${FILE} ]]"
|
||||
assert_success
|
||||
done
|
||||
|
|
|
@ -49,8 +49,7 @@ function setup_file() {
|
|||
export MAIL_ID3=$(_send_email_and_get_id 'email-templates/rspamd-virus')
|
||||
export MAIL_ID4=$(_send_email_and_get_id 'email-templates/rspamd-spam-header')
|
||||
|
||||
for ID in MAIL_ID{1,2,3,4}
|
||||
do
|
||||
for ID in MAIL_ID{1,2,3,4}; do
|
||||
[[ -n ${!ID} ]] || { echo "${ID} is empty - aborting!" ; return 1 ; }
|
||||
done
|
||||
}
|
||||
|
@ -225,8 +224,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test 'RSPAMD_LEARN works' {
|
||||
for FILE in learn-{ham,spam}.{sieve,svbin}
|
||||
do
|
||||
for FILE in learn-{ham,spam}.{sieve,svbin}; do
|
||||
_run_in_container_bash "[[ -f /usr/lib/dovecot/sieve-pipe/${FILE} ]]"
|
||||
assert_success
|
||||
done
|
||||
|
@ -267,8 +265,7 @@ function teardown_file() { _default_teardown ; }
|
|||
assert_success
|
||||
assert_output --partial 'imapsieve: Matched static mailbox rule [1]'
|
||||
refute_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
||||
for LINE in "${LEARN_SPAM_LINES[@]}"
|
||||
do
|
||||
for LINE in "${LEARN_SPAM_LINES[@]}"; do
|
||||
assert_output --partial "${LINE}"
|
||||
done
|
||||
|
||||
|
@ -281,8 +278,7 @@ function teardown_file() { _default_teardown ; }
|
|||
_run_in_container cat /var/log/mail/mail.log
|
||||
assert_success
|
||||
assert_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
||||
for LINE in "${LEARN_HAM_LINES[@]}"
|
||||
do
|
||||
for LINE in "${LEARN_HAM_LINES[@]}"; do
|
||||
assert_output --partial "${LINE}"
|
||||
done
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ function teardown_file() { _default_teardown ; }
|
|||
@test "log warns about interfering features" {
|
||||
run docker logs "${CONTAINER_NAME}"
|
||||
assert_success
|
||||
for SERVICE in 'Amavis/SA' 'OpenDKIM' 'OpenDMARC' 'policyd-spf'
|
||||
do
|
||||
for SERVICE in 'Amavis/SA' 'OpenDKIM' 'OpenDMARC' 'policyd-spf'; do
|
||||
assert_output --regexp ".*WARNING.*Running ${SERVICE} & Rspamd at the same time is discouraged"
|
||||
done
|
||||
}
|
||||
|
@ -63,8 +62,7 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test 'learning is properly disabled' {
|
||||
for FILE in learn-{ham,spam}.{sieve,svbin}
|
||||
do
|
||||
for FILE in learn-{ham,spam}.{sieve,svbin}; do
|
||||
_run_in_container_bash "[[ -f /usr/lib/dovecot/sieve-pipe/${FILE} ]]"
|
||||
assert_failure
|
||||
done
|
||||
|
|
|
@ -72,16 +72,14 @@ ENV_PROCESS_LIST=(
|
|||
# Required for Postfix (when launched by wrapper script which is slow to start)
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
for PROCESS in "${CORE_PROCESS_LIST[@]}"
|
||||
do
|
||||
for PROCESS in "${CORE_PROCESS_LIST[@]}"; do
|
||||
run _check_if_process_is_running "${PROCESS}"
|
||||
assert_success
|
||||
assert_output --partial "${PROCESS}"
|
||||
refute_output --partial "is not running"
|
||||
done
|
||||
|
||||
for PROCESS in "${ENV_PROCESS_LIST[@]}" clamd
|
||||
do
|
||||
for PROCESS in "${ENV_PROCESS_LIST[@]}" clamd; do
|
||||
run _check_if_process_is_running "${PROCESS}"
|
||||
assert_failure
|
||||
assert_output --partial "'${PROCESS}' is not running"
|
||||
|
@ -116,8 +114,7 @@ ENV_PROCESS_LIST=(
|
|||
"${ENV_PROCESS_LIST[@]}"
|
||||
)
|
||||
|
||||
for PROCESS in "${ENABLED_PROCESS_LIST[@]}"
|
||||
do
|
||||
for PROCESS in "${ENABLED_PROCESS_LIST[@]}"; do
|
||||
_should_restart_when_killed "${PROCESS}"
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue