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"
33 apache_module "proxy_fcgi"
35 home_directory = data_bag_item("accounts", "nominatim")["home"]
36 source_directory = "#{home_directory}/nominatim"
37 email_errors = data_bag_item("accounts", "lonvia")["email"]
39 database_cluster = node[:nominatim][:database][:cluster]
40 database_version = database_cluster.sub(/\/.*/, "")
41 database_name = node[:nominatim][:database][:dbname]
43 postgis_version = node[:nominatim][:database][:postgis]
46 provider Chef::Provider::Service::Upstart
47 action [ :enable, :start ]
48 supports :status => true, :restart => true, :reload => true
51 apache_site "nominatim.openstreetmap.org" do
53 directory source_directory
54 variables :pools => node[:nominatim][:fpm_pools]
57 apache_site "default" do
61 node[:nominatim][:fpm_pools].each do |name,data|
62 template "/etc/php5/fpm/pool.d/#{name}.conf" do
67 variables data.merge(:name => name, :port => data[:port])
68 notifies :reload, "service[php5-fpm]"
72 postgresql_user "tomh" do
73 cluster database_cluster
77 postgresql_user "lonvia" do
78 cluster database_cluster
82 postgresql_user "twain" do
83 cluster database_cluster
87 postgresql_user "nominatim" do
88 cluster database_cluster
92 postgresql_user "www-data" do
93 cluster database_cluster
96 postgresql_munin "nominatim" do
97 cluster database_cluster
98 database database_name
101 directory "/var/log/nominatim" do
107 template "/etc/logrotate.d/nominatim" do
108 source "logrotate.nominatim.erb"
119 package "postgresql-#{database_version}-postgis-#{postgis_version}"
120 package "postgresql-server-dev-#{database_version}"
121 package "build-essential"
122 package "libxml2-dev"
123 package "libgeos-dev"
124 package "libgeos++-dev"
129 package "libproj-dev"
130 package "libprotobuf-c0-dev"
131 package "protobuf-c-compiler"
132 package "python-psycopg2"
133 package "libboost-dev"
134 package "libboost-system-dev"
135 package "libboost-filesystem-dev"
136 package "libboost-thread-dev"
138 execute "php-pear-db" do
139 command "pear install DB"
140 not_if { File.exist?("/usr/share/php/DB") }
143 execute "compile_nominatim" do
145 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
149 git source_directory do
151 repository node[:nominatim][:repository]
152 enable_submodules true
155 notifies :run, "execute[compile_nominatim]"
158 directory "#{source_directory}/log" do
165 template "#{source_directory}/.git/hooks/post-merge" do
166 source "update_source.erb"
170 variables :source_directory => source_directory
173 template "#{source_directory}/settings/local.php" do
174 source "nominatim.erb"
178 variables :postgres_version => database_version
181 template "#{source_directory}/settings/ip_blocks.conf" do
182 action :create_if_missing
183 source "ipblocks.erb"
189 file "#{source_directory}/settings/apache_blocks.conf" do
190 action :create_if_missing
196 file "#{source_directory}/settings/ip_blocks.map" do
197 action :create_if_missing
203 if node[:nominatim][:enabled]
204 cron_action = :create
206 cron_action = :delete
209 template "/etc/cron.d/nominatim" do
215 variables :bin_directory => "#{source_directory}/utils", :mailto => email_errors
219 template "#{source_directory}/utils/nominatim-update" do
226 template "/etc/init.d/nominatim-update" do
227 source "updater.init.erb"
231 variables :source_directory => source_directory
234 munin_plugin_conf "nominatim" do
238 munin_plugin "nominatim_importlag" do
239 target "#{source_directory}/munin/nominatim_importlag"
242 munin_plugin "nominatim_query_speed" do
243 target "#{source_directory}/munin/nominatim_query_speed_querylog"
246 munin_plugin "nominatim_requests" do
247 target "#{source_directory}/munin/nominatim_requests_querylog"
250 munin_plugin "nominatim_throttled_ips" do
251 target "#{source_directory}/munin/nominatim_throttled_ips"
254 remote_file "#{source_directory}/data/wikipedia_article.sql.bin" do
255 action :create_if_missing
256 source "http://www.nominatim.org/data/wikipedia_article.sql.bin"
262 remote_file "#{source_directory}/data/wikipedia_redirect.sql.bin" do
263 action :create_if_missing
264 source "http://www.nominatim.org/data/wikipedia_redirect.sql.bin"
270 remote_file "#{source_directory}/data/gb_postcode_data.sql.gz" do
271 action :create_if_missing
272 source "http://www.nominatim.org/data/gb_postcode_data.sql.gz"
278 template "/usr/local/bin/backup-nominatim" do
279 source "backup-nominatim.erb"
285 directory File.dirname(node[:nominatim][:flatnode_file]) do