2 # Cookbook Name:: civicrm
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"
25 passwords = data_bag_item("civicrm", "passwords")
27 database_password = passwords["database"]
28 site_key = passwords["key"]
30 mysql_user "civicrm@localhost" do
31 password database_password
34 mysql_database "civicrm" do
35 permissions "civicrm@localhost" => :all
38 wordpress_site "join.osmfoundation.org" do
39 aliases "crm.osmfoundation.org"
40 database_name "civicrm"
41 database_user "civicrm"
42 database_password database_password
45 wordpress_theme "osmblog-wp-theme" do
46 site "join.osmfoundation.org"
47 repository "git://github.com/harry-wood/osmblog-wp-theme.git"
50 wordpress_plugin "registration-honeypot" do
51 site "join.osmfoundation.org"
54 wordpress_plugin "sitepress-multilingual-cms" do
55 site "join.osmfoundation.org"
56 repository "https://chef.openstreetmap.org/sitepress-multilingual-cms.git"
59 wordpress_plugin "contact-form-7" do
60 site "join.osmfoundation.org"
63 civicrm_version = node[:civicrm][:version]
64 civicrm_directory = "/srv/join.osmfoundation.org/wp-content/plugins/civicrm"
66 directory "/opt/civicrm-#{civicrm_version}" do
72 remote_file "/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip" do
73 action :create_if_missing
74 source "https://download.civicrm.org/civicrm-#{civicrm_version}-wordpress.zip"
81 remote_file "/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz" do
82 action :create_if_missing
83 source "https://download.civicrm.org/civicrm-#{civicrm_version}-l10n.tar.gz"
90 execute "/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip" do
92 command "unzip -qq /var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip"
93 cwd "/opt/civicrm-#{civicrm_version}"
96 subscribes :run, "remote_file[/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
99 execute "/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz" do
101 command "tar -zxf /var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz"
102 cwd "/opt/civicrm-#{civicrm_version}/civicrm"
105 subscribes :run, "remote_file[/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
108 execute "/opt/civicrm-#{civicrm_version}/civicrm" do
110 command "rsync --archive --delete /opt/civicrm-#{civicrm_version}/civicrm/ #{civicrm_directory}"
113 subscribes :run, "execute[/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
114 subscribes :run, "execute[/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
117 directory "/srv/join.osmfoundation.org/wp-content/plugins/files" do
123 extensions_directory = "/srv/join.osmfoundation.org/wp-content/plugins/civicrm-extensions"
125 directory extensions_directory do
131 node[:civicrm][:extensions].each_value do |details|
132 git "#{extensions_directory}/#{details[:name]}" do
134 repository details[:repository]
135 revision details[:revision]
141 settings = edit_file "#{civicrm_directory}/civicrm/templates/CRM/common/civicrm.settings.php.template" do |line|
142 line.gsub!(/%%cms%%/, "WordPress")
143 line.gsub!(/%%CMSdbUser%%/, "civicrm")
144 line.gsub!(/%%CMSdbPass%%/, database_password)
145 line.gsub!(/%%CMSdbHost%%/, "localhost")
146 line.gsub!(/%%CMSdbName%%/, "civicrm")
147 line.gsub!(/%%dbUser%%/, "civicrm")
148 line.gsub!(/%%dbPass%%/, database_password)
149 line.gsub!(/%%dbHost%%/, "localhost")
150 line.gsub!(/%%dbName%%/, "civicrm")
151 line.gsub!(/%%crmRoot%%/, "#{civicrm_directory}/civicrm/")
152 line.gsub!(/%%templateCompileDir%%/, "/srv/join.osmfoundation.org/wp-content/plugins/files/civicrm/templates_c/")
153 line.gsub!(/%%baseURL%%/, "http://join.osmfoundation.org/")
154 line.gsub!(/%%siteKey%%/, site_key)
155 line.gsub!(%r{// *(.*'ext_repo_url'.*)$}, "\\1")
156 line.gsub!(%r{// *define\('CIVICRM_CMSDIR', '/path/to/install/root/'\);}, "define('CIVICRM_CMSDIR', '/srv/join.osmfoundation.org');")
161 file "#{civicrm_directory}/civicrm.settings.php" do
168 template "/etc/cron.d/osmf-crm" do
173 variables :directory => civicrm_directory, :passwords => passwords
176 template "/etc/cron.daily/osmf-crm-backup" do
177 source "backup.cron.erb"
181 variables :passwords => passwords