default.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #
  2. # Cookbook Name:: dovecot
  3. # Recipe:: default
  4. #
  5. # Copyright 2013, Onddo Labs, Sl.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. #
  20. # packages
  21. #
  22. conf_files = node['dovecot']['conf_files']['core']
  23. case node['platform']
  24. when 'redhat','centos','scientific','fedora','suse','amazon' then
  25. # core, imap, pop3, lmtp, ldap, sqlite
  26. package 'dovecot'
  27. conf_files +=
  28. node['dovecot']['conf_files']['imap'] +
  29. node['dovecot']['conf_files']['pop3'] +
  30. node['dovecot']['conf_files']['lmtp'] +
  31. node['dovecot']['conf_files']['ldap']
  32. # sieve
  33. if node['dovecot']['plugins'].include?('sieve')
  34. package 'dovecot-pigeonhole'
  35. conf_files += node['dovecot']['conf_files']['sieve']
  36. end
  37. when 'debian', 'ubuntu' then
  38. # core
  39. package 'dovecot-core'
  40. package 'dovecot-gssapi'
  41. # imap
  42. if node['dovecot']['protocols'].include?('imap')
  43. package 'dovecot-imapd'
  44. conf_files += node['dovecot']['conf_files']['imap']
  45. end
  46. # pop3
  47. if node['dovecot']['protocols'].include?('pop3')
  48. package 'dovecot-pop3d'
  49. conf_files += node['dovecot']['conf_files']['pop3']
  50. end
  51. # lmtp
  52. if node['dovecot']['protocols'].include?('lmtp')
  53. package 'dovecot-lmtpd'
  54. conf_files += node['dovecot']['conf_files']['lmtp']
  55. end
  56. # sieve
  57. if node['dovecot']['plugins'].include?('sieve')
  58. package 'dovecot-sieve'
  59. package 'dovecot-managesieved'
  60. conf_files += node['dovecot']['conf_files']['sieve']
  61. end
  62. # ldap
  63. if node['dovecot']['auth']['ldap'].kind_of?(Array) and node['dovecot']['auth']['ldap'].length > 0
  64. package 'dovecot-ldap'
  65. conf_files += node['dovecot']['conf_files']['ldap']
  66. end
  67. # sqlite
  68. package 'dovecot-sqlite' do
  69. only_if do
  70. node['dovecot']['auth']['sql']['drivers'].kind_of?(Array) and
  71. node['dovecot']['auth']['sql']['drivers'].include?('sqlite')
  72. end
  73. end
  74. else
  75. log('Unsupported platform, trying to guess dovecot packages') { level :warn }
  76. package 'dovecot'
  77. end
  78. package 'dovecot-mysql' do
  79. only_if do
  80. node['dovecot']['auth']['sql']['drivers'].kind_of?(Array) and
  81. node['dovecot']['auth']['sql']['drivers'].include?('mysql')
  82. end
  83. end
  84. package 'dovecot-pgsql' do
  85. only_if do
  86. node['dovecot']['auth']['sql']['drivers'].kind_of?(Array) and
  87. node['dovecot']['auth']['sql']['drivers'].include?('pgsql')
  88. end
  89. end
  90. #
  91. # config files
  92. #
  93. conf_files.each do |conf_file|
  94. dir = ::File.dirname(conf_file)
  95. directory dir do
  96. owner 'root'
  97. group node['dovecot']['group']
  98. mode '00755'
  99. only_if do dir != '.' end
  100. end
  101. template "#{node['dovecot']['conf_path']}/#{conf_file}" do
  102. source "#{conf_file}.erb"
  103. owner 'root'
  104. group node['dovecot']['group']
  105. mode '00640'
  106. variables(
  107. :auth => node['dovecot']['auth'],
  108. :protocols => node['dovecot']['protocols'],
  109. :conf => node['dovecot']['conf']
  110. )
  111. end
  112. end