make it possible to enable or disable rerenderings by a file.
[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 \
1ef97ffe 15 --hstore --multi-geometry --expire-tiles=17-17 \
5203e8e5
UO
16 --expire-output=$EXPIRYFILE $CHANGESFILE"
17
18cleanup()
19{
20 rm -f "$LOCKFILE"
21 exit 1
22}
23
24trytofeedupdate()
25{
26 echo "Trying to feed updates into databse..."
27 echo "Executing: $UPDATECMD"
28 $UPDATECMD
29 if [ $? == 0 ] ; then
30 echo "Update went fine, removing changes-file"
31 rm -f $CHANGESFILE
32 else
33 echo "Update failed with error $?"
34 fi
35}
36
37echo "Starting update script: `date`"
38if [ -e "$LOCKFILE" ] ; then
39 echo "Lockfile exists - ABORTING"
40 exit 1
41fi
42touch "$LOCKFILE" || exit 9
43trap cleanup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \
44 20 21 22 23 24 25 26 27 28 29 30 31
45if [ -e $CHANGESFILE ] ; then
46 echo "Changesfile exists - will try to feed update to Database"
47 trytofeedupdate
48fi
49if [ -e $CHANGESFILE ] ; then
50 echo "Changesfile STILL exists - ABORTING"
51 cleanup
52 exit 1
53fi
54echo "Downloading changes with OSMOSIS..."
55echo "Executing: /usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE"
56/usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE
57if [ $? != 0 ] ; then
58 echo "Osmosis execution failed. ABORTING"
59 cleanup
60 exit 1
61fi
62trytofeedupdate
63if [ -e $CHANGESFILE ] ; then
64 echo "Changesfile STILL exists - update must have failed. ABORTING"
65 cleanup
66 exit 1
67fi
68echo "Update seems to have been successful."
69grep timestamp $OSMOSISWORKDIR/state.txt | sed -e 's/timestamp=//g' -e 's/T/ /g' -e 's/\\:/:/g' > $WEBSTATEFILE
11f3d002 70echo -n "Updated database: now at upstream state of "
71cat $WEBSTATEFILE
1ef97ffe 72#touch /var/lib/tirex/tiles/planet-import-complete
002b918b 73if [ -e $EXPIRYFILE -a -e $RERENDEREXPIREDTRIGGERFILE ] ; then
5203e8e5
UO
74 echo "Expiryfile exists. Telling tirex to rerender the tiles mentioned there..."
75 echo "Number of lines: `wc -l $EXPIRYFILE`"
1ef97ffe 76 # Used to be zoom 13-20 but that causes too much load. Reduced to 15-20.
002b918b 77 # Trying completely without. Lots of load, way too many false positives. -unrz191 2015-09-04
5203e8e5 78 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
1ef97ffe 79 --action rerenderexpiredlist --zoom 15-20 \
5203e8e5
UO
80 --rrs /home.local/osm/bin/osmrerenderwrapper.sh \
81 /var/lib/tirex/tiles/osm
82 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
1ef97ffe 83 --action rerenderexpiredlist --zoom 15-20 \
11f3d002 84 --rrs /home.local/osm/bin/osmrerenderwrapper-osmde.sh \
5203e8e5
UO
85 /var/lib/tirex/tiles/osmde
86 rm $EXPIRYFILE
87fi
88echo "Ending update script cleanly: `date`"
89cleanup
90exit 0
91
This page took 0.099314 seconds and 4 git commands to generate.