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]", :immediately
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]", :immediately
89 execute "/opt/civicrm-#{civicrm_version}/civicrm" do
91 command "rsync --archive --delete /opt/civicrm-#{civicrm_version}/civicrm/ #{civicrm_directory}"
94 subscribes :run, "execute[/var/cache/chef/civicrm-#{civicrm_version}-wordpress.zip]", :immediately
95 subscribes :run, "execute[/var/cache/chef/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately
98 directory "/srv/crm.osmfoundation.org/wp-content/plugins/files" do
104 settings = edit_file "#{civicrm_directory}/civicrm/templates/CRM/common/civicrm.settings.php.template" do |line|
105 line.gsub!(/%%cms%%/, "WordPress")
106 line.gsub!(/%%CMSdbUser%%/, "civicrm")
107 line.gsub!(/%%CMSdbPass%%/, database_password)
108 line.gsub!(/%%CMSdbHost%%/, "localhost")
109 line.gsub!(/%%CMSdbName%%/, "civicrm")
110 line.gsub!(/%%dbUser%%/, "civicrm")
111 line.gsub!(/%%dbPass%%/, database_password)
112 line.gsub!(/%%dbHost%%/, "localhost")
113 line.gsub!(/%%dbName%%/, "civicrm")
114 line.gsub!(/%%crmRoot%%/, "#{civicrm_directory}/civicrm")
115 line.gsub!(/%%templateCompileDir%%/, "/srv/crm.osmfoundation.org/wp-content/plugins/files/civicrm/templates_c")
116 line.gsub!(/%%baseURL%%/, "http://crm.osmfoundation.org/")
117 line.gsub!(/%%siteKey%%/, site_key)
122 file "#{civicrm_directory}/civicrm/civicrm.settings.php" do
129 template "/etc/cron.daily/osmf-crm-backup" do
130 source "backup.cron.erb"
134 variables :passwords => passwords