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"
48 gem_package "sinatra-r18n"
49 gem_package "rack-contrib"
52 apache_module "cache_disk"
54 template "/etc/cron.d/taginfo" do
61 directory "/var/log/taginfo" do
67 file "/etc/logrotate.d/taginfo" do
71 node[:taginfo][:sites].each do |site|
73 directory = site[:directory] || "/srv/#{name}"
74 description = site[:description]
77 contact = site[:contact]
79 directory "/var/log/taginfo/#{name}" do
85 directory directory do
91 git "#{directory}/osmium" do
93 repository "git://github.com/joto/osmium.git"
94 revision "osmorg-taginfo-live"
99 git "#{directory}/taginfo" do
101 repository "git://github.com/joto/taginfo.git"
102 revision "osmorg-taginfo-live"
107 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
109 settings["instance"]["url"] = "http://#{name}/"
110 settings["instance"]["description"] = description
111 settings["instance"]["about"] = about
112 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
113 settings["instance"]["contact"] = contact
114 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
115 settings["opensearch"]["shortname"] = "Taginfo"
116 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
117 settings["sources"]["download"] = "josm"
118 settings["sources"]["create"] = "db languages potlatch projects wiki"
119 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
120 settings["sources"]["db"]["tagstats"] = "#{directory}/taginfo/tagstats/tagstats"
121 settings["tagstats"]["cxxflags"] = "-I../../osmium/include"
122 settings["tagstats"]["geodistribution"] = "MmapAnon"
124 file "#{directory}/taginfo-config.json" do
128 content JSON.pretty_generate(settings)
131 execute "#{directory}/taginfo/tagstats/Makefile" do
134 cwd "#{directory}/taginfo/tagstats"
137 subscribes :run, "git[#{directory}/osmium]"
138 subscribes :run, "git[#{directory}/taginfo]"
139 notifies :restart, "service[apache2]"
142 directory "#{directory}/taginfo/web/tmp" do
148 directory "#{directory}/data" do
154 directory "#{directory}/data/old" do
160 directory "#{directory}/download" do
166 directory "#{directory}/sources" do
172 directory "#{directory}/planet" do
178 remote_file "#{directory}/planet/planet.pbf" do
179 action :create_if_missing
180 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
186 directory "#{directory}/planet/log" do
192 directory "#{directory}/planet/replication" do
198 template "#{directory}/planet/replication/configuration.txt" do
199 source "configuration.txt.erb"
205 file "#{directory}/planet/replication/download.lock" do
211 directory "#{directory}/bin" do
217 template "#{directory}/bin/update-planet" do
218 source "update-planet.erb"
222 variables :directory => directory
225 template "#{directory}/bin/update-taginfo" do
226 source "update-taginfo.erb"
230 variables :directory => directory
233 template "#{directory}/bin/update" do
238 variables :name => name, :directory => directory
242 template "apache.erb"
243 directory "#{directory}/taginfo/web/public"