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"
47 gem_package "sinatra-r18n"
48 gem_package "rack-contrib"
51 apache_module "disk_cache"
53 template "/etc/cron.d/taginfo" do
60 directory "/var/log/taginfo" do
66 file "/etc/logrotate.d/taginfo" do
70 node[:taginfo][:sites].each do |site|
72 directory = site[:directory] || "/srv/#{name}"
73 description = site[:description]
75 contact = site[:contact]
77 directory "/var/log/taginfo/#{name}" do
83 directory directory do
89 git "#{directory}/osmium" do
91 repository "git://github.com/joto/osmium.git"
92 revision "osmorg-taginfo-live"
97 git "#{directory}/taginfo" do
99 repository "git://github.com/joto/taginfo.git"
100 revision "osmorg-taginfo-live"
105 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
107 settings["instance"]["url"] = "http://#{name}/"
108 settings["instance"]["description"] = description
109 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
110 settings["instance"]["contact"] = contact
111 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
112 settings["opensearch"]["shortname"] = "Taginfo"
113 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
114 settings["sources"]["download"] = ""
115 settings["sources"]["create"] = "db languages josm potlatch wiki"
116 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
117 settings["sources"]["db"]["tagstats"] = "#{directory}/taginfo/tagstats/tagstats"
118 settings["tagstats"]["cxxflags"] = "-I../../osmium/include"
119 settings["tagstats"]["geodistribution"] = "MmapAnon"
121 file "#{directory}/taginfo-config.json" do
125 content JSON.pretty_generate(settings)
128 execute "#{directory}/taginfo/tagstats/Makefile" do
131 cwd "#{directory}/taginfo/tagstats"
134 subscribes :run, "git[#{directory}/osmium]"
135 subscribes :run, "git[#{directory}/taginfo]"
136 notifies :restart, "service[apache2]"
139 directory "#{directory}/taginfo/web/tmp" do
145 directory "#{directory}/data" do
151 directory "#{directory}/data/old" do
157 directory "#{directory}/download" do
163 directory "#{directory}/sources" do
169 directory "#{directory}/planet" do
175 remote_file "#{directory}/planet/planet.pbf" do
176 action :create_if_missing
177 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
183 directory "#{directory}/planet/log" do
189 directory "#{directory}/planet/replication" do
195 template "#{directory}/planet/replication/configuration.txt" do
196 source "configuration.txt.erb"
202 file "#{directory}/planet/replication/download.lock" do
208 directory "#{directory}/bin" do
214 template "#{directory}/bin/update-planet" do
215 source "update-planet.erb"
219 variables :directory => directory
222 template "#{directory}/bin/update-taginfo" do
223 source "update-taginfo.erb"
227 variables :directory => directory
230 template "#{directory}/bin/update" do
235 variables :name => name, :directory => directory
239 template "apache.erb"
240 directory "#{directory}/taginfo/web/public"