From: Tom Hughes Date: Sat, 15 Feb 2014 15:30:33 +0000 (+0000) Subject: Initial work on maintaining an up to date planet for taginfo X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/e61e6ff7581eaf1cb17a46c0e0ba2bacd23e1fb2?ds=sidebyside Initial work on maintaining an up to date planet for taginfo --- diff --git a/cookbooks/taginfo/recipes/default.rb b/cookbooks/taginfo/recipes/default.rb index 227da7d7e..ac94c7107 100644 --- a/cookbooks/taginfo/recipes/default.rb +++ b/cookbooks/taginfo/recipes/default.rb @@ -101,6 +101,47 @@ node[:taginfo][:sites].each do |site| notifies :restart, "service[apache2]" end + directory "#{directory}/planet" do + owner "taginfo" + group "taginfo" + mode 0755 + end + + remote_file "#{directory}/planet/planet.pbf" do + action :create_if_missing + source "http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf" + owner "taginfo" + group "taginfo" + mode 0644 + end + + template "#{directory}/planet/configuration.txt" do + source "configuration.txt.erb" + owner "taginfo" + group "taginfo" + mode 0644 + end + + file "#{directory}/planet/download.lock" do + owner "taginfo" + group "taginfo" + mode 0644 + end + + directory "#{directory}/bin" do + owner "taginfo" + group "taginfo" + mode 0755 + end + + template "#{directory}/bin/update-planet" do + source "update-planet.erb" + owner "taginfo" + group "taginfo" + mode 0755 + variables :directory => directory + end + directory "#{directory}/data" do owner "taginfo" group "taginfo" diff --git a/cookbooks/taginfo/templates/default/configuration.txt.erb b/cookbooks/taginfo/templates/default/configuration.txt.erb new file mode 100644 index 000000000..6f5bf935f --- /dev/null +++ b/cookbooks/taginfo/templates/default/configuration.txt.erb @@ -0,0 +1,2 @@ +baseUrl=http://planet.openstreetmap.org/replication/hour +maxInterval=0 diff --git a/cookbooks/taginfo/templates/default/update-planet.erb b/cookbooks/taginfo/templates/default/update-planet.erb new file mode 100644 index 000000000..8fd69ff9e --- /dev/null +++ b/cookbooks/taginfo/templates/default/update-planet.erb @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +cd "<%= @directory %>/planet" + +OSCFILE="$(date +%Y%m%d-%H%M).osc" + +# if there are old .osc files, they have to be taken into account + +OLDFILE=2*-*.osc +if [ -z "$OLDFILE" ] +then + osmosis --rri --simc --write-xml-change "$OSCFILE" +else + osmosis --rxc "$OLDFILE" --rri --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 + +# cleanup + +mv planet-new.pbf planet.pbf +rm "$OSCFILE"