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
6 OSMOSISWORKDIR=/home.local/osm/.osmosis
7 WEBSTATEFILE=/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!
11 UPDATECMD="/usr/bin/osm2pgsql --slim --cache=8000 --append --database=osm \
12 --style=/home.local/osm/dbstyle/osm2pgsql-new.style \
13 --flat-nodes=/mnt/database/flatnodes/flatnodes.db \
14 --hstore --expire-tiles=17-17 \
15 --expire-output=$EXPIRYFILE $CHANGESFILE"
25 echo "Trying to feed updates into databse..."
26 echo "Executing: $UPDATECMD"
29 echo "Update went fine, removing changes-file"
32 echo "Update failed with error $?"
36 echo "Starting update script: `date`"
37 if [ -e "$LOCKFILE" ] ; then
38 echo "Lockfile exists - ABORTING"
41 touch "$LOCKFILE" || exit 9
42 trap cleanup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \
43 20 21 22 23 24 25 26 27 28 29 30 31
44 if [ -e $CHANGESFILE ] ; then
45 echo "Changesfile exists - will try to feed update to Database"
48 if [ -e $CHANGESFILE ] ; then
49 echo "Changesfile STILL exists - ABORTING"
53 echo "Downloading changes with OSMOSIS..."
54 echo "Executing: /usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE"
55 /usr/bin/osmosis --read-replication-interval workingDirectory=$OSMOSISWORKDIR --simplify-change --write-xml-change $CHANGESFILE
57 echo "Osmosis execution failed. ABORTING"
62 if [ -e $CHANGESFILE ] ; then
63 echo "Changesfile STILL exists - update must have failed. ABORTING"
67 echo "Update seems to have been successful."
68 grep timestamp $OSMOSISWORKDIR/state.txt | sed -e 's/timestamp=//g' -e 's/T/ /g' -e 's/\\:/:/g' > $WEBSTATEFILE
69 echo -n "Updated database: now at upstream state of "
71 touch /var/lib/tirex/tiles/planet-import-complete
72 if [ -e $EXPIRYFILE ] ; then
73 echo "Expiryfile exists. Telling tirex to rerender the tiles mentioned there..."
74 echo "Number of lines: `wc -l $EXPIRYFILE`"
75 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
76 --action rerenderexpiredlist --zoom 13-20 \
77 --rrs /home.local/osm/bin/osmrerenderwrapper.sh \
78 /var/lib/tirex/tiles/osm
79 cat $EXPIRYFILE | /home.local/osm/bin/osmtilecleanup.pl \
80 --action rerenderexpiredlist --zoom 13-20 \
81 --rrs /home.local/osm/bin/osmrerenderwrapper-osmde.sh \
82 /var/lib/tirex/tiles/osmde
85 echo "Ending update script cleanly: `date`"