2 # DO NOT EDIT - This file is being maintained by Chef
7 # Get the name of the file and the expected pattern
9 pattern="^osm-([0-9]{4}-[0-9]{2}-[0-9]{2})\.dmp$"
11 # Give up now if the file isn't a database dump
12 [[ $file =~ $pattern ]] || exit 0
14 # Save the date from the file name
15 date="${BASH_REMATCH[1]}"
18 if [ -f /tmp/planetdump.lock ]; then
19 if [ "$(ps -p `cat /tmp/planetdump.lock` | wc -l)" -gt 1 ]; then
20 echo "Error: Another planetdump is running"
23 rm /tmp/planetdump.lock
28 echo $$ > /tmp/planetdump.lock
32 rm /tmp/planetdump.lock
38 # Change to working directory
43 rm -rf changesets changeset_tags
44 rm -rf nodes node_tags
45 rm -rf ways way_tags way_nodes
46 rm -rf relations relation_tags relation_members
49 time nice -n 19 /store/planet-dump-ng/planet-dump-ng \
50 -c "pbzip2 -c" -f "${file}" --dense-nodes=1 \
51 -C "changesets-${date}.osm.bz2" \
52 -x "planet-${date}.osm.bz2" -X "history-${date}.osm.bz2" \
53 -p "planet-${date}.osm.pbf" -P "history-${date}.osm.pbf"
55 # Move XML dumps into place
56 year = `echo ${date} | sed "s/.*-\([0-9]\)\{4\}-.*/\1/"`
58 "changesets-${date}.osm.bz2" => "#{node[:planet][:dump][:xml_directory]}/${year}",
59 "planet-${date}.osm.bz2" => "#{node[:planet][:dump][:xml_directory]}/${year}",
60 "history-${date}.osm.bz2" => "#{node[:planet][:dump][:xml_history_directory]}/${year}",
61 "planet-${date}.osm.pbf" => node[:planet][:dump][:pbf_directory],
62 "history-${date}.osm.pbf" => node[:planet][:dump][:pbf_history_directory]
63 }.each do |file,dir| %>
64 md5sum "<%= file %>" > "<%= file %>.md5"
65 mv "<%= file %>" "<%= file %>.md5" "<%= dir %>"