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"
43 package "ruby#{node[:passenger][:ruby_version]}"
44 package "rubygems#{node[:passenger][:ruby_version]}"
48 gem_package "sinatra-r18n"
49 gem_package "rack-contrib"
52 apache_module "cache_disk"
53 apache_module "headers"
55 template "/etc/cron.d/taginfo" do
62 directory "/var/log/taginfo" do
68 file "/etc/logrotate.d/taginfo" do
72 node[:taginfo][:sites].each do |site|
74 directory = site[:directory] || "/srv/#{name}"
75 description = site[:description]
78 contact = site[:contact]
80 directory "/var/log/taginfo/#{name}" do
86 directory directory do
92 git "#{directory}/osmium" do
94 repository "git://github.com/joto/osmium.git"
95 revision "osmorg-taginfo-live"
100 git "#{directory}/taginfo" do
102 repository "git://github.com/joto/taginfo.git"
103 revision "osmorg-taginfo-live"
108 settings = Chef::DelayedEvaluator.new do
109 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
111 settings["instance"]["url"] = "http://#{name}/"
112 settings["instance"]["description"] = description
113 settings["instance"]["about"] = about
114 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
115 settings["instance"]["contact"] = contact
116 settings["instance"]["access_control_allow_origin"] = ""
117 settings["logging"]["directory"] = "/var/log/taginfo/#{name}"
118 settings["opensearch"]["shortname"] = "Taginfo"
119 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
120 settings["sources"]["download"] = "josm"
121 settings["sources"]["create"] = "db languages potlatch projects wiki"
122 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
123 settings["sources"]["db"]["tagstats"] = "#{directory}/taginfo/tagstats/tagstats"
124 settings["tagstats"]["cxxflags"] = "-I../../osmium/include"
125 settings["tagstats"]["geodistribution"] = "MmapAnon"
127 JSON.pretty_generate(settings)
130 file "#{directory}/taginfo-config.json" do
137 execute "#{directory}/taginfo/tagstats/Makefile" do
140 cwd "#{directory}/taginfo/tagstats"
143 subscribes :run, "git[#{directory}/osmium]"
144 subscribes :run, "git[#{directory}/taginfo]"
145 notifies :restart, "service[apache2]"
148 %w(taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication).each do |dir|
149 directory "#{directory}/#{dir}" do
156 remote_file "#{directory}/planet/planet.pbf" do
157 action :create_if_missing
158 source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
164 template "#{directory}/planet/replication/configuration.txt" do
165 source "configuration.txt.erb"
171 file "#{directory}/planet/replication/download.lock" do
177 template "#{directory}/bin/update-planet" do
178 source "update-planet.erb"
182 variables :directory => directory
185 template "#{directory}/bin/update-taginfo" do
186 source "update-taginfo.erb"
190 variables :directory => directory
193 template "#{directory}/bin/update" do
198 variables :name => name, :directory => directory
202 template "apache.erb"
203 directory "#{directory}/taginfo/web/public"