]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/taginfo/templates/default/update-planet.erb
taginfo: use pyosmium for planet updates
[chef.git] / cookbooks / taginfo / templates / default / update-planet.erb
index 8fd69ff9e9d9ace6b9e5914b2e0c04e2820998d1..db3d54c75470cbeb9aad500e38f9a25b8075833e 100644 (file)
@@ -1,26 +1,34 @@
 #!/bin/sh
 
-set -e
+# DO NOT EDIT - This file is being maintained by Chef
 
-cd "<%= @directory %>/planet"
+# setup
 
-OSCFILE="$(date +%Y%m%d-%H%M).osc"
+PLANETDIR="<%= @directory %>/planet"
+LOGDIR="${PLANETDIR}/log"
+PLANETPREV="${PLANETDIR}/planet-previous.pbf"
+PLANETCURR="${PLANETDIR}/planet.pbf"
+PLANETNEW="${PLANETDIR}/planet-new.pbf"
 
-# if there are old .osc files, they have to be taken into account
+# start logging
 
-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
+exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
 
-# osc file is ready, create new planet file
+retval=1
+while [ $retval -eq 1 ]; do
+    pyosmium-up-to-date -o $PLANETNEW $PLANETCURR
+    retval=$?
+done
 
-osmosis --read-xml-change "$OSCFILE" --read-bin planet.pbf --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf planet-new.pbf
+if [ $retval -ne 0 ]; then
+  exit $retval
+fi
 
 # cleanup
 
-mv planet-new.pbf planet.pbf
-rm "$OSCFILE"
+mv "$PLANETCURR" "$PLANETPREV"
+mv "$PLANETNEW" "$PLANETCURR"
+
+# expire old logs
+
+find "${LOGDIR}" -mtime +28 -delete