1
1
Fork 0
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-03-28 21:59:56 +01:00

Change 'while' style (#3365)

This commit is contained in:
Casper 2023-05-26 01:39:39 +02:00 committed by GitHub
parent 37ca0f9ba9
commit c2d0b748b2
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 22 additions and 44 deletions

View File

@ -124,8 +124,7 @@ function _main() {
_set_default_config_path
local OPTIND
while getopts ":c:i:p:zZR" OPT
do
while getopts ":c:i:p:zZR" OPT; do
case ${OPT} in
( i ) IMAGE_NAME="${OPTARG}" ;;
( z | Z ) USE_SELINUX=":${OPT}" ;;

View File

@ -70,8 +70,7 @@ ${ORANGE}EXIT STATUS${RESET}
}
function _parse_options() {
while getopts ":yY" OPT
do
while getopts ":yY" OPT; do
case "${OPT}" in
( 'y' | 'Y' )
MAILDEL=1

View File

@ -12,8 +12,7 @@ function _list_entries() {
local DATABASE=${1}
_db_should_exist_with_content "${DATABASE}"
while read -r LINE
do
while read -r LINE; do
echo -e "* ${LINE}\n"
done < <(_get_valid_lines_from_file "${DATABASE}")
}

View File

@ -13,8 +13,7 @@ function _list_entries() {
_db_should_exist_with_content "${DATABASE}"
local MASTER_ACCOUNT
while read -r LINE
do
while read -r LINE; do
MASTER_ACCOUNT=$(echo "${LINE}" | cut -d'|' -f1)
echo -e "* ${MASTER_ACCOUNT}\n"

View File

@ -19,8 +19,7 @@ function _list_entries() {
_db_should_exist_with_content "${DATABASE}"
local ENTRY_TO_DISPLAY
while read -r LINE
do
while read -r LINE; do
ENTRY_TO_DISPLAY=$(_format_list_item "${LINE}")
echo -e "* ${ENTRY_TO_DISPLAY}\n"

View File

@ -57,8 +57,7 @@ ${ORANGE}EXIT STATUS${RESET}
_require_n_parameters_or_print_usage 0 "${@}"
while [[ ${#} -gt 0 ]]
do
while [[ ${#} -gt 0 ]]; do
case "${1}" in
( 'keysize' )
if [[ -n ${2+set} ]]; then
@ -124,8 +123,7 @@ if [[ ! -s ${DATABASE_VHOST} ]]; then
exit 0
fi
while read -r DKIM_DOMAIN
do
while read -r DKIM_DOMAIN; do
mkdir -p "/tmp/docker-mailserver/opendkim/keys/${DKIM_DOMAIN}"
if [[ ! -f "/tmp/docker-mailserver/opendkim/keys/${DKIM_DOMAIN}/${SELECTOR}.private" ]]; then

View File

@ -79,8 +79,7 @@ function _parse_arguments() {
_log 'trace' "Options given to this script: '${*}'"
while [[ ${#} -gt 0 ]]
do
while [[ ${#} -gt 0 ]]; do
case "${1}" in
( 'keytype' )

View File

@ -174,8 +174,7 @@ function _ssl_changes() {
# They presently have no special handling other than to trigger a change that will restart Postfix/Dovecot.
}
while true
do
while true; do
_check_for_changes
sleep 2
done

View File

@ -38,8 +38,7 @@ function _create_accounts() {
# creating users ; 'pass' is encrypted
# comments and empty lines are ignored
local LOGIN PASS USER_ATTRIBUTES
while IFS=$'|' read -r LOGIN PASS USER_ATTRIBUTES
do
while IFS=$'|' read -r LOGIN PASS USER_ATTRIBUTES; do
# Setting variables for better readability
USER=$(echo "${LOGIN}" | cut -d @ -f1)
DOMAIN=$(echo "${LOGIN}" | cut -d @ -f2)
@ -104,8 +103,7 @@ function _create_dovecot_alias_dummy_accounts() {
# adding aliases to Dovecot's userdb
# ${REAL_FQUN} is a user's fully-qualified username
local ALIAS REAL_FQUN DOVECOT_USERDB_LINE
while read -r ALIAS REAL_FQUN
do
while read -r ALIAS REAL_FQUN; do
# alias is assumed to not be a proper e-mail
# these aliases do not need to be added to Dovecot's userdb
[[ ! ${ALIAS} == *@* ]] && continue
@ -177,8 +175,7 @@ function _create_masters() {
# creating users ; 'pass' is encrypted
# comments and empty lines are ignored
local LOGIN PASS
while IFS=$'|' read -r LOGIN PASS
do
while IFS=$'|' read -r LOGIN PASS; do
_log 'debug' "Creating master user '${LOGIN}'"
local DOVECOT_MASTERDB_LINE

View File

@ -9,8 +9,7 @@ LOCK_ID=$(uuid)
function _create_lock() {
LOCK_FILE="/tmp/docker-mailserver/${SCRIPT_NAME}.lock"
while [[ -e "${LOCK_FILE}" ]]
do
while [[ -e "${LOCK_FILE}" ]]; do
# Handle stale lock files left behind on crashes
# or premature/non-graceful exits of containers while they're making changes
if [[ -n "$(find "${LOCK_FILE}" -mmin +1 2>/dev/null)" ]]; then

View File

@ -45,8 +45,7 @@ function _vhost_collect_postfix_domains() {
# getting domains FROM mail accounts
if [[ -f ${DATABASE_ACCOUNTS} ]]; then
while IFS=$'|' read -r LOGIN _
do
while IFS=$'|' read -r LOGIN _; do
DOMAIN=$(echo "${LOGIN}" | cut -d @ -f2)
echo "${DOMAIN}" >>"${TMP_VHOST}"
done < <(_get_valid_lines_from_file "${DATABASE_ACCOUNTS}")
@ -54,8 +53,7 @@ function _vhost_collect_postfix_domains() {
# getting domains FROM mail aliases
if [[ -f ${DATABASE_VIRTUAL} ]]; then
while read -r FROM _
do
while read -r FROM _; do
UNAME=$(echo "${FROM}" | cut -d @ -f1)
DOMAIN=$(echo "${FROM}" | cut -d @ -f2)

View File

@ -149,8 +149,7 @@ function _populate_relayhost_map() {
{
_list_domain_parts "${PRINT_DOMAIN_PART_ACCOUNTS}" /tmp/docker-mailserver/postfix-accounts.cf
_list_domain_parts "${PRINT_DOMAIN_PART_VIRTUAL}" /tmp/docker-mailserver/postfix-virtual.cf
} | sort -u | while read -r DOMAIN_PART
do
} | sort -u | while read -r DOMAIN_PART; do
# DOMAIN_PART not already present in `/etc/postfix/relayhost_map`, and not listed as a relay opt-out domain in `postfix-relaymap.cf`
# `^@${DOMAIN_PART}\b` - To check for existing entry, the `\b` avoids accidental partial matches on similar domain parts.
# `^\s*@${DOMAIN_PART}\s*$` - Matches line with only a domain part (eg: @example.test) to avoid including a mapping for those domains to the RELAY_HOST.

View File

@ -97,8 +97,7 @@ function _replace_by_env_in_file() {
local ENV_PREFIX=${1} CONFIG_FILE=${2}
local ESCAPED_VALUE ESCAPED_KEY
while IFS='=' read -r KEY VALUE
do
while IFS='=' read -r KEY VALUE; do
KEY=${KEY#"${ENV_PREFIX}"} # strip prefix
ESCAPED_KEY=$(sed -E 's#([\=\&\|\$\.\*\/\[\\^]|\])#\\\1#g' <<< "${KEY,,}")
ESCAPED_VALUE=$(sed -E 's#([\=\&\|\$\.\*\/\[\\^]|\])#\\\1#g' <<< "${VALUE}")

View File

@ -51,8 +51,7 @@ function _setup_fetchmail_parallel() {
fi
local COUNTER=0 SERVER=0
while read -r LINE
do
while read -r LINE; do
if [[ ${LINE} =~ poll ]]; then
# If we read "poll" then we reached a new server definition
# We need to create a new file with fetchmail defaults from

View File

@ -22,8 +22,7 @@ function _setup_docker_permit() {
_dms_panic__misconfigured 'NETWORK_INTERFACE' 'Network Setup [docker_permit]'
fi
while read -r IP
do
while read -r IP; do
CONTAINER_NETWORKS+=("${IP}")
done < <(ip -o -4 addr show type veth | grep -E -o '[0-9\.]+/[0-9]+')

View File

@ -107,8 +107,7 @@ function __postfix__setup_override_configuration() {
fi
if [[ -f /tmp/docker-mailserver/postfix-master.cf ]]; then
while read -r LINE
do
while read -r LINE; do
if [[ ${LINE} =~ ^[0-9a-z] ]]; then
postconf -P "${LINE}"
fi

View File

@ -316,8 +316,7 @@ function __rspamd__handle_user_modules_adjustments() {
if [[ -f "${RSPAMD_CUSTOM_COMMANDS_FILE}" ]]; then
__rspamd__log 'debug' "Found file '${RSPAMD_CUSTOM_COMMANDS_FILE}' - parsing and applying it"
while read -r COMMAND ARGUMENT1 ARGUMENT2 ARGUMENT3
do
while read -r COMMAND ARGUMENT1 ARGUMENT2 ARGUMENT3; do
case "${COMMAND}" in
('disable-module')

View File

@ -15,8 +15,7 @@ if [[ ! ${UPDATE_CHECK_INTERVAL} =~ ^[0-9]+[smhd]{1}$ ]]; then
UPDATE_CHECK_INTERVAL='1d'
fi
while true
do
while true; do
# get remote version information
LATEST=$(curl -Lsf "${VERSION_URL}")