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
100 package "postgresql-9.1-postgis"
101 package "postgresql-server-dev-9.1"
102 package "build-essential"
103 package "libxml2-dev"
104 package "libgeos-dev"
105 package "libgeos++-dev"
110 package "libproj-dev"
111 package "libprotobuf-c0-dev"
112 package "protobuf-c-compiler"
113 package "python-psycopg2"
115 execute "php-pear-db" do
116 command "pear install DB"
117 not_if { File.exists?("/usr/share/php/DB") }
120 execute "compile_nominatim" do
122 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
126 git source_directory do
128 repository node[:nominatim][:repository]
129 enable_submodules true
132 notifies :run, "execute[compile_nominatim]"
135 directory "#{source_directory}/log" do
142 template "#{source_directory}/.git/hooks/post-merge" do
143 source "update_source.erb"
147 variables :source_directory => source_directory
150 template "#{source_directory}/settings/local.php" do
151 source "nominatim.erb"
157 template "#{source_directory}/settings/ip_blocks.conf" do
158 action :create_if_missing
159 source "ipblocks.erb"
165 file "#{source_directory}/settings/apache_blocks.conf" do
166 action :create_if_missing
172 file "#{source_directory}/settings/ip_blocks.map" do
173 action :create_if_missing
179 cron "nominatim_logrotate" do
183 command "#{source_directory}/utils/cron_logrotate.sh"
188 cron "nominatim_banip" do
189 command "#{source_directory}/utils/cron_banip.py"
194 cron "nominatim_vacuum" do
197 command "#{source_directory}/utils/cron_vacuum.sh"
202 ['search', 'reverse'].each do |filename|
203 ['phpj', 'phpx'].each do |ext|
204 link "#{source_directory}/website/#{filename}.#{ext}" do
205 to "#{source_directory}/website/#{filename}.php"
212 template "#{source_directory}/utils/nominatim-update" do
219 template "/etc/init.d/nominatim-update" do
220 source "updater.init.erb"
224 variables :source_directory => source_directory
227 munin_plugin_conf "nominatim" do
231 munin_plugin "nominatim_importlag" do
232 target "#{source_directory}/munin/nominatim_importlag"
235 munin_plugin "nominatim_query_speed" do
236 target "#{source_directory}/munin/nominatim_query_speed"
239 munin_plugin "nominatim_requests" do
240 target "#{source_directory}/munin/nominatim_requests"
243 munin_plugin "nominatim_throttled_ips" do
244 target "#{source_directory}/munin/nominatim_throttled_ips"
247 template "/usr/local/bin/backup-nominatim" do
248 source "backup-nominatim.erb"
254 cron "nominatim_backup" do
258 command "/usr/local/bin/backup-nominatim"