+ mode "755"
+ variables :threads => lowzoom_threads
+end
+
+systemd_service "render-lowzoom" do
+ description "Render low zoom tiles"
+ condition_path_exists_glob "!/run/update-lowzoom-*"
+ user "tile"
+ exec_start "/usr/local/bin/render-lowzoom"
+ sandbox true
+ restrict_address_families "AF_UNIX"
+ read_write_paths "/var/log/tile"
+end
+
+systemd_timer "render-lowzoom" do
+ description "Render low zoom tiles"
+ on_calendar "23:00 #{node[:timezone]}"
+end
+
+service "render-lowzoom.timer" do
+ action [:enable, :start]
+end
+
+package "liblockfile-simple-perl"
+package "libfilesys-df-perl"
+
+template "/usr/local/bin/cleanup-tiles" do
+ source "cleanup-tiles.erb"
+ owner "root"
+ group "root"
+ mode "755"
+end
+
+systemd_service "cleanup-tiles@" do
+ description "Cleanup old tiles for /%I"
+ exec_start "/usr/local/bin/cleanup-tiles /%I"
+ user "_renderd"
+ io_scheduling_class "idle"
+ sandbox true
+ read_write_paths "/%I"
+end
+
+systemd_timer "cleanup-tiles@" do
+ description "Cleanup old tiles for /%I"
+ on_boot_sec "30m"
+ on_unit_inactive_sec "60m"
+ randomized_delay_sec "10m"
+end
+
+tile_directories.each do |directory|
+ label = directory[1..].gsub("/", "-")
+
+ service "cleanup-tiles@#{label}.timer" do
+ action [:enable, :start]
+ end