Change 'for' style (#3368)

This commit is contained in:
Casper 2023-05-26 14:00:40 +02:00 committed by GitHub
parent 8512dba8ad
commit 8bfe8424fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 43 additions and 86 deletions

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}]

View file

@ -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)

View file

@ -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

View file

@ -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}"

View file

@ -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

View file

@ -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}"

View 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
}

View file

@ -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