Make taginfo handle planet updates that need multiple passes correctly
authorTom Hughes <tom@compton.nu>
Fri, 14 Sep 2018 23:50:49 +0000 (00:50 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 14 Sep 2018 23:50:49 +0000 (00:50 +0100)
cookbooks/taginfo/templates/default/update-planet.erb

index 1d8ba1b126e843fdc5ab20b76c04a2f6b74c4252..50e058632a8d9167ea832cd481d4c37bcf0c5c5c 100644 (file)
@@ -9,15 +9,20 @@ LOGDIR="${PLANETDIR}/log"
 PLANETPREV="${PLANETDIR}/planet-previous.pbf"
 PLANETCURR="${PLANETDIR}/planet.pbf"
 PLANETNEW="${PLANETDIR}/planet-new.pbf"
+PLANETTMP="${PLANETDIR}/planet-tmp.pbf"
 
 # start logging
 
 exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
 
-retval=1
+pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
+retval=$?
+
 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