2 ulimit -m 4194304 -v 4194304
5 if [ -f /tmp/planetdump.lock ]; then
6 if [ "$(ps -p `cat /tmp/planetdump.lock` | wc -l)" -gt 1 ]; then
7 # process is still running
8 echo Error: Another planetdump is running
11 # process not running, but lock file not deleted?
12 rm /tmp/planetdump.lock
17 echo $$ > /tmp/planetdump.lock
20 cur_date=`date +%y%m%d`
22 cur_planet=planet-${cur_date}.osm
23 cur_changeset=changesets-${cur_date}.osm
24 planet_dir=/store/planet/
26 export CONNECTION_PARAMS='dbname=openstreetmap host=db-slave user=planetdump password=<%= @password %>'
27 export PATH='/usr/local/bin:/usr/bin:/bin:/usr/bin/X11'
30 if [ \! -d ${planet_dir}/planet/ ]
32 echo ${planet_dir}planet/ does not exist
35 if [ \! -d ${planet_dir}/planet/${cur_year}/ ]; then mkdir ${planet_dir}/planet/${cur_year}/; fi
36 cd ${planet_dir}/planet/${cur_year}/
38 /opt/planetdump/planet06_pg | pbzip2 -p6 -6c > .${cur_planet}.bz2.new
39 /opt/planetdump/planet06_pg --changesets | pbzip2 -p6 -9c > .${cur_changeset}.bz2.new
41 planet_size=$(du -sb .${cur_planet}.bz2.new | awk '{ print $1 }')
42 changeset_size=$(du -sb .${cur_changeset}.bz2.new | awk '{ print $1 }')
43 if ((planet_size<32000000000)); then
44 echo Planet .${cur_planet}.bz2.new too small
47 if ((changeset_size<720000000)); then
48 echo Changeset .${cur_changeset}.bz2.new too small
52 mv .${cur_planet}.bz2.new ${cur_planet}.bz2
53 mv .${cur_changeset}.bz2.new ${cur_changeset}.bz2
54 md5sum ${cur_planet}.bz2 > ${cur_planet}.bz2.md5
55 md5sum ${cur_changeset}.bz2 > ${cur_changeset}.bz2.md5
57 #link planet latest to the new file
58 cd ${planet_dir}/planet/
60 ln -fs ${cur_year}/${cur_planet}.bz2 planet-latest.osm.bz2
61 ln -fs ${cur_year}/${cur_changeset}.bz2 changesets-latest.osm.bz2
63 # mangle md5 files for 'latest' ones
64 rm -f planet-latest.osm.bz2.md5
65 rm -f changesets-latest.osm.bz2.md5
67 sed -e "s/${cur_planet}.bz2/planet-latest.osm.bz2/" ${cur_year}/${cur_planet}.bz2.md5 > planet-latest.osm.bz2.md5
68 sed -e "s/${cur_changeset}.bz2/changesets-latest.osm.bz2/" ${cur_year}/${cur_changeset}.bz2.md5 > changesets-latest.osm.bz2.md5
70 rm /tmp/planetdump.lock