]> git.openstreetmap.org Git - chef.git/blob - cookbooks/overpass/templates/default/overpass-update-db.erb
Tweak some tile sandboxes
[chef.git] / cookbooks / overpass / templates / default / overpass-update-db.erb
1 #!/bin/bash
2
3 PYOSMIUM="pyosmium-get-changes --server <%= node[:overpass][:replication_url] %> -f <%= @basedir %>/db/replicate-id"
4 <% if node[:overpass][:meta_mode] == "attic" -%>
5 PYOSMIUM="$PYOSMIUM --no-deduplicate"
6 <% end -%>
7
8 <% if node[:overpass][:meta_mode] == "meta" -%>
9 META=--meta
10 <% elsif node[:overpass][:meta_mode] == "attic" -%>
11 META=--keep-attic
12 <% else -%>
13 META=
14 <% end -%>
15
16 status=3 # make it sleep on issues
17
18 if [ -f <%= @basedir %>/db/replicate-id ]; then
19   # first apply any pending updates
20   if [ -f <%= @basedir %>/diffs/latest.osc ]; then
21     DATA_VERSION=`osmium fileinfo -e -g data.timestamp.last <%= @basedir %>/diffs/latest.osc`
22     if [ "x$DATA_VERSION" != "x" ]; then
23       echo "Downloaded up to timestamp $DATA_VERSION"
24       while ! <%= @basedir %>/bin/update_from_dir --osc-dir=<%= @basedir %>/diffs --version=$DATA_VERSION $META --flush-size=0; do
25         echo "Error while updating. Retry in 1 min."
26         sleep 60
27       done
28     fi
29     rm <%= @basedir %>/diffs/latest.osc
30   fi
31
32   $PYOSMIUM -v -s 1000 -o <%= @basedir %>/diffs/latest.osc
33   status=$?
34 fi
35
36 if [ $status -eq 0 ]; then
37   echo "Downloaded next batch."
38 elif [ $status -eq 3 ]; then
39   rm <%= @basedir %>/diffs/latest.osc
40   echo "No new data, sleeping for a minute."
41   sleep 60
42 else
43   echo "Fatal error, stopping updates."
44   exit $status
45 fi