From b31f5ec63b8549cf1340b80a2ea32f5209ed2ee8 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 14 Feb 2022 17:38:19 +0100 Subject: [PATCH] Ensuring idempotence --- migrate-sieve | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migrate-sieve b/migrate-sieve index 2b2a4b0..04035f4 100755 --- a/migrate-sieve +++ b/migrate-sieve @@ -52,6 +52,7 @@ SIEVE_FILE_BASE="Normal.sieve" DOVECOT_SIEVE_FILE_BASE=".dovecot.sieve" declare -a MAIL_DNS=() +declare -A ENSURED_DIRS=() #------------------------------------------------------------------- detect_color() { @@ -435,11 +436,18 @@ LN() { ensure_vmail_dir() { local vdir="$1" + + if [[ -v ENSURED_DIRS[${vdir}] ]] ; then + debug "Directory '${CYAN}${vdir}${NORMAL}' already handled." + return + fi + if [[ ! -d "${vdir}" ]] ; then MKDIR "${vdir}" fi CHMOD 0700 "${vdir}" CHOWN "${VMAIL_USER}:${VMAIL_GROUP}" "${vdir}" + ENSURED_DIRS[${vdir}]="y" } -- 2.39.5