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, "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 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';")
 
  90 file "/srv/thinkup.openstreetmap.org/webapp/config.inc.php" do
 
  94   content thinkup_config
 
  95   notifies :reload, "service[apache2]"
 
  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")
 
 108 file "/srv/thinkup.openstreetmap.org/extras/cron/config" do
 
 115 template "/etc/cron.d/thinkup" do
 
 122 template "/etc/cron.daily/thinkup-backup" do
 
 123   source "backup.cron.erb"
 
 127   variables :passwords => passwords