Use sieve_default option for sieveScript

https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration#Visible_Default_Script
This commit is contained in:
Andrey Golovizin 2018-01-07 13:06:05 +01:00
parent a6d9604ea5
commit aeedb25daf
2 changed files with 12 additions and 5 deletions

View file

@ -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

View file

@ -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))}