-template "/etc/logrotate.d/nominatim" do
- source "logrotate.nominatim.erb"
- owner "root"
- group "root"
- mode 0644
-end
-
-package "osmosis"
-package "gcc"
-package "proj-bin"
-package "libgeos-c1"
-package "postgresql-#{database_version}-postgis-#{postgis_version}"
-package "postgresql-server-dev-#{database_version}"
-package "build-essential"
-package "libxml2-dev"
-package "libgeos-dev"
-package "libgeos++-dev"
-package "libpq-dev"
-package "libbz2-dev"
-package "libtool"
-package "automake"
-package "libproj-dev"
-package "libprotobuf-c0-dev"
-package "protobuf-c-compiler"
-package "python-psycopg2"
-package "libboost-dev"
-package "libboost-system-dev"
-package "libboost-filesystem-dev"
-package "libboost-thread-dev"
-
-execute "php-pear-db" do
- command "pear install DB"
- not_if { File.exist?("/usr/share/php/DB") }
+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