remove expiryfile when rendering is disabled, else it grows indefinitely and causes...
[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
76 echo "Expiryfile and triggerfile exists. Telling tirex to rerender the tiles mentioned there..."
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.
79 # Trying completely without. Lots of load, way too many false positives. -unrz191 2015-09-04
80 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
1ef97ffe 81 --action rerenderexpiredlist --zoom 15-20 \
5203e8e5
UO
82 --rrs /home.local/osm/bin/osmrerenderwrapper.sh \
83 /var/lib/tirex/tiles/osm
c5981eb1 84 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
1ef97ffe 85 --action rerenderexpiredlist --zoom 15-20 \
11f3d002 86 --rrs /home.local/osm/bin/osmrerenderwrapper-osmde.sh \
5203e8e5 87 /var/lib/tirex/tiles/osmde
c5981eb1
UO
88 else
89 echo "Expiryfile exists but rerendering is disabled."
90 fi
5203e8e5
UO
91 rm $EXPIRYFILE
92fi
93echo "Ending update script cleanly: `date`"
94cleanup
95exit 0
96
This page took 0.057144 seconds and 4 git commands to generate.