]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Ensuring idempotence
authorFrank Brehm <frank@brehm-online.com>
Mon, 14 Feb 2022 16:38:19 +0000 (17:38 +0100)
committerFrank Brehm <frank@brehm-online.com>
Mon, 14 Feb 2022 16:38:19 +0000 (17:38 +0100)
migrate-sieve

index 2b2a4b0597fb3633ec24367ca36d5e4da9e854ac..04035f4a34c2025352d21da106845cfb580bf57c 100755 (executable)
@@ -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"
 
 }