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