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 # http://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"
41 database_name "civicrm"
42 database_user "civicrm"
43 database_password database_password
46 wordpress_theme "osmblog-wp-theme" do
47 site "join.osmfoundation.org"
48 repository "git://github.com/harry-wood/osmblog-wp-theme.git"
51 wordpress_plugin "registration-honeypot" do
52 site "join.osmfoundation.org"
55 wordpress_plugin "sitepress-multilingual-cms" do
56 site "join.osmfoundation.org"
57 repository "git://chef.openstreetmap.org/sitepress-multilingual-cms.git"
60 civicrm_version = node[:civicrm][:version]
61 civicrm_directory = "/srv/join.osmfoundation.org/wp-content/plugins/civicrm"
63 directory "/opt/civicrm-#{civicrm_version}" do
69 remote_file "/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip" do
70 action :create_if_missing
71 source "https://download.civicrm.org/civicrm-#{civicrm_version}-wordpress.zip"
78 remote_file "/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz" do
79 action :create_if_missing
80 source "https://download.civicrm.org/civicrm-#{civicrm_version}-l10n.tar.gz"
87 execute "/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip" do
89 command "unzip -qq /var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip"
90 cwd "/opt/civicrm-#{civicrm_version}"
93 subscribes :run, "remote_file[/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
96 execute "/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz" do
98 command "tar -zxf /var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz"
99 cwd "/opt/civicrm-#{civicrm_version}/civicrm"
102 subscribes :run, "remote_file[/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
105 execute "/opt/civicrm-#{civicrm_version}/civicrm" do
107 command "rsync --archive --delete /opt/civicrm-#{civicrm_version}/civicrm/ #{civicrm_directory}"
110 subscribes :run, "execute[/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
111 subscribes :run, "execute[/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
114 directory "/srv/join.osmfoundation.org/wp-content/plugins/files" do
120 settings = edit_file "#{civicrm_directory}/civicrm/templates/CRM/common/civicrm.settings.php.template" do |line|
121 line.gsub!(/%%cms%%/, "WordPress")
122 line.gsub!(/%%CMSdbUser%%/, "civicrm")
123 line.gsub!(/%%CMSdbPass%%/, database_password)
124 line.gsub!(/%%CMSdbHost%%/, "localhost")
125 line.gsub!(/%%CMSdbName%%/, "civicrm")
126 line.gsub!(/%%dbUser%%/, "civicrm")
127 line.gsub!(/%%dbPass%%/, database_password)
128 line.gsub!(/%%dbHost%%/, "localhost")
129 line.gsub!(/%%dbName%%/, "civicrm")
130 line.gsub!(/%%crmRoot%%/, "#{civicrm_directory}/civicrm/")
131 line.gsub!(/%%templateCompileDir%%/, "/srv/join.osmfoundation.org/wp-content/plugins/files/civicrm/templates_c/")
132 line.gsub!(/%%baseURL%%/, "http://join.osmfoundation.org/")
133 line.gsub!(/%%siteKey%%/, site_key)
138 file "#{civicrm_directory}/civicrm.settings.php" do
145 template "/etc/cron.d/osmf-crm" do
150 variables :directory => civicrm_directory, :passwords => passwords
153 template "/etc/cron.daily/osmf-crm-backup" do
154 source "backup.cron.erb"
158 variables :passwords => passwords