packages.rb 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #
  2. # Cookbook Name:: dovecot
  3. # Recipe:: packages
  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. case node['platform']
  23. when 'redhat','centos','scientific','fedora','suse','amazon' then
  24. # core, imap, pop3, lmtp, ldap, sqlite
  25. ruby_block 'package-dovecot-core' do
  26. block {}
  27. notifies :install, 'package[dovecot]', :immediately
  28. [ 'core', 'imap', 'pop3', 'lmtp', 'ldap' ].each do |conf_type|
  29. node['dovecot']['conf_files'][conf_type].each do |conf_file|
  30. notifies :create, "template[#{conf_file}]", :immediately
  31. end
  32. end
  33. end
  34. package 'dovecot' do action :nothing end
  35. # sieve
  36. ruby_block 'package-dovecot-sieve' do
  37. block {}
  38. only_if do Dovecot::Plugins.required?('sieve', node['dovecot']) end
  39. notifies :install, 'package[dovecot-pigeonhole]', :immediately
  40. node['dovecot']['conf_files']['sieve'].each do |conf_file|
  41. notifies :create, "template[#{conf_file}]", :immediately
  42. end
  43. end
  44. package 'dovecot-pigeonhole' do action :nothing end
  45. when 'debian', 'ubuntu' then
  46. # core
  47. ruby_block 'package-dovecot-core' do
  48. block {}
  49. notifies :install, 'package[dovecot-core]', :immediately
  50. notifies :install, 'package[dovecot-gssapi]', :immediately
  51. node['dovecot']['conf_files']['core'].each do |conf_file|
  52. notifies :create, "template[#{conf_file}]", :immediately
  53. end
  54. end
  55. package 'dovecot-core' do action :nothing end
  56. package 'dovecot-gssapi' do action :nothing end
  57. # imap
  58. ruby_block 'package-dovecot-imap' do
  59. block {}
  60. only_if do Dovecot::Protocols.enabled?('imap', node['dovecot']['protocols']) end
  61. notifies :install, 'package[dovecot-imapd]', :immediately
  62. node['dovecot']['conf_files']['imap'].each do |conf_file|
  63. notifies :create, "template[#{conf_file}]", :immediately
  64. end
  65. end
  66. package 'dovecot-imapd' do action :nothing end
  67. # pop3
  68. ruby_block 'package-dovecot-pop3d' do
  69. block {}
  70. only_if do Dovecot::Protocols.enabled?('pop3', node['dovecot']['protocols']) end
  71. notifies :install, 'package[dovecot-pop3d]', :immediately
  72. node['dovecot']['conf_files']['pop3'].each do |conf_file|
  73. notifies :create, "template[#{conf_file}]", :immediately
  74. end
  75. end
  76. package 'dovecot-pop3d' do action :nothing end
  77. # lmtp
  78. ruby_block 'package-dovecot-lmtpd' do
  79. block {}
  80. only_if do Dovecot::Protocols.enabled?('lmtp', node['dovecot']['protocols']) end
  81. notifies :install, 'package[dovecot-lmtpd]', :immediately
  82. node['dovecot']['conf_files']['lmtp'].each do |conf_file|
  83. notifies :create, "template[#{conf_file}]", :immediately
  84. end
  85. end
  86. package 'dovecot-lmtpd' do action :nothing end
  87. # sieve
  88. ruby_block 'package-dovecot-sieve' do
  89. block {}
  90. only_if do Dovecot::Plugins.required?('sieve', node['dovecot']) end
  91. notifies :install, 'package[dovecot-sieve]', :immediately
  92. notifies :install, 'package[dovecot-managesieved]', :immediately
  93. node['dovecot']['conf_files']['sieve'].each do |conf_file|
  94. notifies :create, "template[#{conf_file}]", :immediately
  95. end
  96. end
  97. package 'dovecot-sieve' do action :nothing end
  98. package 'dovecot-managesieved' do action :nothing end
  99. # ldap
  100. ruby_block 'package-dovecot-ldap' do
  101. block {}
  102. only_if do node['dovecot']['auth']['ldap'].kind_of?(Array) and node['dovecot']['auth']['ldap'].length > 0 end
  103. notifies :install, 'package[dovecot-ldap]', :immediately
  104. node['dovecot']['conf_files']['ldap'].each do |conf_file|
  105. notifies :create, "template[#{conf_file}]", :immediately
  106. end
  107. end
  108. package 'dovecot-ldap' do action :nothing end
  109. # sqlite
  110. ruby_block 'package-dovecot-sqlite' do
  111. block {}
  112. only_if do node['dovecot']['conf']['sql']['driver'] == 'sqlite' end
  113. notifies :install, 'package[dovecot-sqlite]', :immediately
  114. end
  115. package 'dovecot-sqlite' do action :nothing end
  116. else
  117. Chef::Application.fatal!("Unsupported platform: #{node['platform']}");
  118. end
  119. ruby_block 'package-dovecot-mysql' do
  120. block {}
  121. only_if do node['dovecot']['conf']['sql']['driver'] == 'mysql' end
  122. notifies :install, 'package[dovecot-mysql]', :immediately
  123. end
  124. package 'dovecot-mysql' do action :nothing end
  125. ruby_block 'package-dovecot-pgsql' do
  126. block {}
  127. only_if do node['dovecot']['conf']['sql']['driver'] == 'pgsql' end
  128. notifies :install, 'package[dovecot-pgsql]', :immediately
  129. end
  130. package 'dovecot-pgsql' do action :nothing end