From 576cc1d3c30ceef2928c3bf581fdbb5530027553 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Fri, 2 Sep 2011 17:38:31 -0400 Subject: setup dovecot version differences for expire class --- manifests/expire.pp | 38 +++++++++++++++++++++++++++----------- 1 file 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", -- cgit v1.2.3