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

index c8a8054639a618d509ac1c6ad14dd6b2a946c14d..bff5ceaaa6f54d374333038538e34ee3b90767c0 100755 (executable)
@@ -54,6 +54,7 @@ COMPILED_SIEVE_BASE=".dovecot.svbin"
 
 declare -a MAIL_DNS=()
 declare -A ENSURED_DIRS=()
+declare -A NOT_COMPILED=()
 
 #-------------------------------------------------------------------
 detect_color() {
@@ -610,8 +611,13 @@ migrate_entry() {
     if [[ "${SIMULATE}" != "y" ]] ; then
         sievec "${dovecot_sieve_file}" || true
     fi
-    CHOWN "${VMAIL_USER}:${VMAIL_GROUP}" "${compiled_sieve}"
-    CHMOD 0600 "${compiled_sieve}"
+    if [[ -f "${compiled_sieve}" ]] ; then
+        CHOWN "${VMAIL_USER}:${VMAIL_GROUP}" "${compiled_sieve}"
+        CHMOD 0600 "${compiled_sieve}"
+    elif [[ "${SIMULATE}" != "y" ]] ; then
+        warn "Compiled sieve file '${YELLOW}${compiled_sieve}${NORMAL}' does not exists."
+        NOT_COMPILED[${dn}]="${cn} <${mail_address}>"
+    fi
     if [[ -e "${compiled_sieve}" && "${QUIET}" != "y" ]] ; then
         ls -l "${color_param}" "${compiled_sieve}"
     fi
@@ -628,6 +634,19 @@ migrate_all() {
         migrate_entry "${dn}"
     done
 
+    if [[ "${SIMULATE}" != "y" ]] ; then
+        empty_line
+        local dn=
+        if [[ "${#NOT_COMPILED[*]}" == "0" ]] ; then
+            info "All generated sieve files could be compiled."
+        else
+            warn "The sieve scripts of following mailboxes could not be compiled:"
+            for dn in "${!NOT_COMPILED[@]}" ; do
+                echo "   * ${NOT_COMPILED[${dn}]} - '${dn}'"
+            done
+        fi
+    fi
+
 }
 
 #------------------------------------------------