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"
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"]
39 action [ :enable, :start ]
40 supports :status => true, :restart => true, :reload => true
43 apache_site "nominatim.openstreetmap.org" do
45 directory source_directory
46 variables :pools => node[:nominatim][:fpm_pools]
49 node[:nominatim][:fpm_pools].each do |name,data|
51 template "/etc/php5/fpm/pool.d/#{name}.conf" do
56 variables data.merge(:name => name)
57 notifies :reload, "service[php5-fpm]"
61 postgresql_user "tomh" do
66 postgresql_user "lonvia" do
71 postgresql_user "twain" do
76 postgresql_user "nominatim" do
81 postgresql_user "www-data" do
85 postgresql_munin "nominatim" do
90 directory "/var/log/nominatim" do
96 template "/etc/logrotate.d/nominatim" do
97 source "logrotate.nominatim.erb"
108 package "postgresql-9.1-postgis"
109 package "postgresql-server-dev-9.1"
110 package "build-essential"
111 package "libxml2-dev"
112 package "libgeos-dev"
113 package "libgeos++-dev"
118 package "libproj-dev"
119 package "libprotobuf-c0-dev"
120 package "protobuf-c-compiler"
121 package "python-psycopg2"
123 execute "php-pear-db" do
124 command "pear install DB"
125 not_if { File.exists?("/usr/share/php/DB") }
128 execute "compile_nominatim" do
130 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
134 git source_directory do
136 repository node[:nominatim][:repository]
137 enable_submodules true
140 notifies :run, "execute[compile_nominatim]"
143 directory "#{source_directory}/log" do
150 template "#{source_directory}/.git/hooks/post-merge" do
151 source "update_source.erb"
155 variables :source_directory => source_directory
158 template "#{source_directory}/settings/local.php" do
159 source "nominatim.erb"
165 template "#{source_directory}/settings/ip_blocks.conf" do
166 action :create_if_missing
167 source "ipblocks.erb"
173 file "#{source_directory}/settings/apache_blocks.conf" do
174 action :create_if_missing
180 file "#{source_directory}/settings/ip_blocks.map" do
181 action :create_if_missing
187 cron "nominatim_logrotate" do
191 command "#{source_directory}/utils/cron_logrotate.sh"
196 cron "nominatim_banip" do
197 command "#{source_directory}/utils/cron_banip.py"
202 cron "nominatim_vacuum" do
205 command "#{source_directory}/utils/cron_vacuum.sh"
210 ['search', 'reverse'].each do |filename|
211 ['phpj', 'phpx'].each do |ext|
212 link "#{source_directory}/website/#{filename}.#{ext}" do
213 to "#{source_directory}/website/#{filename}.php"
220 template "#{source_directory}/utils/nominatim-update" do
227 template "/etc/init.d/nominatim-update" do
228 source "updater.init.erb"
232 variables :source_directory => source_directory
235 munin_plugin_conf "nominatim" do
239 munin_plugin "nominatim_importlag" do
240 target "#{source_directory}/munin/nominatim_importlag"
243 munin_plugin "nominatim_query_speed" do
244 target "#{source_directory}/munin/nominatim_query_speed"
247 munin_plugin "nominatim_requests" do
248 target "#{source_directory}/munin/nominatim_requests"
251 munin_plugin "nominatim_throttled_ips" do
252 target "#{source_directory}/munin/nominatim_throttled_ips"
255 template "/usr/local/bin/backup-nominatim" do
256 source "backup-nominatim.erb"
262 cron "nominatim_backup" do
266 command "/usr/local/bin/backup-nominatim"