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 "libosmpbf-dev"
30 package "libprotobuf-dev"
31 package "libboost-dev"
32 package "libexpat1-dev"
33 package "libsparsehash-dev"
34 package "libgd2-xpm-dev"
45 package "ruby#{node[:passenger][:ruby_version]}"
46 package "rubygems#{node[:passenger][:ruby_version]}"
50 gem_package "sinatra-r18n"
51 gem_package "rack-contrib"
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}/osmium" do
103 repository "git://github.com/joto/osmium.git"
104 revision "osmorg-taginfo-live"
109 git "#{directory}/taginfo" do
111 repository "git://github.com/joto/taginfo.git"
112 revision "osmorg-taginfo-live"
117 settings = Chef::DelayedEvaluator.new do
118 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
120 settings["instance"]["url"] = "http://#{name}/"
121 settings["instance"]["description"] = description
122 settings["instance"]["about"] = about
123 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
124 settings["instance"]["contact"] = contact
125 settings["instance"]["access_control_allow_origin"] = ""
126 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
127 settings["opensearch"]["shortname"] = "Taginfo"
128 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
129 settings["sources"]["download"] = ""
130 settings["sources"]["create"] = "db languages projects wiki"
131 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
132 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
133 settings["sources"]["db"]["tagstats"] = "#{directory}/taginfo/tagstats/tagstats"
134 settings["tagstats"]["cxxflags"] = "-I../../osmium/include"
135 settings["tagstats"]["geodistribution"] = "MmapAnon"
136 settings["user_interface"]["key_page"]["show_tab_similar"] = true
137 settings["level0"]["overpass_url_prefix"] = "http://overpass-api.de/api/interpreter?"
139 JSON.pretty_generate(settings)
142 file "#{directory}/taginfo-config.json" do
147 notifies :restart, "service[apache2]"
150 execute "#{directory}/taginfo/tagstats/Makefile" do
153 cwd "#{directory}/taginfo/tagstats"
156 subscribes :run, "git[#{directory}/osmium]"
157 subscribes :run, "git[#{directory}/taginfo]"
158 notifies :restart, "service[apache2]"
161 %w(taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication).each do |dir|
162 directory "#{directory}/#{dir}" do
169 remote_file "#{directory}/planet/planet.pbf" do
170 action :create_if_missing
171 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
177 template "#{directory}/planet/replication/configuration.txt" do
178 source "configuration.txt.erb"
184 file "#{directory}/planet/replication/download.lock" do
190 template "#{directory}/bin/update-planet" do
191 source "update-planet.erb"
195 variables :directory => directory
198 template "#{directory}/bin/update-taginfo" do
199 source "update-taginfo.erb"
203 variables :directory => directory
206 template "#{directory}/bin/update" do
211 variables :name => name, :directory => directory
215 template "apache.erb"
216 directory "#{directory}/taginfo/web/public"