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"
43 ruby_version = node[:passenger][:ruby_version]
45 package "ruby#{ruby_version}"
47 %w(json sqlite3 sinatra sinatra-r18n rack-contrib).each do |gem|
49 gem_binary "gem#{ruby_version}"
54 apache_module "cache_disk"
55 apache_module "headers"
57 template "/etc/cron.d/taginfo" do
64 directory "/var/log/taginfo" do
70 file "/etc/logrotate.d/taginfo" do
74 template "/etc/sudoers.d/taginfo" do
81 node[:taginfo][:sites].each do |site|
83 directory = site[:directory] || "/srv/#{name}"
84 description = site[:description]
87 contact = site[:contact]
89 directory "/var/log/taginfo/#{name}" do
95 directory directory do
101 git "#{directory}/libosmium" do
103 repository "git://github.com/osmcode/libosmium.git"
109 git "#{directory}/osmium-tool" do
111 repository "git://github.com/osmcode/osmium-tool.git"
117 git "#{directory}/taginfo" do
119 repository "git://github.com/joto/taginfo.git"
120 revision "osmorg-taginfo-live"
125 settings = Chef::DelayedEvaluator.new do
126 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
128 settings["instance"]["url"] = "http://#{name}/"
129 settings["instance"]["description"] = description
130 settings["instance"]["about"] = about
131 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
132 settings["instance"]["contact"] = contact
133 settings["instance"]["access_control_allow_origin"] = ""
134 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
135 settings["opensearch"]["shortname"] = "Taginfo"
136 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
137 settings["sources"]["download"] = ""
138 settings["sources"]["create"] = "db languages projects wiki"
139 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
140 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
141 settings["tagstats"]["cxxflags"] = "-I../../libosmium/include"
142 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
143 settings["level0"]["overpass_url_prefix"] = "http://overpass-api.de/api/interpreter?"
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
172 subscribes :create, "git[#{directory}/libosmium]"
173 subscribes :create, "git[#{directory}/osmium-tool]"
176 execute "compile-osmium" do
178 command "cmake .. && make"
179 cwd "#{directory}/osmium-tool/build"
182 subscribes :run, "git[#{directory}/libosmium]"
183 subscribes :run, "git[#{directory}/osmium-tool]"
184 subscribes :run, "directory[#{directory}/osmium-tool/build]"
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 => name, :directory => directory
241 template "apache.erb"
242 directory "#{directory}/taginfo/web/public"