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 # 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.
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 %w[json sqlite3 sinatra sinatra-r18n rack-contrib].each do |gem|
54 gem_binary "gem#{ruby_version}"
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 directory = site[:directory] || "/srv/#{site_name}"
89 description = site[:description]
92 contact = site[:contact]
94 directory "/var/log/taginfo/#{site_name}" do
100 directory directory do
106 git "#{directory}/libosmium" do
108 repository "git://github.com/osmcode/libosmium.git"
114 git "#{directory}/osmium-tool" do
116 repository "git://github.com/osmcode/osmium-tool.git"
122 git "#{directory}/taginfo" do
124 repository "git://github.com/taginfo/taginfo.git"
125 revision "osmorg-taginfo-live"
130 settings = Chef::DelayedEvaluator.new do
131 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
133 settings["instance"]["url"] = "http://#{site_name}/"
134 settings["instance"]["description"] = description
135 settings["instance"]["about"] = about
136 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
137 settings["instance"]["contact"] = contact
138 settings["instance"]["access_control_allow_origin"] = ""
139 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
140 settings["opensearch"]["shortname"] = "Taginfo"
141 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
142 settings["sources"]["download"] = ""
143 settings["sources"]["create"] = "db languages projects wiki"
144 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
145 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
146 settings["tagstats"]["cxxflags"] = "-I../../libosmium/include"
147 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
149 JSON.pretty_generate(settings)
152 file "#{directory}/taginfo-config.json" do
157 notifies :restart, "service[apache2]"
160 execute "#{directory}/taginfo/tagstats/Makefile" do
163 cwd "#{directory}/taginfo/tagstats"
166 subscribes :run, "git[#{directory}/libosmium]"
167 subscribes :run, "git[#{directory}/taginfo]"
168 notifies :restart, "service[apache2]"
171 directory "#{directory}/osmium-tool/build" do
177 execute "compile-osmium" do
179 command "cmake .. && make"
180 cwd "#{directory}/osmium-tool/build"
183 subscribes :run, "git[#{directory}/libosmium]"
184 subscribes :run, "git[#{directory}/osmium-tool]"
187 %w[taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication].each do |dir|
188 directory "#{directory}/#{dir}" do
195 remote_file "#{directory}/planet/planet.pbf" do
196 action :create_if_missing
197 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
203 template "#{directory}/planet/replication/configuration.txt" do
204 source "configuration.txt.erb"
210 file "#{directory}/planet/replication/download.lock" do
216 template "#{directory}/bin/update-planet" do
217 source "update-planet.erb"
221 variables :directory => directory
224 template "#{directory}/bin/update-taginfo" do
225 source "update-taginfo.erb"
229 variables :directory => directory
232 template "#{directory}/bin/update" do
237 variables :name => site_name, :directory => directory
240 ssl_certificate site_name do
242 notifies :reload, "service[apache2]"
245 apache_site site_name do
246 template "apache.erb"
247 directory "#{directory}/taginfo/web/public"