]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/planet/templates/default/planet-update.erb
planet: do not keep previous planet around.
[chef.git] / cookbooks / planet / templates / default / planet-update.erb
index 4c00592b9b0c74684b09f48bde497e2f0cadbbc2..fbfc6592fce5979226f4ebbde4140d4453916b6b 100644 (file)
@@ -2,18 +2,34 @@
 
 # DO NOT EDIT - This file is being maintained by Chef
 
-exec >> /var/log/planet-update.log 2>&1
+# setup
 
-echo "Updating planet file..."
+SUFFIX="osh.pbf"
 
-/sbin/runuser -u planet -- /usr/local/bin/planet-update-file
+PLANETDIR="/var/lib/planet"
+PLANETPREV="${PLANETDIR}/planet-previous.${SUFFIX}"
+PLANETCURR="${PLANETDIR}/planet.${SUFFIX}"
+PLANETNEW="${PLANETDIR}/planet-new.${SUFFIX}"
 
-echo "Running jobs..."
-<% node[:planet][:current][:jobs].each_value do |job| -%>
+rm -f "$PLANETPREV"
 
-echo "Running '<%= job[:command] %>' as user '<%= job[:user] %>'..."
+pyosmium-up-to-date -vvv -o "$PLANETNEW" "$PLANETCURR"
+retval=$?
 
-/sbin/runuser -u "<%= job[:user] %>" -- "<%= job[:command] %>"
-<% end -%>
+while [ $retval -eq 1 ]; do
+    mv "$PLANETCURR" "$PLANETPREV"
+    rm -f "$PLANETPREV"
+    mv "$PLANETNEW" "$PLANETCURR"
+    pyosmium-up-to-date -vvv -o "$PLANETNEW" "$PLANETCURR"
+    retval=$?
+done
 
-echo "Done."
+if [ $retval -ne 0 ]; then
+    exit $retval
+fi
+
+# cleanup
+
+mv "$PLANETCURR" "$PLANETPREV"
+rm -f "$PLANETPREV"
+mv "$PLANETNEW" "$PLANETCURR"