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 action [ :enable, :start ]
52 supports :status => true, :restart => true, :reload => true
55 apache_site "nominatim.openstreetmap.org" do
57 directory source_directory
58 variables :pools => node[:nominatim][:fpm_pools]
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)
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"
134 execute "php-pear-db" do
135 command "pear install DB"
136 not_if { File.exists?("/usr/share/php/DB") }
139 execute "compile_nominatim" do
141 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
145 git source_directory do
147 repository node[:nominatim][:repository]
148 enable_submodules true
151 notifies :run, "execute[compile_nominatim]"
154 directory "#{source_directory}/log" do
161 template "#{source_directory}/.git/hooks/post-merge" do
162 source "update_source.erb"
166 variables :source_directory => source_directory
169 template "#{source_directory}/settings/local.php" do
170 source "nominatim.erb"
176 template "#{source_directory}/settings/ip_blocks.conf" do
177 action :create_if_missing
178 source "ipblocks.erb"
184 file "#{source_directory}/settings/apache_blocks.conf" do
185 action :create_if_missing
191 file "#{source_directory}/settings/ip_blocks.map" do
192 action :create_if_missing
198 cron "nominatim_logrotate" do
202 command "#{source_directory}/utils/cron_logrotate.sh"
207 cron "nominatim_banip" do
208 command "#{source_directory}/utils/cron_banip.py"
213 cron "nominatim_vacuum" do
216 command "#{source_directory}/utils/cron_vacuum.sh"
221 ['search', 'reverse'].each do |filename|
222 ['phpj', 'phpx'].each do |ext|
223 link "#{source_directory}/website/#{filename}.#{ext}" do
224 to "#{source_directory}/website/#{filename}.php"
231 template "#{source_directory}/utils/nominatim-update" do
238 template "/etc/init.d/nominatim-update" do
239 source "updater.init.erb"
243 variables :source_directory => source_directory
246 munin_plugin_conf "nominatim" do
250 munin_plugin "nominatim_importlag" do
251 target "#{source_directory}/munin/nominatim_importlag"
254 munin_plugin "nominatim_query_speed" do
255 target "#{source_directory}/munin/nominatim_query_speed"
258 munin_plugin "nominatim_requests" do
259 target "#{source_directory}/munin/nominatim_requests"
262 munin_plugin "nominatim_throttled_ips" do
263 target "#{source_directory}/munin/nominatim_throttled_ips"
266 template "/usr/local/bin/backup-nominatim" do
267 source "backup-nominatim.erb"
273 cron "nominatim_backup" do
277 command "/usr/local/bin/backup-nominatim"