]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/mail/dovecot.nix
Improve cleanup cron job for dovecot
[perso/Immae/Config/Nix.git] / modules / private / mail / dovecot.nix
index 6c3b4b8e14660e5087718277d4810f08592128ed..c3d306de372e7699cd8c940be6f6d829f9b0c2f7 100644 (file)
@@ -92,6 +92,17 @@ in
           }
         ''
 
+        # ACL
+        ''
+          mail_plugins = $mail_plugins acl
+          plugin {
+            acl = vfile:${pkgs.writeText "dovecot-acl" ''
+              Backup/* owner lrp
+              ''}
+            acl_globals_only = yes
+          }
+        ''
+
         # Full text search
         ''
           # needs to be bigger than any mailbox size
@@ -117,6 +128,8 @@ in
             sieve_plugins = sieve_imapsieve sieve_extprograms
             imapsieve_url = sieve://127.0.0.1:4190
 
+            sieve_before = file:${./sieve_scripts}/backup.sieve
+
             # From elsewhere to Junk folder
             imapsieve_mailbox1_name = Junk
             imapsieve_mailbox1_causes = COPY APPEND
@@ -225,7 +238,7 @@ in
         # Needs to come last if there are mail_plugins entries
         ''
         protocol imap {
-          mail_plugins = $mail_plugins imap_sieve
+          mail_plugins = $mail_plugins imap_sieve imap_acl
         }
         protocol lda {
           mail_plugins = $mail_plugins sieve
@@ -243,9 +256,9 @@ in
 
     services.cron.systemCronJobs = let
       cron_script = pkgs.writeScriptBin "cleanup-imap-folders" ''
-        ${pkgs.dovecot}/bin/doveadm expunge -A MAILBOX "Backup/*" NOT UID 1:256
-        ${pkgs.dovecot}/bin/doveadm expunge -A MAILBOX Junk SEEN NOT FLAGGED BEFORE 4w
-        ${pkgs.dovecot}/bin/doveadm search -A MAILBOX Trash NOT FLAGGED BEFORE 4w
+        ${pkgs.dovecot}/bin/doveadm expunge -A MAILBOX "Backup/*" NOT UID 1:256 2>&1 > /dev/null | grep -v "Mailbox doesn't exist:" | grep -v "Info: Opening DB"
+        ${pkgs.dovecot}/bin/doveadm expunge -A MAILBOX Junk SEEN NOT FLAGGED BEFORE 4w 2>&1 > /dev/null | grep -v "Mailbox doesn't exist:" | grep -v "Info: Opening DB"
+        ${pkgs.dovecot}/bin/doveadm expunge -A MAILBOX Trash NOT FLAGGED BEFORE 4w 2>&1 > /dev/null | grep -v "Mailbox doesn't exist:" | grep -v "Info: Opening DB"
         '';
       in
       [