]> git.openstreetmap.org Git - chef.git/commitdiff
Allow planet redirector to handle any links under the webroot
authorTom Hughes <tom@compton.nu>
Wed, 20 Feb 2019 21:33:42 +0000 (21:33 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 20 Feb 2019 21:33:42 +0000 (21:33 +0000)
cookbooks/planet/templates/default/apache-latest-planet-filename.erb

index d7c8695c7408103620557e5bbe49baa10f6736c2..967fa41e5bc00bb3109e5928d46e7ccb6e1c4e8e 100644 (file)
@@ -2,9 +2,25 @@
 
 # DO NOT EDIT - This file is being maintained by Chef
 
+use strict;
+use warnings;
+
+use Cwd qw(abs_path);
+
 $| = 1;
-while (<STDIN>) {
-       my $where = readlink("<%= node[:planet][:dump][:xml_directory] %>/planet-latest.osm.bz2");
-       s/planet\/planet\-latest\.osm\.bz2/planet\/$where/g;
-       print $_;
+
+while (my $path = <STDIN>)
+{
+    chomp $path;
+
+    my $file = abs_path("/store/planet${path}");
+
+    if ($file && $file =~ m|/store/planet/| && -f $file)
+    {
+        print "${file}\n";
+    }
+    else
+    {
+        print "NULL\n";
+    }
 }