]> git.openstreetmap.org Git - chef.git/blob - cookbooks/taginfo/templates/default/update-planet.erb
371369b07cc4a2cb50c159e0a8e51088364b9d6e
[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 PLANETPREV="${PLANETDIR}/planet-previous.pbf"
14 PLANETCURR="${PLANETDIR}/planet.pbf"
15 PLANETNEW="${PLANETDIR}/planet-new.pbf"
16 STATEDIR="${PLANETDIR}/replication"
17 OSCFILE="${PLANETDIR}/$(date +%Y%m%d-%H%M).osc"
18 OSCFILEPREV="${PLANETDIR}/previous.osc"
19
20 # start logging
21
22 exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
23
24 # if there are old .osc files, they have to be taken into account
25
26 OLDFILE="$(find "${PLANETDIR}" -name "2*-*.osc" -print)"
27 if [ -z "$OLDFILE" ]
28 then
29    osmosis --rri "$STATEDIR" --simc --write-xml-change "$OSCFILE"
30 else
31    osmosis --rxc "$OLDFILE" --rri "$STATEDIR" --mc --simc --write-xml-change "$OSCFILE" && rm "$OLDFILE"
32 fi
33
34 # osc file is ready, create new planet file
35
36 osmosis --read-xml-change "$OSCFILE" --read-bin "$PLANETCURR" --buffer bufferCapacity=12000 --apply-change --buffer bufferCapacity=12000 --write-pbf file="$PLANETNEW"
37
38 # cleanup
39
40 mv "$PLANETCURR" "$PLANETPREV"
41 mv "$PLANETNEW" "$PLANETCURR"
42 mv "$OSCFILE" "$OSCFILEPREV"
43
44 # expire old logs
45
46 find "${LOGDIR}" -mtime +28 -delete