-execute "compile_nominatim" do
- action :nothing
- command "cd #{source_directory} && ./autogen.sh && ./configure && make"
- user "nominatim"
+if node[:nominatim][:state] == "master"
+ postgresql_user "replication" do
+ cluster node[:nominatim][:dbcluster]
+ password data_bag_item("nominatim", "passwords")["replication"]
+ replication true
+ end
+
+ directory node[:rsyncd][:modules][:archive][:path] do
+ owner "postgres"
+ group "postgres"
+ mode "700"
+ end
+
+ template "/usr/local/bin/clean-db-nominatim" do
+ source "clean-db-nominatim.erb"
+ owner "root"
+ group "root"
+ mode "755"
+ variables :archive_dir => node[:rsyncd][:modules][:archive][:path],
+ :update_stop_file => "#{basedir}/status/updates_disabled",
+ :streaming_clients => search(:node, "nominatim_state:slave").map { |slave| slave[:fqdn] }.join(" ")
+ end
+end
+
+## Nominatim backend
+
+include_recipe "git"
+
+package %w[
+ build-essential
+ cmake
+ g++
+ libboost-dev
+ libboost-system-dev
+ libboost-filesystem-dev
+ libexpat1-dev
+ zlib1g-dev
+ libxml2-dev
+ libbz2-dev
+ libpq-dev
+ libgeos++-dev
+ libproj-dev
+ python3-pyosmium
+ pyosmium
+ python3-psycopg2
+ php-pgsql
+ php-intl
+]
+
+source_directory = "#{basedir}/nominatim"
+build_directory = "#{basedir}/bin"
+
+directory build_directory do
+ owner "nominatim"
+ group "nominatim"
+ mode "755"
+ recursive true