2 # Cookbook Name:: taginfo
5 # Copyright 2014, 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 # https://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.
22 include_recipe "apache"
23 include_recipe "passenger"
35 libboost-program-options-dev
48 ruby_version = node[:passenger][:ruby_version]
50 package "ruby#{ruby_version}"
52 gem_package "bundler#{ruby_version}" do
53 package_name "bundler"
54 gem_binary "gem#{ruby_version}"
55 options "--format-executable"
59 apache_module "cache_disk"
60 apache_module "headers"
62 template "/etc/cron.d/taginfo" do
69 directory "/var/log/taginfo" do
75 file "/etc/logrotate.d/taginfo" do
79 template "/etc/sudoers.d/taginfo" do
86 node[:taginfo][:sites].each do |site|
87 site_name = site[:name]
88 site_aliases = Array(site[:aliases])
89 directory = site[:directory] || "/srv/#{site_name}"
90 description = site[:description]
93 contact = site[:contact]
95 directory "/var/log/taginfo/#{site_name}" do
101 directory directory do
107 git "#{directory}/libosmium" do
109 repository "git://github.com/osmcode/libosmium.git"
115 git "#{directory}/osmium-tool" do
117 repository "git://github.com/osmcode/osmium-tool.git"
123 git "#{directory}/taginfo" do
125 repository "git://github.com/taginfo/taginfo.git"
126 revision "osmorg-taginfo-live"
131 settings = Chef::DelayedEvaluator.new do
132 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
134 settings["instance"]["url"] = "https://#{site_name}/"
135 settings["instance"]["description"] = description
136 settings["instance"]["about"] = about
137 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
138 settings["instance"]["contact"] = contact
139 settings["instance"]["access_control_allow_origin"] = ""
140 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
141 settings["opensearch"]["shortname"] = "Taginfo"
142 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
143 settings["sources"]["download"] = ""
144 settings["sources"]["create"] = "db languages projects wiki"
145 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
146 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
147 settings["tagstats"]["cxxflags"] = "-I../../libosmium/include"
148 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
150 JSON.pretty_generate(settings)
153 file "#{directory}/taginfo-config.json" do
158 notifies :restart, "service[apache2]"
161 execute "#{directory}/taginfo/tagstats/Makefile" do
164 cwd "#{directory}/taginfo/tagstats"
167 subscribes :run, "git[#{directory}/libosmium]"
168 subscribes :run, "git[#{directory}/taginfo]"
169 notifies :restart, "service[apache2]"
172 directory "#{directory}/osmium-tool/build" do
178 execute "compile-osmium" do
180 command "cmake .. && make"
181 cwd "#{directory}/osmium-tool/build"
184 subscribes :run, "git[#{directory}/libosmium]"
185 subscribes :run, "git[#{directory}/osmium-tool]"
188 execute "#{directory}/taginfo/Gemfile" do
190 command "bundle#{ruby_version} install"
191 cwd "#{directory}/taginfo"
194 subscribes :run, "gem_package[bundler#{ruby_version}]"
195 subscribes :run, "git[#{directory}/taginfo]"
196 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
199 %w[taginfo/web/tmp bin data data/old download sources planet planet/log].each do |dir|
200 directory "#{directory}/#{dir}" do
207 remote_file "#{directory}/planet/planet.pbf" do
208 action :create_if_missing
209 source "https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
215 template "#{directory}/bin/update-planet" do
216 source "update-planet.erb"
220 variables :directory => directory
223 template "#{directory}/bin/update-taginfo" do
224 source "update-taginfo.erb"
228 variables :directory => directory
231 template "#{directory}/bin/update" do
236 variables :name => site_name, :directory => directory
239 passenger_application "#{directory}/taginfo/web/public"
241 ssl_certificate site_name do
242 domains [site_name] + site_aliases
243 notifies :reload, "service[apache2]"
246 apache_site site_name do
247 template "apache.erb"
248 directory "#{directory}/taginfo/web/public"
249 variables :aliases => site_aliases