gem_package "sinatra-r18n"
gem_package "rack-contrib"
+directory "/var/log/taginfo" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+end
+
+template "/etc/logrotate.d/taginfo" do
+ source "logrotate.erb"
+ owner "root"
+ group "root"
+ mode 0644
+end
+
node[:taginfo][:sites].each do |site|
name = site[:name]
directory = site[:directory] || "/srv/#{name}"
icon = site[:icon]
contact = site[:contact]
+ directory "/var/log/taginfo/#{site}" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
directory directory do
owner "taginfo"
group "taginfo"
settings["instance"]["description"] = description
settings["instance"]["icon"] = "/img/logo/#{icon}.png"
settings["instance"]["contact"] = contact
+ settings["logging"]["directory"] = "/var/log/taginfo/#{site}"
settings["opensearch"]["shortname"] = "Taginfo"
settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
+ settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
settings["tagstats"]["cxxflags"] = "-I../../osmium/include"
file "#{directory}/taginfo-config.json" do
notifies :restart, "service[apache2]"
end
+ directory "#{directory}/taginfo/web/tmp" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
+ directory "#{directory}/data" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
+ directory "#{directory}/download" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
+ directory "#{directory}/sources" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
directory "#{directory}/planet" do
owner "taginfo"
group "taginfo"
mode 0644
end
- template "#{directory}/planet/configuration.txt" do
+ directory "#{directory}/planet/log" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
+ directory "#{directory}/planet/replication" do
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ end
+
+ template "#{directory}/planet/replication/configuration.txt" do
source "configuration.txt.erb"
owner "taginfo"
group "taginfo"
mode 0644
end
- file "#{directory}/planet/download.lock" do
+ file "#{directory}/planet/replication/download.lock" do
owner "taginfo"
group "taginfo"
mode 0644
variables :directory => directory
end
- directory "#{directory}/data" do
+ template "#{directory}/bin/update-taginfo" do
+ source "update-taginfo.erb"
+ owner "taginfo"
+ group "taginfo"
+ mode 0755
+ variables :directory => directory
+ end
+
+ template "#{directory}/bin/update" do
+ source "update.erb"
owner "taginfo"
group "taginfo"
mode 0755
+ variables :directory => directory
end
apache_site name do
#!/bin/sh
+# DO NOT EDIT - This file is being maintained by Chef
+
+# abort on error
+
set -e
-cd "<%= @directory %>/planet"
+# setup
+
+PLANETDIR="<%= @directory %>/planet"
+LOGDIR="${PLANETDIR}/log"
+PLANETOLD="${PLANETDIR}/planet.pbf"
+PLANETNEW="${PLANETDIR}/planet-new.pbf"
+STATEDIR="${PLANETDIR}/replication"
+OSCFILE="${PLANETDIR}/$(date +%Y%m%d-%H%M).osc"
+
+# start logging
-OSCFILE="$(date +%Y%m%d-%H%M).osc"
+exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
# if there are old .osc files, they have to be taken into account
-OLDFILE=2*-*.osc
+OLDFILE="$(find "${PLANETDIR}" -name "2*-*.osc" -print)"
if [ -z "$OLDFILE" ]
then
- osmosis --rri --simc --write-xml-change "$OSCFILE"
+ osmosis --rri "$STATEDIR" --simc --write-xml-change "$OSCFILE"
else
- osmosis --rxc "$OLDFILE" --rri --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
+ osmosis --rxc "$OLDFILE" --rri "$STATEDIR" --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
fi
# osc file is ready, create new planet file
-osmosis --read-xml-change "$OSCFILE" --read-bin planet.pbf --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf planet-new.pbf
+osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETOLD" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf omitmetadata=true file="$PLANETNEW"
# cleanup
-mv planet-new.pbf planet.pbf
+mv "$PLANETNEW" "$PLANETOLD"
rm "$OSCFILE"
--- /dev/null
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+set -e
+
+ROOT="<%= @directory %>"
+
+cp $ROOT/data/taginfo-history.db $ROOT/sources
+$ROOT/taginfo/sources/update_all.sh $ROOT/sources
+mv $ROOT/data/taginfo-* $ROOT/data/old
+mv $ROOT/sources/taginfo-*.db $ROOT/sources/*/taginfo-*.db $ROOT/data
+mv $ROOT/sources/download/* $ROOT/download
+
+touch $ROOT/taginfo/web/tmp/restart.txt