summaryrefslogtreecommitdiff
path: root/manifests/expire.pp
blob: 9d53bb40cb38106ec111e33f1feae618df52cd66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class dovecot::expire {

  include ::dovecot

  file { '/etc/cron.daily/dovecot-expire':
    owner => root, group => 0, mode => 0755;
  }
  if $dovecot_expire_type == 'legacy' or $dovecot_expire_type == 'mixed' {
    case $dovecot_mail_location {
      '': { fail("Need to set \$dovecot_mail_location on $fqdn!") }
    }
    case $dovecot_expire_dirs {
      '': { $dovecot_expire_dirs = 'Trash\|Junk' }
    }
    case $dovecot_expire_days {
      '': { $dovecot_expire_days = '14' }
    }
    File['/etc/cron.daily/dovecot-expire']{
      content => "find ${dovecot_mail_location} -regex '.*/\\.\\(${dovecot_expire_dirs}\\)\\(/.*\\)?\\/\\(cur\\|new\\)/.*' -type f -ctime +${dovecot_expire_days} -delete\n"
    }
  } else {
    File['/etc/cron.daily/dovecot-expire']{
      content => "dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool.sh\n"
    }
  }

  if $dovecot_expire_type != 'legacy' {
    file{'/etc/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/dovecot-expire.conf" ],
      require => Package['dovecot'],
      notify => Service['dovecot'],
      owner => root, group => 0, mode => 0600;
    }

    file { '/usr/libexec/dovecot/expire-tool.sh':
      source => "puppet:///modules/dovecot/expire/expire-tool.sh",
      owner => root, group => 0, mode => 0700;
    }
  }

  case $dovecot_expire_type {
    'legacy': { info("no need to include anything for legacy mode") }
    'mixed': { include ::dovecot::expire::sqlite }
    default: { include ::dovecot::expire::sqlite }
  }
}