summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2011-09-02 17:38:31 -0400
committerMicah Anderson <micah@riseup.net>2011-09-02 17:38:31 -0400
commit576cc1d3c30ceef2928c3bf581fdbb5530027553 (patch)
treef64c261ccf9df82ea5f45ac710c02db9be8612f4
parent6ed512ba710312d05936261fe0873e255c27364f (diff)
setup dovecot version differences for expire class
-rw-r--r--manifests/expire.pp38
1 files changed, 27 insertions, 11 deletions
diff --git a/manifests/expire.pp b/manifests/expire.pp
index 72e1ad6..e5679f4 100644
--- a/manifests/expire.pp
+++ b/manifests/expire.pp
@@ -5,6 +5,7 @@ class dovecot::expire ( $type = 'sqlite', $mail_location = '', $dirs = '', $days
file { '/etc/cron.daily/dovecot-expire':
owner => root, group => 0, mode => 0755;
}
+
if $type == 'legacy' or $type == 'mixed' {
case $mail_location {
'': { fail("Need to set \$dovecot_mail_location on $fqdn!") }
@@ -19,22 +20,37 @@ class dovecot::expire ( $type = 'sqlite', $mail_location = '', $dirs = '', $days
content => "find ${mail_location} -regex '.*/\\.\\(${dirs}\\)\\(/.*\\)?\\/\\(cur\\|new\\)/.*' -type f -ctime +${days} -delete\n"
}
} else {
- case $operatingsystem {
- debian: {
- augeas { "expire_cron":
- context => "/files/etc/default/dovecot/rule",
- changes => [ 'set /files/etc/default/dovecot/EXPIRE_CRON \'"daily"\'' ],
+ # dovecot version 1 way
+ if $version != 2 {
+ case $operatingsystem {
+ debian: {
+ augeas { "expire_cron":
+ context => "/files/etc/default/dovecot/rule",
+ changes => [ 'set /files/etc/default/dovecot/EXPIRE_CRON \'"daily"\'' ],
+ }
}
- }
- default: {
- File['/etc/cron.daily/dovecot-expire']{
- content => "dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool.sh\n"
+ default: {
+ File['/etc/cron.daily/dovecot-expire']{
+ content => "dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool.sh\n"
+ }
}
}
+ } else {
+ # dovecot version 2 way (no mail_location, dirs need to be space separated variables and expire script runs doveadm expunge)
+ # problem with this method is that it doesn't allow for different times for different mailboxes
+ case $dirs {
+ '': { $dirs = 'Trash Junk' }
+ }
+ case $days {
+ '': { $days = '14' }
+ }
+ File['/etc/cron.daily/dovecot-expire']{
+ content => "#!/bin/sh\n\n dirs='${dirs}'\nfor mailbox in \$dirs; do doveadm expunge -A mailbox \$mailbox savedbefore ${days}d; done\n"
+ }
}
}
-
- if $type != 'legacy' and $type != 'mysql' {
+
+ if $type != 'legacy' and $type != 'mysql' and $version != 2 {
file{'/etc/dovecot-expire.conf':
source => [ "puppet:///modules/site-dovecot/expire/${fqdn}/dovecot-expire.conf",
"puppet:///modules/site-dovecot/expire/dovecot-expire.conf",