On taginfo server: Keep last planet and change file around after update.
authorJochen Topf <jochen@topf.org>
Wed, 18 Nov 2015 21:54:13 +0000 (22:54 +0100)
committerJochen Topf <jochen@topf.org>
Wed, 18 Nov 2015 21:54:13 +0000 (22:54 +0100)
cookbooks/taginfo/templates/default/update-planet.erb

index 76b7af2..371369b 100644 (file)
@@ -10,10 +10,12 @@ set -e
 
 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"
+OSCFILEPREV="${PLANETDIR}/previous.osc"
 
 # start logging
 
@@ -31,12 +33,13 @@ fi
 
 # osc file is ready, create new planet file
 
-osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETOLD" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW"
+osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETCURR" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW"
 
 # cleanup
 
-mv "$PLANETNEW" "$PLANETOLD"
-rm "$OSCFILE"
+mv "$PLANETCURR" "$PLANETPREV"
+mv "$PLANETNEW" "$PLANETCURR"
+mv "$OSCFILE" "$OSCFILEPREV"
 
 # expire old logs