default.rb 3.4 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 Dovecot::Plugins.required?('sieve', node['dovecot'])
  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 Dovecot::Protocols.enabled?('imap', node['dovecot']['protocols'])
  43. package 'dovecot-imapd'
  44. conf_files += node['dovecot']['conf_files']['imap']
  45. end
  46. # pop3
  47. if Dovecot::Protocols.enabled?('pop3', node['dovecot']['protocols'])
  48. package 'dovecot-pop3d'
  49. conf_files += node['dovecot']['conf_files']['pop3']
  50. end
  51. # lmtp
  52. if Dovecot::Protocols.enabled?('lmtp', node['dovecot']['protocols'])
  53. package 'dovecot-lmtpd'
  54. conf_files += node['dovecot']['conf_files']['lmtp']
  55. end
  56. # sieve
  57. if Dovecot::Plugins.required?('sieve', node['dovecot'])
  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 node['dovecot']['conf']['sql']['driver'] == 'sqlite' end
  70. end
  71. else
  72. log('Unsupported platform, trying to guess dovecot packages') { level :warn }
  73. package 'dovecot'
  74. end
  75. package 'dovecot-mysql' do
  76. only_if do node['dovecot']['conf']['sql']['driver'] == 'mysql' end
  77. end
  78. package 'dovecot-pgsql' do
  79. only_if do node['dovecot']['conf']['sql']['driver'] == 'pgsql' end
  80. end
  81. #
  82. # config files
  83. #
  84. conf_files.each do |conf_file|
  85. dir = ::File.dirname(conf_file)
  86. directory dir do
  87. owner 'root'
  88. group node['dovecot']['group']
  89. mode '00755'
  90. only_if do dir != '.' end
  91. end
  92. template "#{node['dovecot']['conf_path']}/#{conf_file}" do
  93. source "#{conf_file}.erb"
  94. owner 'root'
  95. group node['dovecot']['group']
  96. mode '00640'
  97. variables(
  98. :auth => node['dovecot']['auth'],
  99. :protocols => node['dovecot']['protocols'],
  100. :services => node['dovecot']['services'],
  101. :plugins => node['dovecot']['plugins'],
  102. :namespaces => node['dovecot']['namespaces'],
  103. :conf => node['dovecot']['conf']
  104. )
  105. notifies :reload, 'service[dovecot]'
  106. end
  107. end
  108. service 'dovecot' do
  109. supports :restart => true, :reload => true, :status => true
  110. action [ :enable, :start ]
  111. end