2 # Cookbook Name:: thinkup
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 "apache"
21 include_recipe "mysql"
23 passwords = data_bag_item("thinkup", "passwords")
35 apache_site "thinkup.openstreetmap.org" do
39 mysql_user "thinkup@localhost" do
40 password passwords["database"]
43 mysql_database "thinkup" do
44 permissions "thinkup@localhost" => :all
47 git "/srv/thinkup.openstreetmap.org" do
49 repository "git://github.com/ginatrapani/ThinkUp.git"
53 notifies :reload, resources(:service => "apache2")
56 directory "/srv/thinkup.openstreetmap.org/logs" do
62 directory "/srv/thinkup.openstreetmap.org/logs/archive" do
68 directory "/srv/thinkup.openstreetmap.org/webapp/data" do
74 directory "/srv/thinkup.openstreetmap.org/webapp/_lib/view/compiled_view" do
80 file "/srv/thinkup.openstreetmap.org/webapp/config.inc.php" do
84 content_from_file "/srv/thinkup.openstreetmap.org/webapp/config.sample.inc.php" do |line|
85 line.gsub!(/^(\$THINKUP_CFG\['site_root_path'\] *=) '[^']*';$/, "\\1 '/';")
86 line.gsub!(/^(\$THINKUP_CFG\['timezone'\] *=) '[^']*';$/, "\\1 'Europe/London';")
87 line.gsub!(/^(\$THINKUP_CFG\['db_user'\] *=) '[^']*';$/, "\\1 'thinkup';")
88 line.gsub!(/^(\$THINKUP_CFG\['db_password'\] *=) '[^']*';$/, "\\1 '#{passwords["database"]}';")
89 line.gsub!(/^(\$THINKUP_CFG\['db_name'\] *=) '[^']*';$/, "\\1 'thinkup';")
93 notifies :reload, resources(:service => "apache2")
96 file "/srv/thinkup.openstreetmap.org/extras/cron/config" do
100 content_from_file "/srv/thinkup.openstreetmap.org/extras/cron/config.sample" do |line|
101 line.gsub!(/^thinkup="[^"]*"$/, "thinkup=\"/srv/thinkup.openstreetmap.org\"")
102 line.gsub!(/^thinkup_username="[^"]*"$/, "thinkup_username=\"openstreetmap@jonno.cix.co.uk\"")
103 line.gsub!(/^thinkup_password="[^"]*"$/, "thinkup_password=\"#{passwords["admin"]}\"")
104 line.gsub!(/^php="[^"]*"$/, "php=\"/usr/bin/php\"")
105 line.gsub!(/^#crawl_interval=[0-9]+$/, "crawl_interval=30")
111 template "/etc/cron.d/thinkup" do
118 template "/etc/cron.daily/thinkup-backup" do
119 source "backup.cron.erb"
123 variables :passwords => passwords