5 # Copyright:: 2011, OpenStreetMap Foundation
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
11 # https://www.apache.org/licenses/LICENSE-2.0
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.
20 include_recipe "wordpress"
21 include_recipe "mysql"
29 cache_dir = Chef::Config[:file_cache_path]
31 passwords = data_bag_item("civicrm", "passwords")
33 database_password = passwords["database"]
34 site_key = passwords["key"]
36 mysql_user "civicrm@localhost" do
37 password database_password
40 mysql_database "civicrm" do
41 permissions "civicrm@localhost" => :all
44 wordpress_site "join.osmfoundation.org" do
45 aliases "crm.osmfoundation.org"
46 database_name "civicrm"
47 database_user "civicrm"
48 database_password database_password
51 wordpress_theme "osmblog-wp-theme" do
52 site "join.osmfoundation.org"
53 repository "https://github.com/harry-wood/osmblog-wp-theme.git"
56 wordpress_plugin "registration-honeypot" do
57 site "join.osmfoundation.org"
60 wordpress_plugin "sitepress-multilingual-cms" do
61 site "join.osmfoundation.org"
62 repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git"
63 not_if { ENV["TEST_KITCHEN"] }
66 wordpress_plugin "contact-form-7" do
67 site "join.osmfoundation.org"
70 civicrm_version = node[:civicrm][:version]
71 civicrm_directory = "/srv/join.osmfoundation.org/wp-content/plugins/civicrm"
73 directory "/opt/civicrm-#{civicrm_version}" do
79 remote_file "#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" do
80 action :create_if_missing
81 source "https://download.civicrm.org/civicrm-#{civicrm_version}-wordpress.zip"
88 remote_file "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do
89 action :create_if_missing
90 source "https://download.civicrm.org/civicrm-#{civicrm_version}-l10n.tar.gz"
97 execute "#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" do
99 command "unzip -o -qq #{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip"
100 cwd "/opt/civicrm-#{civicrm_version}"
103 subscribes :run, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
106 execute "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do
108 command "tar -zxf #{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz"
109 cwd "/opt/civicrm-#{civicrm_version}/civicrm"
112 subscribes :run, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
115 execute "/opt/civicrm-#{civicrm_version}/civicrm" do
117 command "rsync --archive --delete /opt/civicrm-#{civicrm_version}/civicrm/ #{civicrm_directory}"
120 subscribes :run, "execute[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
121 subscribes :run, "execute[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
124 directory "/srv/join.osmfoundation.org/wp-content/plugins/files" do
130 extensions_directory = "/srv/join.osmfoundation.org/wp-content/plugins/civicrm-extensions"
132 directory extensions_directory do
138 node[:civicrm][:extensions].each_value do |details|
139 git "#{extensions_directory}/#{details[:name]}" do
141 repository details[:repository]
142 revision details[:revision]
148 settings = edit_file "#{civicrm_directory}/civicrm/templates/CRM/common/civicrm.settings.php.template" do |line|
149 line.gsub!(/%%cms%%/, "WordPress")
150 line.gsub!(/%%CMSdbUser%%/, "civicrm")
151 line.gsub!(/%%CMSdbPass%%/, database_password)
152 line.gsub!(/%%CMSdbHost%%/, "localhost")
153 line.gsub!(/%%CMSdbName%%/, "civicrm")
154 line.gsub!(/%%dbUser%%/, "civicrm")
155 line.gsub!(/%%dbPass%%/, database_password)
156 line.gsub!(/%%dbHost%%/, "localhost")
157 line.gsub!(/%%dbName%%/, "civicrm")
158 line.gsub!(/%%crmRoot%%/, "#{civicrm_directory}/civicrm/")
159 line.gsub!(/%%templateCompileDir%%/, "/srv/join.osmfoundation.org/wp-content/plugins/files/civicrm/templates_c/")
160 line.gsub!(/%%baseURL%%/, "http://join.osmfoundation.org/")
161 line.gsub!(/%%siteKey%%/, site_key)
162 line.gsub!(%r{// *(.*'ext_repo_url'.*)$}, "\\1")
163 line.gsub!(%r{// *define\('CIVICRM_CMSDIR', '/path/to/install/root/'\);}, "define('CIVICRM_CMSDIR', '/srv/join.osmfoundation.org');")
168 file "#{civicrm_directory}/civicrm.settings.php" do
175 template "/etc/cron.d/osmf-crm" do
180 variables :directory => civicrm_directory, :passwords => passwords
183 template "/etc/cron.daily/osmf-crm-backup" do
184 source "backup.cron.erb"
188 variables :passwords => passwords