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 if node[:lsb][:release].to_f >= 14.04
35 apache_module "proxy_fcgi"
37 apache_module "fastcgi-handler"
40 home_directory = data_bag_item("accounts", "nominatim")["home"]
41 source_directory = "#{home_directory}/nominatim"
42 email_errors = data_bag_item("accounts", "lonvia")["email"]
44 database_cluster = node[:nominatim][:database][:cluster]
45 database_version = database_cluster.sub(/\/.*/, "")
46 database_name = node[:nominatim][:database][:dbname]
48 postgis_version = node[:nominatim][:database][:postgis]
51 if node[:lsb][:release].to_f >= 14.04
52 provider Chef::Provider::Service::Upstart
54 action [ :enable, :start ]
55 supports :status => true, :restart => true, :reload => true
58 apache_site "nominatim.openstreetmap.org" do
60 directory source_directory
61 variables :pools => node[:nominatim][:fpm_pools]
64 apache_site "default" do
68 node[:nominatim][:fpm_pools].each do |name,data|
69 template "/etc/php5/fpm/pool.d/#{name}.conf" do
74 variables data.merge(:name => name, :port => data[:port])
75 notifies :reload, "service[php5-fpm]"
79 postgresql_user "tomh" do
80 cluster database_cluster
84 postgresql_user "lonvia" do
85 cluster database_cluster
89 postgresql_user "twain" do
90 cluster database_cluster
94 postgresql_user "nominatim" do
95 cluster database_cluster
99 postgresql_user "www-data" do
100 cluster database_cluster
103 postgresql_munin "nominatim" do
104 cluster database_cluster
105 database database_name
108 directory "/var/log/nominatim" do
114 template "/etc/logrotate.d/nominatim" do
115 source "logrotate.nominatim.erb"
126 package "postgresql-#{database_version}-postgis-#{postgis_version}"
127 package "postgresql-server-dev-#{database_version}"
128 package "build-essential"
129 package "libxml2-dev"
130 package "libgeos-dev"
131 package "libgeos++-dev"
136 package "libproj-dev"
137 package "libprotobuf-c0-dev"
138 package "protobuf-c-compiler"
139 package "python-psycopg2"
141 execute "php-pear-db" do
142 command "pear install DB"
143 not_if { File.exists?("/usr/share/php/DB") }
146 execute "compile_nominatim" do
148 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
152 git source_directory do
154 repository node[:nominatim][:repository]
155 enable_submodules true
158 notifies :run, "execute[compile_nominatim]"
161 directory "#{source_directory}/log" do
168 template "#{source_directory}/.git/hooks/post-merge" do
169 source "update_source.erb"
173 variables :source_directory => source_directory
176 template "#{source_directory}/settings/local.php" do
177 source "nominatim.erb"
181 variables :postgres_version => database_version
184 template "#{source_directory}/settings/ip_blocks.conf" do
185 action :create_if_missing
186 source "ipblocks.erb"
192 file "#{source_directory}/settings/apache_blocks.conf" do
193 action :create_if_missing
199 file "#{source_directory}/settings/ip_blocks.map" do
200 action :create_if_missing
206 if node[:nominatim][:enabled]
207 cron_action = :create
209 cron_action = :delete
212 template "/etc/cron.d/nominatim" do
218 variables :bin_directory => "#{source_directory}/utils", :mailto => email_errors
222 template "#{source_directory}/utils/nominatim-update" do
229 template "/etc/init.d/nominatim-update" do
230 source "updater.init.erb"
234 variables :source_directory => source_directory
237 munin_plugin_conf "nominatim" do
241 munin_plugin "nominatim_importlag" do
242 target "#{source_directory}/munin/nominatim_importlag"
245 munin_plugin "nominatim_query_speed" do
246 target "#{source_directory}/munin/nominatim_query_speed_querylog"
249 munin_plugin "nominatim_requests" do
250 target "#{source_directory}/munin/nominatim_requests_querylog"
253 munin_plugin "nominatim_throttled_ips" do
254 target "#{source_directory}/munin/nominatim_throttled_ips"
257 template "/usr/local/bin/backup-nominatim" do
258 source "backup-nominatim.erb"
264 directory File.dirname(node[:nominatim][:flatnode_file]) do