2 # Cookbook Name:: nominatim
5 # Copyright 2012, 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::ssl"
21 include_recipe "postgresql"
31 apache_module "rewrite"
32 apache_module "fastcgi-handler"
34 home_directory = data_bag_item("accounts", "nominatim")["home"]
35 source_directory = "#{home_directory}/nominatim"
36 email_errors = data_bag_item("accounts", "lonvia")["email"]
38 database_cluster = node[:nominatim][:database][:cluster]
39 database_version = database_cluster.sub(/\/.*/, "")
40 database_name = node[:nominatim][:database][:dbname]
42 postgis_version = node[:nominatim][:database][:postgis]
45 action [ :enable, :start ]
46 supports :status => true, :restart => true, :reload => true
49 apache_site "nominatim.openstreetmap.org" do
51 directory source_directory
52 variables :pools => node[:nominatim][:fpm_pools]
55 node[:nominatim][:fpm_pools].each do |name,data|
56 template "/etc/php5/fpm/pool.d/#{name}.conf" do
61 variables data.merge(:name => name)
62 notifies :reload, "service[php5-fpm]"
66 postgresql_user "tomh" do
67 cluster database_cluster
71 postgresql_user "lonvia" do
72 cluster database_cluster
76 postgresql_user "twain" do
77 cluster database_cluster
81 postgresql_user "nominatim" do
82 cluster database_cluster
86 postgresql_user "www-data" do
87 cluster database_cluster
90 postgresql_munin "nominatim" do
91 cluster database_cluster
92 database database_name
95 directory "/var/log/nominatim" do
101 template "/etc/logrotate.d/nominatim" do
102 source "logrotate.nominatim.erb"
113 package "postgresql-#{database_version}-postgis-#{postgis_version}"
114 package "postgresql-server-dev-#{database_version}"
115 package "build-essential"
116 package "libxml2-dev"
117 package "libgeos-dev"
118 package "libgeos++-dev"
123 package "libproj-dev"
124 package "libprotobuf-c0-dev"
125 package "protobuf-c-compiler"
126 package "python-psycopg2"
128 execute "php-pear-db" do
129 command "pear install DB"
130 not_if { File.exists?("/usr/share/php/DB") }
133 execute "compile_nominatim" do
135 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
139 git source_directory do
141 repository node[:nominatim][:repository]
142 enable_submodules true
145 notifies :run, "execute[compile_nominatim]"
148 directory "#{source_directory}/log" do
155 template "#{source_directory}/.git/hooks/post-merge" do
156 source "update_source.erb"
160 variables :source_directory => source_directory
163 template "#{source_directory}/settings/local.php" do
164 source "nominatim.erb"
170 template "#{source_directory}/settings/ip_blocks.conf" do
171 action :create_if_missing
172 source "ipblocks.erb"
178 file "#{source_directory}/settings/apache_blocks.conf" do
179 action :create_if_missing
185 file "#{source_directory}/settings/ip_blocks.map" do
186 action :create_if_missing
192 cron "nominatim_logrotate" do
196 command "#{source_directory}/utils/cron_logrotate.sh"
201 cron "nominatim_banip" do
202 command "#{source_directory}/utils/cron_banip.py"
207 cron "nominatim_vacuum" do
210 command "#{source_directory}/utils/cron_vacuum.sh"
215 ['search', 'reverse'].each do |filename|
216 ['phpj', 'phpx'].each do |ext|
217 link "#{source_directory}/website/#{filename}.#{ext}" do
218 to "#{source_directory}/website/#{filename}.php"
225 template "#{source_directory}/utils/nominatim-update" do
232 template "/etc/init.d/nominatim-update" do
233 source "updater.init.erb"
237 variables :source_directory => source_directory
240 munin_plugin_conf "nominatim" do
244 munin_plugin "nominatim_importlag" do
245 target "#{source_directory}/munin/nominatim_importlag"
248 munin_plugin "nominatim_query_speed" do
249 target "#{source_directory}/munin/nominatim_query_speed"
252 munin_plugin "nominatim_requests" do
253 target "#{source_directory}/munin/nominatim_requests"
256 munin_plugin "nominatim_throttled_ips" do
257 target "#{source_directory}/munin/nominatim_throttled_ips"
260 template "/usr/local/bin/backup-nominatim" do
261 source "backup-nominatim.erb"
267 cron "nominatim_backup" do
271 command "/usr/local/bin/backup-nominatim"