3 # DO NOT EDIT - This file is being maintained by Chef
7 if [ "$user" != "www-data" ];
9 echo 'Error: run as www-data'
13 if [ -f /tmp/planet2pbf.lock ]; then
14 if [ "$(ps -p `cat /tmp/planet2pbf.lock` | wc -l)" -gt 1 ]; then
15 echo planet2pbf process is still running
18 # process not running, but lock file not deleted?
19 rm /tmp/planet2pbf.lock
22 echo $$ >/tmp/planet2pbf.lock
24 YEARFULL=`TZ=GMT+24 date +%Y`
26 cd /store/planet/planet/
29 YEAR=`TZ=GMT+24 date +%y`
30 MONTH=`TZ=GMT+24 date +%m`
31 DAY=`TZ=GMT+24 date +%d`
32 if [ -f ${YEARFULL}/planet-${YEAR}${MONTH}${DAY}.osm.bz2 -o -f ${YEARFULL}/.planet-${YEAR}${MONTH}${DAY}.osm.bz2.new ];
34 planet=planet-${YEAR}${MONTH}${DAY}.osm
36 echo Error /store/planet/planet/${YEARFULL}/planet-${YEAR}${MONTH}${DAY}.osm.bz2 not available
42 while [ -f ${YEARFULL}/.${planet}.bz2.new ];
44 echo sleeping - ${planet}.bz2
47 if [ -f /store/planet/planet/${YEARFULL}/${planet}.bz2 ]
50 if [ -f /store/planet/pbf/${planet}.pbf ];
52 echo Error: file /store/planet/pbf/${planet}.pbf exists
55 JAVACMD_OPTIONS=-Xmx2048M
56 export JAVACMD_OPTIONS
57 pbzip2 -dc /store/planet/planet/${YEARFULL}/${planet}.bz2 | osmosis --read-xml - --buffer bufferCapacity=18000 --write-pbf /store/planet/pbf/${planet}.pbf
59 md5sum ${planet}.pbf >${planet}.pbf.md5
60 ln -fs ${planet}.pbf planet-latest.osm.pbf
61 ln -fs ${planet}.pbf.md5 planet-latest.osm.pbf.md5
63 echo Error no file - ${planet}.bz2
66 rm /tmp/planet2pbf.lock