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"
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|
83 site_name = site[:name]
84 directory = site[:directory] || "/srv/#{site_name}"
85 description = site[:description]
88 contact = site[:contact]
90 directory "/var/log/taginfo/#{site_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/taginfo/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://#{site_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/#{site_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
173 execute "compile-osmium" do
175 command "cmake .. && make"
176 cwd "#{directory}/osmium-tool/build"
179 subscribes :run, "git[#{directory}/libosmium]"
180 subscribes :run, "git[#{directory}/osmium-tool]"
183 %w[taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication].each do |dir|
184 directory "#{directory}/#{dir}" do
191 remote_file "#{directory}/planet/planet.pbf" do
192 action :create_if_missing
193 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
199 template "#{directory}/planet/replication/configuration.txt" do
200 source "configuration.txt.erb"
206 file "#{directory}/planet/replication/download.lock" do
212 template "#{directory}/bin/update-planet" do
213 source "update-planet.erb"
217 variables :directory => directory
220 template "#{directory}/bin/update-taginfo" do
221 source "update-taginfo.erb"
225 variables :directory => directory
228 template "#{directory}/bin/update" do
233 variables :name => site_name, :directory => directory
236 ssl_certificate site_name do
238 notifies :reload, "service[apache2]"
241 apache_site site_name do
242 template "apache.erb"
243 directory "#{directory}/taginfo/web/public"