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"
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"]
38 database_cluster = node[:nominatim][:database][:cluster]
39 database_version = database_cluster.sub(/\/.*/, "")
40 database_name = node[:nominatim][:database][:dbname]
43 action [ :enable, :start ]
44 supports :status => true, :restart => true, :reload => true
47 apache_site "nominatim.openstreetmap.org" do
49 directory source_directory
50 variables :pools => node[:nominatim][:fpm_pools]
53 node[:nominatim][:fpm_pools].each do |name,data|
54 template "/etc/php5/fpm/pool.d/#{name}.conf" do
59 variables data.merge(:name => name)
60 notifies :reload, "service[php5-fpm]"
64 postgresql_user "tomh" do
65 cluster database_cluster
69 postgresql_user "lonvia" do
70 cluster database_cluster
74 postgresql_user "twain" do
75 cluster database_cluster
79 postgresql_user "nominatim" do
80 cluster database_cluster
84 postgresql_user "www-data" do
85 cluster database_cluster
88 postgresql_munin "nominatim" do
89 cluster database_cluster
90 database database_name
93 directory "/var/log/nominatim" do
99 template "/etc/logrotate.d/nominatim" do
100 source "logrotate.nominatim.erb"
111 package "postgresql-#{database_version}-postgis"
112 package "postgresql-server-dev-#{database_version}"
113 package "build-essential"
114 package "libxml2-dev"
115 package "libgeos-dev"
116 package "libgeos++-dev"
121 package "libproj-dev"
122 package "libprotobuf-c0-dev"
123 package "protobuf-c-compiler"
124 package "python-psycopg2"
126 execute "php-pear-db" do
127 command "pear install DB"
128 not_if { File.exists?("/usr/share/php/DB") }
131 execute "compile_nominatim" do
133 command "cd #{source_directory} && ./autogen.sh && ./configure && make"
137 git source_directory do
139 repository node[:nominatim][:repository]
140 enable_submodules true
143 notifies :run, "execute[compile_nominatim]"
146 directory "#{source_directory}/log" do
153 template "#{source_directory}/.git/hooks/post-merge" do
154 source "update_source.erb"
158 variables :source_directory => source_directory
161 template "#{source_directory}/settings/local.php" do
162 source "nominatim.erb"
168 template "#{source_directory}/settings/ip_blocks.conf" do
169 action :create_if_missing
170 source "ipblocks.erb"
176 file "#{source_directory}/settings/apache_blocks.conf" do
177 action :create_if_missing
183 file "#{source_directory}/settings/ip_blocks.map" do
184 action :create_if_missing
190 cron "nominatim_logrotate" do
194 command "#{source_directory}/utils/cron_logrotate.sh"
199 cron "nominatim_banip" do
200 command "#{source_directory}/utils/cron_banip.py"
205 cron "nominatim_vacuum" do
208 command "#{source_directory}/utils/cron_vacuum.sh"
213 ['search', 'reverse'].each do |filename|
214 ['phpj', 'phpx'].each do |ext|
215 link "#{source_directory}/website/#{filename}.#{ext}" do
216 to "#{source_directory}/website/#{filename}.php"
223 template "#{source_directory}/utils/nominatim-update" do
230 template "/etc/init.d/nominatim-update" do
231 source "updater.init.erb"
235 variables :source_directory => source_directory
238 munin_plugin_conf "nominatim" do
242 munin_plugin "nominatim_importlag" do
243 target "#{source_directory}/munin/nominatim_importlag"
246 munin_plugin "nominatim_query_speed" do
247 target "#{source_directory}/munin/nominatim_query_speed"
250 munin_plugin "nominatim_requests" do
251 target "#{source_directory}/munin/nominatim_requests"
254 munin_plugin "nominatim_throttled_ips" do
255 target "#{source_directory}/munin/nominatim_throttled_ips"
258 template "/usr/local/bin/backup-nominatim" do
259 source "backup-nominatim.erb"
265 cron "nominatim_backup" do
269 command "/usr/local/bin/backup-nominatim"