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::ssl"
23 include_recipe "passenger"
26 package "libsqlite3-dev"
29 package "libboost-dev"
30 package "libexpat1-dev"
31 package "libsparsehash-dev"
32 package "libgd2-xpm-dev"
34 package "libboost-program-options-dev"
44 ruby_version = node[:passenger][:ruby_version]
46 package "ruby#{ruby_version}"
48 %w(json sqlite3 sinatra sinatra-r18n rack-contrib).each do |gem|
50 gem_binary "gem#{ruby_version}"
55 apache_module "cache_disk"
56 apache_module "headers"
58 template "/etc/cron.d/taginfo" do
65 directory "/var/log/taginfo" do
71 file "/etc/logrotate.d/taginfo" do
75 template "/etc/sudoers.d/taginfo" do
82 node[:taginfo][:sites].each do |site|
84 directory = site[:directory] || "/srv/#{name}"
85 description = site[:description]
88 contact = site[:contact]
90 directory "/var/log/taginfo/#{name}" do
96 directory directory do
102 git "#{directory}/libosmium" do
104 repository "git://github.com/osmcode/libosmium.git"
110 git "#{directory}/osmium-tool" do
112 repository "git://github.com/osmcode/osmium-tool.git"
118 git "#{directory}/taginfo" do
120 repository "git://github.com/joto/taginfo.git"
121 revision "osmorg-taginfo-live"
126 settings = Chef::DelayedEvaluator.new do
127 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
129 settings["instance"]["url"] = "http://#{name}/"
130 settings["instance"]["description"] = description
131 settings["instance"]["about"] = about
132 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
133 settings["instance"]["contact"] = contact
134 settings["instance"]["access_control_allow_origin"] = ""
135 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
136 settings["opensearch"]["shortname"] = "Taginfo"
137 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
138 settings["sources"]["download"] = ""
139 settings["sources"]["create"] = "db languages projects wiki"
140 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
141 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
142 settings["tagstats"]["cxxflags"] = "-I../../libosmium/include"
143 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
145 JSON.pretty_generate(settings)
148 file "#{directory}/taginfo-config.json" do
153 notifies :restart, "service[apache2]"
156 execute "#{directory}/taginfo/tagstats/Makefile" do
159 cwd "#{directory}/taginfo/tagstats"
162 subscribes :run, "git[#{directory}/libosmium]"
163 subscribes :run, "git[#{directory}/taginfo]"
164 notifies :restart, "service[apache2]"
167 directory "#{directory}/osmium-tool/build" do
174 execute "compile-osmium" do
176 command "cmake .. && make"
177 cwd "#{directory}/osmium-tool/build"
180 subscribes :run, "git[#{directory}/libosmium]"
181 subscribes :run, "git[#{directory}/osmium-tool]"
184 %w(taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication).each do |dir|
185 directory "#{directory}/#{dir}" do
192 remote_file "#{directory}/planet/planet.pbf" do
193 action :create_if_missing
194 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
200 template "#{directory}/planet/replication/configuration.txt" do
201 source "configuration.txt.erb"
207 file "#{directory}/planet/replication/download.lock" do
213 template "#{directory}/bin/update-planet" do
214 source "update-planet.erb"
218 variables :directory => directory
221 template "#{directory}/bin/update-taginfo" do
222 source "update-taginfo.erb"
226 variables :directory => directory
229 template "#{directory}/bin/update" do
234 variables :name => name, :directory => directory
238 template "apache.erb"
239 directory "#{directory}/taginfo/web/public"