]> git.openstreetmap.org Git - chef.git/blob - cookbooks/thinkup/recipes/default.rb
Convert all notify/subscribe calls to the new style syntax
[chef.git] / cookbooks / thinkup / recipes / default.rb
1 #
2 # Cookbook Name:: thinkup
3 # Recipe:: default
4 #
5 # Copyright 2011, OpenStreetMap Foundation
6 #
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
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19
20 include_recipe "apache"
21 include_recipe "mysql"
22
23 passwords = data_bag_item("thinkup", "passwords")
24
25 package "php5"
26 package "php5-cli"
27 package "php5-curl"
28 package "php5-mysql"
29 package "php5-gd"
30
31 package "php-apc"
32
33 apache_module "php5"
34
35 apache_site "thinkup.openstreetmap.org" do
36   template "apache.erb"
37 end
38
39 mysql_user "thinkup@localhost" do
40   password passwords["database"]
41 end
42
43 mysql_database "thinkup" do
44   permissions "thinkup@localhost" => :all
45 end
46
47 git "/srv/thinkup.openstreetmap.org" do
48   action :sync
49   repository "git://github.com/ginatrapani/ThinkUp.git"
50   revision "v1.2.1"
51   user "root"
52   group "root"
53   notifies :reload, "service[apache2]"
54 end
55
56 directory "/srv/thinkup.openstreetmap.org/logs" do
57   owner "thinkup"
58   group "thinkup"
59   mode "0755"
60 end
61
62 directory "/srv/thinkup.openstreetmap.org/logs/archive" do
63   owner "thinkup"
64   group "thinkup"
65   mode "0755"
66 end
67
68 directory "/srv/thinkup.openstreetmap.org/webapp/data" do
69   owner "www-data"
70   group "www-data"
71   mode "0755"
72 end
73
74 directory "/srv/thinkup.openstreetmap.org/webapp/_lib/view/compiled_view" do
75   owner "www-data"
76   group "www-data"
77   mode "0755"
78 end
79
80 thinkup_config = edit_file "/srv/thinkup.openstreetmap.org/webapp/config.sample.inc.php" do |line|
81   line.gsub!(/^(\$THINKUP_CFG\['site_root_path'\] *=) '[^']*';$/, "\\1 '/';")
82   line.gsub!(/^(\$THINKUP_CFG\['timezone'\] *=) '[^']*';$/, "\\1 'Europe/London';")
83   line.gsub!(/^(\$THINKUP_CFG\['db_user'\] *=) '[^']*';$/, "\\1 'thinkup';")
84   line.gsub!(/^(\$THINKUP_CFG\['db_password'\] *=) '[^']*';$/, "\\1 '#{passwords["database"]}';")
85   line.gsub!(/^(\$THINKUP_CFG\['db_name'\] *=) '[^']*';$/, "\\1 'thinkup';")
86
87   line
88 end
89
90 file "/srv/thinkup.openstreetmap.org/webapp/config.inc.php" do
91   owner "root"
92   group "root"
93   mode 0644
94   content thinkup_config
95   notifies :reload, "service[apache2]"
96 end
97
98 thinkup_cron = edit_file "/srv/thinkup.openstreetmap.org/extras/cron/config.sample" do |line|
99   line.gsub!(/^thinkup="[^"]*"$/, "thinkup=\"/srv/thinkup.openstreetmap.org\"")
100   line.gsub!(/^thinkup_username="[^"]*"$/, "thinkup_username=\"openstreetmap@jonno.cix.co.uk\"")
101   line.gsub!(/^thinkup_password="[^"]*"$/, "thinkup_password=\"#{passwords["admin"]}\"")
102   line.gsub!(/^php="[^"]*"$/, "php=\"/usr/bin/php\"")
103   line.gsub!(/^#crawl_interval=[0-9]+$/, "crawl_interval=30")
104
105   line
106 end
107
108 file "/srv/thinkup.openstreetmap.org/extras/cron/config" do
109   owner "root"
110   group "thinkup"
111   mode 0640
112   content thinkup_cron
113 end
114
115 template "/etc/cron.d/thinkup" do
116   source "cron.erb"
117   owner "root"
118   group "root"
119   mode "0644"
120 end
121
122 template "/etc/cron.daily/thinkup-backup" do
123   source "backup.cron.erb"
124   owner "root"
125   group "root"
126   mode 0750
127   variables :passwords => passwords
128 end