Handle planet updates that need multiple passes correctly
authorTom Hughes <tom@compton.nu>
Fri, 14 Sep 2018 18:08:49 +0000 (19:08 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 14 Sep 2018 18:08:49 +0000 (19:08 +0100)
cookbooks/cplanet/templates/default/update-planet.erb

index e992c35788ca176f9bd2fc2bf1dd38c795784a8f..6c77eafa60e8a50436cce73a513316a6ed98b6fa 100644 (file)
@@ -8,11 +8,16 @@ PLANETDIR="<%= @basedir %>/planet"
 PLANETPREV="${PLANETDIR}/planet-previous.pbf"
 PLANETCURR="${PLANETDIR}/planet.pbf"
 PLANETNEW="${PLANETDIR}/planet-new.pbf"
+PLANETTMP="${PLANETDIR}/planet-tmp.pbf"
+
+pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
+retval=$?
 
-retval=1
 while [ $retval -eq 1 ]; do
-    pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
+    mv "$PLANETNEW" "$PLANETTMP"
+    pyosmium-up-to-date -v -o $PLANETNEW $PLANETTMP
     retval=$?
+    rm "$PLANETTMP"
 done
 
 if [ $retval -ne 0 ]; then