trigger rerendering of tiles in our main area (Erlangen/Nuernberg) after expiry so...
[osmrrze.git] / scripts / doosmupdate.sh
CommitLineData
5203e8e5
UO
1#!/bin/bash
2
3LOCKFILE=/home.local/osm/run/.osmupdate.lock
4CHANGESFILE=/home.local/osm/run/osmosis-changes.osc.gz
5EXPIRYFILE=/home.local/osm/run/expiredtiles.lst
002b918b 6RERENDEREXPIREDTRIGGERFILE=/home.local/osm/run/rerenderexpiredtiles.setting
5203e8e5
UO
7OSMOSISWORKDIR=/home.local/osm/.osmosis
8WEBSTATEFILE=/var/www/lastdbupdate.txt
9# Note: set the expire-tiles to 3 less than the real maximum,
10# as this makes the tilelist MUCH shorter, and the tiles get rerendered
11# anyways due to the metatile-layout!
12UPDATECMD="/usr/bin/osm2pgsql --slim --cache=8000 --append --database=osm \
13 --style=/home.local/osm/dbstyle/osm2pgsql-new.style \
1e28d5c9 14 --flat-nodes=/mnt/database/flatnodes/flatnodes.db \
c5981eb1
UO
15 --hstore --multi-geometry \
16 --expire-tiles=17-17 --expire-output=$EXPIRYFILE \
17 $CHANGESFILE"
5203e8e5
UO
18
19cleanup()
20{
21 rm -f "$LOCKFILE"
22 exit 1
23}
24
25trytofeedupdate()
26{
27 echo "Trying to feed updates into databse..."
28 echo "Executing: $UPDATECMD"
29 $UPDATECMD
30 if [ $? == 0 ] ; then
31 echo "Update went fine, removing changes-file"
32 rm -f $CHANGESFILE
33 else
34 echo "Update failed with error $?"
35 fi
36}
37
38echo "Starting update script: `date`"
39if [ -e "$LOCKFILE" ] ; then
40 echo "Lockfile exists - ABORTING"
41 exit 1
42fi
43touch "$LOCKFILE" || exit 9
44trap cleanup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \
45 20 21 22 23 24 25 26 27 28 29 30 31
46if [ -e $CHANGESFILE ] ; then
47 echo "Changesfile exists - will try to feed update to Database"
48 trytofeedupdate
49fi
50if [ -e $CHANGESFILE ] ; then
51 echo "Changesfile STILL exists - ABORTING"
52 cleanup
53 exit 1
54fi
55echo "Downloading changes with OSMOSIS..."
56echo "Executing: /usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE"
57/usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE
58if [ $? != 0 ] ; then
59 echo "Osmosis execution failed. ABORTING"
60 cleanup
61 exit 1
62fi
63trytofeedupdate
64if [ -e $CHANGESFILE ] ; then
65 echo "Changesfile STILL exists - update must have failed. ABORTING"
66 cleanup
67 exit 1
68fi
69echo "Update seems to have been successful."
70grep timestamp $OSMOSISWORKDIR/state.txt | sed -e 's/timestamp=//g' -e 's/T/ /g' -e 's/\\:/:/g' > $WEBSTATEFILE
11f3d002 71echo -n "Updated database: now at upstream state of "
72cat $WEBSTATEFILE
1ef97ffe 73#touch /var/lib/tirex/tiles/planet-import-complete
c5981eb1
UO
74if [ -e $EXPIRYFILE ] ; then
75 if [ -e $RERENDEREXPIREDTRIGGERFILE ] ; then
e6723fa6 76 echo "Expiryfile and triggerfile exists. Marking the tiles mentioned there as expired..."
c5981eb1
UO
77 echo "Number of lines: `wc -l $EXPIRYFILE`"
78 # Used to be zoom 13-20 but that causes too much load. Reduced to 15-20.
c1cfefc4
UO
79 cat $EXPIRYFILE | sudo -u tirex /home.local/osm/bin/osmtilecleanup.pl \
80 --action touchexpiredlist --zoom 15-20 \
5203e8e5 81 /var/lib/tirex/tiles/osm
c1cfefc4
UO
82 cat $EXPIRYFILE | sudo -u tirex /home.local/osm/bin/osmtilecleanup.pl \
83 --action touchexpiredlist --zoom 15-20 \
5203e8e5 84 /var/lib/tirex/tiles/osmde
c1cfefc4
UO
85 cat $EXPIRYFILE | sudo -u tirex /home.local/osm/bin/osmtilecleanup.pl \
86 --action touchexpiredlist --zoom 15-20 \
87 /var/lib/tirex/tiles/osmhd
e6723fa6
UO
88 # Now immediately rerender all the tiles there that are in our area.
89 # The rest gets done on demand by mod_tile.
90 echo "Triggering rerendering of expired tiles in our area..."
91 tirex-batch --prio=31 --expire=+3600 --filter='exists;older(1450000000)' map=osm bbox=10.93,49.37,11.14,49.63 z=15-20
92 tirex-batch --prio=31 --expire=+3600 --filter='exists;older(1450000000)' map=osmde bbox=10.93,49.37,11.14,49.63 z=15-20
93 tirex-batch --prio=31 --expire=+3600 --filter='exists;older(1450000000)' map=osmhd bbox=10.93,49.37,11.14,49.63 z=15-20
c5981eb1
UO
94 else
95 echo "Expiryfile exists but rerendering is disabled."
96 fi
5203e8e5
UO
97 rm $EXPIRYFILE
98fi
99echo "Ending update script cleanly: `date`"
100cleanup
101exit 0
102
This page took 0.700274 seconds and 4 git commands to generate.