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"
42 package "ruby#{node[:passenger][:ruby_version]}"
43 package "rubygems#{node[:passenger][:ruby_version]}"
47 gem_package "sinatra-r18n"
48 gem_package "rack-contrib"
51 apache_module "cache_disk"
52 apache_module "headers"
54 template "/etc/cron.d/taginfo" do
61 directory "/var/log/taginfo" do
67 file "/etc/logrotate.d/taginfo" do
71 template "/etc/sudoers.d/taginfo" do
78 node[:taginfo][:sites].each do |site|
80 directory = site[:directory] || "/srv/#{name}"
81 description = site[:description]
84 contact = site[:contact]
86 directory "/var/log/taginfo/#{name}" do
92 directory directory do
98 git "#{directory}/libosmium" do
100 repository "git://github.com/osmcode/libosmium.git"
106 git "#{directory}/taginfo" do
108 repository "git://github.com/joto/taginfo.git"
109 revision "osmorg-taginfo-live"
114 settings = Chef::DelayedEvaluator.new do
115 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
117 settings["instance"]["url"] = "http://#{name}/"
118 settings["instance"]["description"] = description
119 settings["instance"]["about"] = about
120 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
121 settings["instance"]["contact"] = contact
122 settings["instance"]["access_control_allow_origin"] = ""
123 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
124 settings["opensearch"]["shortname"] = "Taginfo"
125 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
126 settings["sources"]["download"] = ""
127 settings["sources"]["create"] = "db languages projects wiki"
128 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
129 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
130 settings["sources"]["db"]["tagstats"] = "#{directory}/taginfo/tagstats/tagstats"
131 settings["tagstats"]["cxxflags"] = "-I../../libosmium/include"
132 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
133 settings["user_interface"]["key_page"]["show_tab_similar"] = true
134 settings["level0"]["overpass_url_prefix"] = "http://overpass-api.de/api/interpreter?"
136 JSON.pretty_generate(settings)
139 file "#{directory}/taginfo-config.json" do
144 notifies :restart, "service[apache2]"
147 execute "#{directory}/taginfo/tagstats/Makefile" do
150 cwd "#{directory}/taginfo/tagstats"
153 subscribes :run, "git[#{directory}/libosmium]"
154 subscribes :run, "git[#{directory}/taginfo]"
155 notifies :restart, "service[apache2]"
158 %w(taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication).each do |dir|
159 directory "#{directory}/#{dir}" do
166 remote_file "#{directory}/planet/planet.pbf" do
167 action :create_if_missing
168 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
174 template "#{directory}/planet/replication/configuration.txt" do
175 source "configuration.txt.erb"
181 file "#{directory}/planet/replication/download.lock" do
187 template "#{directory}/bin/update-planet" do
188 source "update-planet.erb"
192 variables :directory => directory
195 template "#{directory}/bin/update-taginfo" do
196 source "update-taginfo.erb"
200 variables :directory => directory
203 template "#{directory}/bin/update" do
208 variables :name => name, :directory => directory
212 template "apache.erb"
213 directory "#{directory}/taginfo/web/public"