summaryrefslogtreecommitdiff
path: root/manifests/expire.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/expire.pp')
-rw-r--r--manifests/expire.pp59
1 files changed, 43 insertions, 16 deletions
diff --git a/manifests/expire.pp b/manifests/expire.pp
index 42a170c..7eb5c6a 100644
--- a/manifests/expire.pp
+++ b/manifests/expire.pp
@@ -1,32 +1,58 @@
-class dovecot::expire(
- $type = 'script',
- $mail_location = 'absent',
- $days = '14',
- $directories = 'Trash\|Junk'
-) {
- include ::dovecot
+class dovecot::expire ( $type = 'sqlite', $mail_location = '', $dirs = '', $days = '' ) {
file{'/etc/cron.daily/dovecot-expire':
owner => root, group => 0, mode => 0755;
}
- if $dovecot::expire::type == 'legacy' or $dovecot::expire::type == 'mixed' {
- case $dovecot::expire::mail_location {
- 'absent': { fail("Need to set \$mail_location on ${::fqdn}!") }
+
+ if $type == 'legacy' or $type == 'mixed' {
+ case $mail_location {
+ '': { fail("Need to set \$dovecot_mail_location on $fqdn!") }
+ }
+ case $dirs {
+ '': { $dirs = 'Trash\|Junk' }
+ }
+ case $days {
+ '': { $days = '14' }
}
File['/etc/cron.daily/dovecot-expire']{
- content => "find ${dovecot::expire::mail_location} -regex '.*/\\.\\(${dovecot::expire::directories}\\)\\(/.*\\)?\\/\\(cur\\|new\\)/.*' -type f -ctime +${dovecot::expire::days} -delete\n"
+ content => "find ${mail_location} -regex '.*/\\.\\(${dirs}\\)\\(/.*\\)?\\/\\(cur\\|new\\)/.*' -type f -ctime +${days} -delete\n"
}
} else {
+ # 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"
}
}
+ }
+ } 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 $dovecot::expire::type != 'legacy' {
+ if $type != 'legacy' and $type != 'mysql' and $version != 2 {
file{'/etc/dovecot-expire.conf':
- source => [ "puppet:///modules/site_dovecot/expire/${::fqdn}/dovecot-expire.conf",
+ source => [ "puppet:///modules/site_dovecot/expire/${fqdn}/dovecot-expire.conf",
"puppet:///modules/site_dovecot/expire/dovecot-expire.conf",
- "puppet:///modules/dovecot/expire/${::operatingsystem}/dovecot-expire.conf",
+ "puppet:///modules/dovecot/expire/${operatingsystem}/dovecot-expire.conf",
"puppet:///modules/dovecot/expire/dovecot-expire.conf" ],
require => Package['dovecot'],
notify => Service['dovecot'],
@@ -39,9 +65,10 @@ class dovecot::expire(
}
}
- case $dovecot::expire::type {
- 'legacy': { info("no need to include anything for legacy type") }
+ case $type {
+ 'legacy': { info("no need to include anything for legacy mode") }
'mixed': { include ::dovecot::expire::sqlite }
+ 'mysql': { include ::dovecot::expire::mysql }
default: { include ::dovecot::expire::sqlite }
}
}