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"
23 passwords = data_bag_item("civicrm", "passwords")
25 database_password = passwords["database"]
26 admin_password = passwords["admin"]
27 site_key = passwords["key"]
29 mysql_user "civicrm@localhost" do
30 password database_password
33 mysql_database "civicrm" do
34 permissions "civicrm@localhost" => :all
37 wordpress_site "crm.osmfoundation.org" do
39 database_name "civicrm"
40 database_user "civicrm"
41 database_password database_password
44 civicrm_version = node[:civicrm][:version]
45 civicrm_directory = "/srv/crm.osmfoundation.org/wp-content/plugins/civicrm"
47 directory "/opt/civicrm-#{civicrm_version}" do
53 remote_file "/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip" do
54 action :create_if_missing
55 source "http://downloads.sourceforge.net/project/civicrm/civicrm-stable/#{civicrm_version}/civicrm-#{civicrm_version}-wordpress.zip"
62 remote_file "/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz" do
63 action :create_if_missing
64 source "http://downloads.sourceforge.net/project/civicrm/civicrm-stable/#{civicrm_version}/civicrm-#{civicrm_version}-l10n.tar.gz"
71 execute "/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip" do
73 command "unzip -qq /var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip"
74 cwd "/opt/civicrm-#{civicrm_version}"
77 subscribes :run, "remote_file[/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip]"
80 execute "/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz" do
82 command "tar -zxf /var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz"
83 cwd "/opt/civicrm-#{civicrm_version}/civicrm"
86 subscribes :run, "remote_file[/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz]"
89 link civicrm_directory do
90 to "/opt/civicrm-#{civicrm_version}/civicrm"
93 directory "/srv/crm.osmfoundation.org/wp-content/plugins/files" do
99 settings = edit_file "#{civicrm_directory}/civicrm/templates/CRM/common/civicrm.settings.php.template" do |line|
100 line.gsub!(/%%cms%%/, "WordPress")
101 line.gsub!(/%%CMSdbUser%%/, "civicrm")
102 line.gsub!(/%%CMSdbPass%%/, database_password)
103 line.gsub!(/%%CMSdbHost%%/, "localhost")
104 line.gsub!(/%%CMSdbName%%/, "civicrm")
105 line.gsub!(/%%dbUser%%/, "civicrm")
106 line.gsub!(/%%dbPass%%/, database_password)
107 line.gsub!(/%%dbHost%%/, "localhost")
108 line.gsub!(/%%dbName%%/, "civicrm")
109 line.gsub!(/%%crmRoot%%/, "#{civicrm_directory}/civicrm")
110 line.gsub!(/%%templateCompileDir%%/, "/srv/crm.osmfoundation.org/wp-content/plugins/files/civicrm/templates_c")
111 line.gsub!(/%%baseURL%%/, "http://crm.osmfoundation.org/")
112 line.gsub!(/%%siteKey%%/, site_key)
117 file "#{civicrm_directory}/civicrm/civicrm.settings.php" do
124 template "/etc/cron.daily/osmf-crm-backup" do
125 source "backup.cron.erb"
129 variables :passwords => passwords