Extracted all references to planet dump output locations to attributes
authorMatt Amos <zerebubuth@gmail.com>
Sun, 21 Dec 2014 18:10:53 +0000 (18:10 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 22 Dec 2014 14:38:35 +0000 (14:38 +0000)
cookbooks/planet/attributes/default.rb [new file with mode: 0644]
cookbooks/planet/recipes/default.rb
cookbooks/planet/recipes/dump.rb
cookbooks/planet/templates/default/apache-latest-planet-filename.erb [moved from cookbooks/planet/files/default/bin/apache-latest-planet-filename with 64% similarity]
cookbooks/planet/templates/default/planet-mirror-redirect-update.erb [moved from cookbooks/planet/files/default/bin/planet-mirror-redirect-update with 96% similarity]
cookbooks/planet/templates/default/planetdump.erb

diff --git a/cookbooks/planet/attributes/default.rb b/cookbooks/planet/attributes/default.rb
new file mode 100644 (file)
index 0000000..649d9b3
--- /dev/null
@@ -0,0 +1,4 @@
+default[:planet][:dump][:xml_directory] = "/store/planet/planet"
+default[:planet][:dump][:xml_history_directory] = "/store/planet/planet/full-history"
+default[:planet][:dump][:pbf_directory] = "/store/planet/pbf"
+default[:planet][:dump][:pbf_history_directory] = "/store/planet/pbf/full-history"
index 706e766e8c57f8581d3958267795c81b7455be25..51470380dc47684f04331f2e05355262afc7a1b0 100644 (file)
@@ -61,16 +61,13 @@ remote_directory "/store/planet" do
   files_mode 0755
 end
 
-directory "/store/planet/planet" do
-  owner "www-data"
-  group "planet"
-  mode 0775
-end
-
-directory "/store/planet/pbf" do
-  owner "www-data"
-  group "planet"
-  mode 0775
+[:xml_directory, :xml_history_directory,
+ :pbf_directory, :pbf_history_directory].each do |dir|
+  directory dir do
+    owner "www-data"
+    group "planet"
+    mode 0775
+  end
 end
 
 directory "/store/planet/notes" do
index bc0214da59e992fde0d5ea447a292946906796c2..1425fbec30214b9c1245fb3413e4862cbb96e6ee 100644 (file)
@@ -89,9 +89,11 @@ directory "/store/planetdump" do
   mode 0755
 end
 
-template "/usr/local/bin/planetdump" do
-  source "planetdump.erb"
-  owner "root"
-  group "root"
-  mode 0755
+["planetdump", "planet-mirror-redirect-update", "apache-latest-planet-filename"].each do |program|
+  template "/usr/local/bin/#{program}" do
+    source "#{program}.erb"
+    owner "root"
+    group "root"
+    mode 0755
+  end
 end
similarity index 64%
rename from cookbooks/planet/files/default/bin/apache-latest-planet-filename
rename to cookbooks/planet/templates/default/apache-latest-planet-filename.erb
index e5e35819a92f3a28d41ff50e634720e4b0890d09..d7c8695c7408103620557e5bbe49baa10f6736c2 100644 (file)
@@ -4,7 +4,7 @@
 
 $| = 1;
 while (<STDIN>) {
-       my $where = readlink("/store/planet/planet/planet-latest.osm.bz2");
+       my $where = readlink("<%= node[:planet][:dump][:xml_directory] %>/planet-latest.osm.bz2");
        s/planet\/planet\-latest\.osm\.bz2/planet\/$where/g;
        print $_;
 }
similarity index 96%
rename from cookbooks/planet/files/default/bin/planet-mirror-redirect-update
rename to cookbooks/planet/templates/default/planet-mirror-redirect-update.erb
index 6d772ec2b6ebc068e1f31e7207314844b232c6fb..1f37ecd234cb994546c93b4442c216220a3b0125 100644 (file)
@@ -8,7 +8,7 @@
        Modifies .htaccess
 */
 $_YEAR = date('Y');
-$_PLANET_FOLDER = '/store/planet/planet/'.$_YEAR.'/';
+$_PLANET_FOLDER = '<%= node[:planet][:dump][:xml_directory] %>/'.$_YEAR.'/';
 $_PLANET_REGEX = "/^(planet|changesets)\-\d{6}(\-nolt)?\.osm\.(bz2|gz)$/";
 $_MIRROR = 'http://ftp.heanet.ie/mirrors/openstreetmap.org/planet/'.$_YEAR.'/';
 $_PLANET_HTACCESS = $_PLANET_FOLDER.'../../.htaccess';
index 4d5bac02ce64c61e90de2214ab8a8f828b3dfb1e..a8fd4aa9fcf0f3a3a96f6df443f1b2e3158a0538 100644 (file)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# DO NOT EDIT - This file is being maintained by Chef
 
 # Exit on error
 set -e
@@ -52,15 +53,14 @@ time nice -n 19 /store/planet-dump-ng/planet-dump-ng \
      -p "planet-${date}.osm.pbf" -P "history-${date}.osm.pbf"
 
 # Move XML dumps into place
-for file in "changesets-${date}.osm.bz2" "planet-${date}.osm.bz2" "history-${date}.osm.bz2"
-do
-    md5sum "#{file}" > "#{file}.md5"
-    mv "${file}" "${file}.md5" "/store/planet/planet"
-done
-
-# Move PBF dumps into place
-for file in "planet-${date}.osm.pbf" "history-${date}.osm.pbf"
-do
-    md5sum "#{file}" > "#{file}.md5"
-    mv "${file}" "${file}.md5" "/store/planet/pbf"
-done
+year = `echo ${date} | sed "s/.*-\([0-9]\)\{4\}-.*/\1/"`
+<% {
+        "changesets-${date}.osm.bz2" => "#{node[:planet][:dump][:xml_directory]}/${year}",
+        "planet-${date}.osm.bz2" => "#{node[:planet][:dump][:xml_directory]}/${year}",
+        "history-${date}.osm.bz2" => "#{node[:planet][:dump][:xml_history_directory]}/${year}",
+        "planet-${date}.osm.pbf" => node[:planet][:dump][:pbf_directory],
+        "history-${date}.osm.pbf" => node[:planet][:dump][:pbf_history_directory]
+}.each do |file,dir| %>
+md5sum "<%= file %>" > "<%= file %>.md5"
+mv "<%= file %>" "<%= file %>.md5" "<%= dir %>"
+<% end %>