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"
28 package "libosmpbf-dev"
29 package "libprotobuf-dev"
30 package "libboost-dev"
31 package "libexpat1-dev"
32 package "libsparsehash-dev"
33 package "libgd2-xpm-dev"
44 package "ruby#{node[:passenger][:ruby_version]}"
45 package "rubygems#{node[:passenger][:ruby_version]}"
49 gem_package "sinatra-r18n"
50 gem_package "rack-contrib"
53 apache_module "cache_disk"
54 apache_module "headers"
56 template "/etc/cron.d/taginfo" do
63 directory "/var/log/taginfo" do
69 file "/etc/logrotate.d/taginfo" do
73 template "/etc/sudoers.d/taginfo" do
80 node[:taginfo][:sites].each do |site|
82 directory = site[:directory] || "/srv/#{name}"
83 description = site[:description]
86 contact = site[:contact]
88 directory "/var/log/taginfo/#{name}" do
94 directory directory do
100 git "#{directory}/osmium" do
102 repository "git://github.com/joto/osmium.git"
103 revision "osmorg-taginfo-live"
108 git "#{directory}/taginfo" do
110 repository "git://github.com/joto/taginfo.git"
111 revision "osmorg-taginfo-live"
116 settings = Chef::DelayedEvaluator.new do
117 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
119 settings["instance"]["url"] = "http://#{name}/"
120 settings["instance"]["description"] = description
121 settings["instance"]["about"] = about
122 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
123 settings["instance"]["contact"] = contact
124 settings["instance"]["access_control_allow_origin"] = ""
125 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
126 settings["opensearch"]["shortname"] = "Taginfo"
127 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
128 settings["sources"]["download"] = ""
129 settings["sources"]["create"] = "db languages projects wiki"
130 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
131 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
132 settings["sources"]["db"]["tagstats"] = "#{directory}/taginfo/tagstats/tagstats"
133 settings["tagstats"]["cxxflags"] = "-I../../osmium/include"
134 settings["tagstats"]["geodistribution"] = "MmapAnon"
135 settings["user_interface"]["key_page"]["show_tab_similar"] = true
136 settings["level0"]["overpass_url_prefix"] = "http://overpass-api.de/api/interpreter?"
138 JSON.pretty_generate(settings)
141 file "#{directory}/taginfo-config.json" do
146 notifies :restart, "service[apache2]"
149 execute "#{directory}/taginfo/tagstats/Makefile" do
152 cwd "#{directory}/taginfo/tagstats"
155 subscribes :run, "git[#{directory}/osmium]"
156 subscribes :run, "git[#{directory}/taginfo]"
157 notifies :restart, "service[apache2]"
160 %w(taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication).each do |dir|
161 directory "#{directory}/#{dir}" do
168 remote_file "#{directory}/planet/planet.pbf" do
169 action :create_if_missing
170 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
176 template "#{directory}/planet/replication/configuration.txt" do
177 source "configuration.txt.erb"
183 file "#{directory}/planet/replication/download.lock" do
189 template "#{directory}/bin/update-planet" do
190 source "update-planet.erb"
194 variables :directory => directory
197 template "#{directory}/bin/update-taginfo" do
198 source "update-taginfo.erb"
202 variables :directory => directory
205 template "#{directory}/bin/update" do
210 variables :name => name, :directory => directory
214 template "apache.erb"
215 directory "#{directory}/taginfo/web/public"