Commit | Line | Data |
---|---|---|
5203e8e5 UO |
1 | #!/bin/bash |
2 | ||
3 | LOCKFILE=/home.local/osm/run/.osmupdate.lock | |
4 | CHANGESFILE=/home.local/osm/run/osmosis-changes.osc.gz | |
5 | EXPIRYFILE=/home.local/osm/run/expiredtiles.lst | |
002b918b | 6 | RERENDEREXPIREDTRIGGERFILE=/home.local/osm/run/rerenderexpiredtiles.setting |
5203e8e5 UO |
7 | OSMOSISWORKDIR=/home.local/osm/.osmosis |
8 | WEBSTATEFILE=/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! | |
12 | UPDATECMD="/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 | |
19 | cleanup() | |
20 | { | |
21 | rm -f "$LOCKFILE" | |
22 | exit 1 | |
23 | } | |
24 | ||
25 | trytofeedupdate() | |
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 | ||
38 | echo "Starting update script: `date`" | |
39 | if [ -e "$LOCKFILE" ] ; then | |
40 | echo "Lockfile exists - ABORTING" | |
41 | exit 1 | |
42 | fi | |
43 | touch "$LOCKFILE" || exit 9 | |
44 | trap 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 | |
46 | if [ -e $CHANGESFILE ] ; then | |
47 | echo "Changesfile exists - will try to feed update to Database" | |
48 | trytofeedupdate | |
49 | fi | |
50 | if [ -e $CHANGESFILE ] ; then | |
51 | echo "Changesfile STILL exists - ABORTING" | |
52 | cleanup | |
53 | exit 1 | |
54 | fi | |
55 | echo "Downloading changes with OSMOSIS..." | |
56 | echo "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 | |
58 | if [ $? != 0 ] ; then | |
59 | echo "Osmosis execution failed. ABORTING" | |
60 | cleanup | |
61 | exit 1 | |
62 | fi | |
63 | trytofeedupdate | |
64 | if [ -e $CHANGESFILE ] ; then | |
65 | echo "Changesfile STILL exists - update must have failed. ABORTING" | |
66 | cleanup | |
67 | exit 1 | |
68 | fi | |
69 | echo "Update seems to have been successful." | |
70 | grep timestamp $OSMOSISWORKDIR/state.txt | sed -e 's/timestamp=//g' -e 's/T/ /g' -e 's/\\:/:/g' > $WEBSTATEFILE | |
11f3d002 | 71 | echo -n "Updated database: now at upstream state of " |
72 | cat $WEBSTATEFILE | |
1ef97ffe | 73 | #touch /var/lib/tirex/tiles/planet-import-complete |
c5981eb1 UO |
74 | if [ -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 |
92 | fi | |
93 | echo "Ending update script cleanly: `date`" | |
94 | cleanup | |
95 | exit 0 | |
96 |