From aeedb25daf43268309dd8df4420ee4cfa3588347 Mon Sep 17 00:00:00 2001 From: Andrey Golovizin Date: Sun, 7 Jan 2018 13:06:05 +0100 Subject: [PATCH] Use sieve_default option for sieveScript https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration#Visible_Default_Script --- mail-server/dovecot.nix | 2 ++ mail-server/users.nix | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index 34c94fb..731b578 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -110,6 +110,8 @@ in plugin { sieve = file:/var/sieve/%u/scripts;active=/var/sieve/%u/active.sieve + sieve_default = file:/var/sieve/%u/default.sieve + sieve_default_name = default } lda_mailbox_autosubscribe = yes diff --git a/mail-server/users.nix b/mail-server/users.nix index 9484882..a8cda32 100644 --- a/mail-server/users.nix +++ b/mail-server/users.nix @@ -55,16 +55,21 @@ let # is null, remove the file. ${lib.concatMapStringsSep "\n" ({ name, sieveScript }: if lib.isString sieveScript then '' - cat << EOF > "/var/sieve/${name}.sieve" + if (! test -d "/var/sieve/${name}"); then + mkdir -p "/var/sieve/${name}" + chown "${name}:${vmailGroupName}" "/var/sieve/${name}" + chmod 770 "/var/sieve/${name}" + fi + cat << EOF > "/var/sieve/${name}/default.sieve" ${sieveScript} EOF - chown "${name}:${vmailGroupName}" "/var/sieve/${name}.sieve" + chown "${name}:${vmailGroupName}" "/var/sieve/${name}/default.sieve" '' else '' - if (test -f "/var/sieve/${name}.sieve"); then - rm "/var/sieve/${name}.sieve" + if (test -f "/var/sieve/${name}/default.sieve"); then + rm "/var/sieve/${name}/default.sieve" fi if (test -f "/var/sieve/${name}.svbin"); then - rm "/var/sieve/${name}.svbin" + rm "/var/sieve/${name}/default.svbin" fi '') (map (user: { inherit (user) name sieveScript; }) (lib.attrValues loginAccounts))}