]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/taginfo/templates/default/update-planet.erb
Switch taginfo to expire logs manually and drop logrotate
[chef.git] / cookbooks / taginfo / templates / default / update-planet.erb
index 8fd69ff9e9d9ace6b9e5914b2e0c04e2820998d1..311c7703e6230cb1b47c15716d66e066ecc6d74c 100644 (file)
@@ -1,26 +1,43 @@
 #!/bin/sh
 
 #!/bin/sh
 
+# DO NOT EDIT - This file is being maintained by Chef
+
+# abort on error
+
 set -e
 
 set -e
 
-cd "<%= @directory %>/planet"
+# setup
+
+PLANETDIR="<%= @directory %>/planet"
+LOGDIR="${PLANETDIR}/log"
+PLANETOLD="${PLANETDIR}/planet.pbf"
+PLANETNEW="${PLANETDIR}/planet-new.pbf"
+STATEDIR="${PLANETDIR}/replication"
+OSCFILE="${PLANETDIR}/$(date +%Y%m%d-%H%M).osc"
 
 
-OSCFILE="$(date +%Y%m%d-%H%M).osc"
+# 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
 
 
 # if there are old .osc files, they have to be taken into account
 
-OLDFILE=2*-*.osc
+OLDFILE="$(find "${PLANETDIR}" -name "2*-*.osc" -print)"
 if [ -z "$OLDFILE" ]
 then
 if [ -z "$OLDFILE" ]
 then
-   osmosis --rri --simc --write-xml-change "$OSCFILE"
+   osmosis --rri "$STATEDIR" --simc --write-xml-change "$OSCFILE"
 else
 else
-   osmosis --rxc "$OLDFILE" --rri --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
+   osmosis --rxc "$OLDFILE" --rri "$STATEDIR" --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
 fi
 
 # osc file is ready, create new planet file
 
 fi
 
 # osc file is ready, create new planet file
 
-osmosis --read-xml-change "$OSCFILE" --read-bin planet.pbf --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf planet-new.pbf
+osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETOLD" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW"
 
 # cleanup
 
 
 # cleanup
 
-mv planet-new.pbf planet.pbf
+mv "$PLANETNEW" "$PLANETOLD"
 rm "$OSCFILE"
 rm "$OSCFILE"
+
+# expire old logs
+
+find "${LOGDIR}" -mtime +28 -delte