X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/c38fe4f2235708a86e6f1b547f6bb3432130f3a7..7b9bf6ef0f3f579947bb613da9ae648327fd7923:/cookbooks/taginfo/templates/default/update-planet.erb diff --git a/cookbooks/taginfo/templates/default/update-planet.erb b/cookbooks/taginfo/templates/default/update-planet.erb index a728ac1bf..50e058632 100644 --- a/cookbooks/taginfo/templates/default/update-planet.erb +++ b/cookbooks/taginfo/templates/default/update-planet.erb @@ -2,38 +2,38 @@ # DO NOT EDIT - This file is being maintained by Chef -# abort on error - -set -e - # setup PLANETDIR="<%= @directory %>/planet" LOGDIR="${PLANETDIR}/log" -PLANETOLD="${PLANETDIR}/planet.pbf" +PLANETPREV="${PLANETDIR}/planet-previous.pbf" +PLANETCURR="${PLANETDIR}/planet.pbf" PLANETNEW="${PLANETDIR}/planet-new.pbf" -STATEDIR="${PLANETDIR}/replication" -OSCFILE="${PLANETDIR}/$(date +%Y%m%d-%H%M).osc" +PLANETTMP="${PLANETDIR}/planet-tmp.pbf" # start logging exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1 -# if there are old .osc files, they have to be taken into account +pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR +retval=$? + +while [ $retval -eq 1 ]; do + mv "$PLANETNEW" "$PLANETTMP" + pyosmium-up-to-date -v -o $PLANETNEW $PLANETTMP + retval=$? + rm "$PLANETTMP" +done -OLDFILE="$(find "${PLANETDIR}" -name "2*-*.osc" -print)" -if [ -z "$OLDFILE" ] -then - osmosis --rri "$STATEDIR" --simc --write-xml-change "$OSCFILE" -else - osmosis --rxc "$OLDFILE" --rri "$STATEDIR" --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE" +if [ $retval -ne 0 ]; then + exit $retval fi -# osc file is ready, create new planet file +# cleanup -osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETOLD" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW" +mv "$PLANETCURR" "$PLANETPREV" +mv "$PLANETNEW" "$PLANETCURR" -# cleanup +# expire old logs -mv "$PLANETNEW" "$PLANETOLD" -rm "$OSCFILE" +find "${LOGDIR}" -mtime +28 -delete