copy+paste error
[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
6OSMOSISWORKDIR=/home.local/osm/.osmosis
7WEBSTATEFILE=/var/www/lastdbupdate.txt
8# Note: set the expire-tiles to 3 less than the real maximum,
9# as this makes the tilelist MUCH shorter, and the tiles get rerendered
10# anyways due to the metatile-layout!
11UPDATECMD="/usr/bin/osm2pgsql --slim --cache=8000 --append --database=osm \
12 --style=/home.local/osm/dbstyle/osm2pgsql-new.style \
13 --hstore --expire-tiles=17-17 \
14 --expire-output=$EXPIRYFILE $CHANGESFILE"
15
16cleanup()
17{
18 rm -f "$LOCKFILE"
19 exit 1
20}
21
22trytofeedupdate()
23{
24 echo "Trying to feed updates into databse..."
25 echo "Executing: $UPDATECMD"
26 $UPDATECMD
27 if [ $? == 0 ] ; then
28 echo "Update went fine, removing changes-file"
29 rm -f $CHANGESFILE
30 else
31 echo "Update failed with error $?"
32 fi
33}
34
35echo "Starting update script: `date`"
36if [ -e "$LOCKFILE" ] ; then
37 echo "Lockfile exists - ABORTING"
38 exit 1
39fi
40touch "$LOCKFILE" || exit 9
41trap cleanup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \
42 20 21 22 23 24 25 26 27 28 29 30 31
43if [ -e $CHANGESFILE ] ; then
44 echo "Changesfile exists - will try to feed update to Database"
45 trytofeedupdate
46fi
47if [ -e $CHANGESFILE ] ; then
48 echo "Changesfile STILL exists - ABORTING"
49 cleanup
50 exit 1
51fi
52echo "Downloading changes with OSMOSIS..."
53echo "Executing: /usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE"
54/usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE
55if [ $? != 0 ] ; then
56 echo "Osmosis execution failed. ABORTING"
57 cleanup
58 exit 1
59fi
60trytofeedupdate
61if [ -e $CHANGESFILE ] ; then
62 echo "Changesfile STILL exists - update must have failed. ABORTING"
63 cleanup
64 exit 1
65fi
66echo "Update seems to have been successful."
67grep timestamp $OSMOSISWORKDIR/state.txt | sed -e 's/timestamp=//g' -e 's/T/ /g' -e 's/\\:/:/g' > $WEBSTATEFILE
11f3d002 68echo -n "Updated database: now at upstream state of "
69cat $WEBSTATEFILE
70touch /var/lib/tirex/tiles/planet-import-complete
5203e8e5
UO
71if [ -e $EXPIRYFILE ] ; then
72 echo "Expiryfile exists. Telling tirex to rerender the tiles mentioned there..."
73 echo "Number of lines: `wc -l $EXPIRYFILE`"
74 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
75 --action rerenderexpiredlist --zoom 13-20 \
76 --rrs /home.local/osm/bin/osmrerenderwrapper.sh \
77 /var/lib/tirex/tiles/osm
78 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
79 --action rerenderexpiredlist --zoom 13-20 \
11f3d002 80 --rrs /home.local/osm/bin/osmrerenderwrapper-osmde.sh \
5203e8e5
UO
81 /var/lib/tirex/tiles/osmde
82 rm $EXPIRYFILE
83fi
84echo "Ending update script cleanly: `date`"
85cleanup
86exit 0
87
This page took 0.083716 seconds and 4 git commands to generate.