1
1
Fork 0
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-04-28 08:45:06 +02: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 _set_default_config_path
local OPTIND local OPTIND
while getopts ":c:i:p:zZR" OPT while getopts ":c:i:p:zZR" OPT; do
do
case ${OPT} in case ${OPT} in
( i ) IMAGE_NAME="${OPTARG}" ;; ( i ) IMAGE_NAME="${OPTARG}" ;;
( z | Z ) USE_SELINUX=":${OPT}" ;; ( z | Z ) USE_SELINUX=":${OPT}" ;;

View File

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

View File

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

View File

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

View File

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

View File

@ -57,8 +57,7 @@ ${ORANGE}EXIT STATUS${RESET}
_require_n_parameters_or_print_usage 0 "${@}" _require_n_parameters_or_print_usage 0 "${@}"
while [[ ${#} -gt 0 ]] while [[ ${#} -gt 0 ]]; do
do
case "${1}" in case "${1}" in
( 'keysize' ) ( 'keysize' )
if [[ -n ${2+set} ]]; then if [[ -n ${2+set} ]]; then
@ -124,8 +123,7 @@ if [[ ! -s ${DATABASE_VHOST} ]]; then
exit 0 exit 0
fi fi
while read -r DKIM_DOMAIN while read -r DKIM_DOMAIN; do
do
mkdir -p "/tmp/docker-mailserver/opendkim/keys/${DKIM_DOMAIN}" mkdir -p "/tmp/docker-mailserver/opendkim/keys/${DKIM_DOMAIN}"
if [[ ! -f "/tmp/docker-mailserver/opendkim/keys/${DKIM_DOMAIN}/${SELECTOR}.private" ]]; then 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: '${*}'" _log 'trace' "Options given to this script: '${*}'"
while [[ ${#} -gt 0 ]] while [[ ${#} -gt 0 ]]; do
do
case "${1}" in case "${1}" in
( 'keytype' ) ( '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. # They presently have no special handling other than to trigger a change that will restart Postfix/Dovecot.
} }
while true while true; do
do
_check_for_changes _check_for_changes
sleep 2 sleep 2
done done

View File

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

View File

@ -9,8 +9,7 @@ LOCK_ID=$(uuid)
function _create_lock() { function _create_lock() {
LOCK_FILE="/tmp/docker-mailserver/${SCRIPT_NAME}.lock" LOCK_FILE="/tmp/docker-mailserver/${SCRIPT_NAME}.lock"
while [[ -e "${LOCK_FILE}" ]] while [[ -e "${LOCK_FILE}" ]]; do
do
# Handle stale lock files left behind on crashes # Handle stale lock files left behind on crashes
# or premature/non-graceful exits of containers while they're making changes # or premature/non-graceful exits of containers while they're making changes
if [[ -n "$(find "${LOCK_FILE}" -mmin +1 2>/dev/null)" ]]; then 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 # getting domains FROM mail accounts
if [[ -f ${DATABASE_ACCOUNTS} ]]; then if [[ -f ${DATABASE_ACCOUNTS} ]]; then
while IFS=$'|' read -r LOGIN _ while IFS=$'|' read -r LOGIN _; do
do
DOMAIN=$(echo "${LOGIN}" | cut -d @ -f2) DOMAIN=$(echo "${LOGIN}" | cut -d @ -f2)
echo "${DOMAIN}" >>"${TMP_VHOST}" echo "${DOMAIN}" >>"${TMP_VHOST}"
done < <(_get_valid_lines_from_file "${DATABASE_ACCOUNTS}") done < <(_get_valid_lines_from_file "${DATABASE_ACCOUNTS}")
@ -54,8 +53,7 @@ function _vhost_collect_postfix_domains() {
# getting domains FROM mail aliases # getting domains FROM mail aliases
if [[ -f ${DATABASE_VIRTUAL} ]]; then if [[ -f ${DATABASE_VIRTUAL} ]]; then
while read -r FROM _ while read -r FROM _; do
do
UNAME=$(echo "${FROM}" | cut -d @ -f1) UNAME=$(echo "${FROM}" | cut -d @ -f1)
DOMAIN=$(echo "${FROM}" | cut -d @ -f2) 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_ACCOUNTS}" /tmp/docker-mailserver/postfix-accounts.cf
_list_domain_parts "${PRINT_DOMAIN_PART_VIRTUAL}" /tmp/docker-mailserver/postfix-virtual.cf _list_domain_parts "${PRINT_DOMAIN_PART_VIRTUAL}" /tmp/docker-mailserver/postfix-virtual.cf
} | sort -u | while read -r DOMAIN_PART } | sort -u | while read -r DOMAIN_PART; do
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 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. # `^@${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. # `^\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 ENV_PREFIX=${1} CONFIG_FILE=${2}
local ESCAPED_VALUE ESCAPED_KEY local ESCAPED_VALUE ESCAPED_KEY
while IFS='=' read -r KEY VALUE while IFS='=' read -r KEY VALUE; do
do
KEY=${KEY#"${ENV_PREFIX}"} # strip prefix KEY=${KEY#"${ENV_PREFIX}"} # strip prefix
ESCAPED_KEY=$(sed -E 's#([\=\&\|\$\.\*\/\[\\^]|\])#\\\1#g' <<< "${KEY,,}") ESCAPED_KEY=$(sed -E 's#([\=\&\|\$\.\*\/\[\\^]|\])#\\\1#g' <<< "${KEY,,}")
ESCAPED_VALUE=$(sed -E 's#([\=\&\|\$\.\*\/\[\\^]|\])#\\\1#g' <<< "${VALUE}") ESCAPED_VALUE=$(sed -E 's#([\=\&\|\$\.\*\/\[\\^]|\])#\\\1#g' <<< "${VALUE}")

View File

@ -51,8 +51,7 @@ function _setup_fetchmail_parallel() {
fi fi
local COUNTER=0 SERVER=0 local COUNTER=0 SERVER=0
while read -r LINE while read -r LINE; do
do
if [[ ${LINE} =~ poll ]]; then if [[ ${LINE} =~ poll ]]; then
# If we read "poll" then we reached a new server definition # If we read "poll" then we reached a new server definition
# We need to create a new file with fetchmail defaults from # 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]' _dms_panic__misconfigured 'NETWORK_INTERFACE' 'Network Setup [docker_permit]'
fi fi
while read -r IP while read -r IP; do
do
CONTAINER_NETWORKS+=("${IP}") CONTAINER_NETWORKS+=("${IP}")
done < <(ip -o -4 addr show type veth | grep -E -o '[0-9\.]+/[0-9]+') 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 fi
if [[ -f /tmp/docker-mailserver/postfix-master.cf ]]; then if [[ -f /tmp/docker-mailserver/postfix-master.cf ]]; then
while read -r LINE while read -r LINE; do
do
if [[ ${LINE} =~ ^[0-9a-z] ]]; then if [[ ${LINE} =~ ^[0-9a-z] ]]; then
postconf -P "${LINE}" postconf -P "${LINE}"
fi fi

View File

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

View File

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