]> git.openstreetmap.org Git - chef.git/blob - cookbooks/taginfo/templates/default/update-planet.erb
Disable CacheStaleOnError for taginfo
[chef.git] / cookbooks / taginfo / templates / default / update-planet.erb
1 #!/bin/sh
2
3 # DO NOT EDIT - This file is being maintained by Chef
4
5 # abort on error
6
7 set -e
8
9 # setup
10
11 PLANETDIR="<%= @directory %>/planet"
12 LOGDIR="${PLANETDIR}/log"
13 PLANETOLD="${PLANETDIR}/planet.pbf"
14 PLANETNEW="${PLANETDIR}/planet-new.pbf"
15 STATEDIR="${PLANETDIR}/replication"
16 OSCFILE="${PLANETDIR}/$(date +%Y%m%d-%H%M).osc"
17
18 # start logging
19
20 exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
21
22 # if there are old .osc files, they have to be taken into account
23
24 OLDFILE="$(find "${PLANETDIR}" -name "2*-*.osc" -print)"
25 if [ -z "$OLDFILE" ]
26 then
27    osmosis --rri "$STATEDIR" --simc --write-xml-change "$OSCFILE"
28 else
29    osmosis --rxc "$OLDFILE" --rri "$STATEDIR" --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
30 fi
31
32 # osc file is ready, create new planet file
33
34 osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETOLD" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW"
35
36 # cleanup
37
38 mv "$PLANETNEW" "$PLANETOLD"
39 rm "$OSCFILE"
40
41 # expire old logs
42
43 find "${LOGDIR}" -mtime +28 -delete