X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/063bfb7e0473de34b947b867d4d0c490540b4fc9..1d6267bb05023fec9c7a0b73c461e89579d62eeb:/cookbooks/planet/templates/default/apache-latest-planet-filename.erb diff --git a/cookbooks/planet/templates/default/apache-latest-planet-filename.erb b/cookbooks/planet/templates/default/apache-latest-planet-filename.erb index d7c8695c7..283e0d5a8 100644 --- a/cookbooks/planet/templates/default/apache-latest-planet-filename.erb +++ b/cookbooks/planet/templates/default/apache-latest-planet-filename.erb @@ -1,10 +1,28 @@ -#!/usr/bin/perl +#!/usr/bin/python3 # DO NOT EDIT - This file is being maintained by Chef -$| = 1; -while () { - my $where = readlink("<%= node[:planet][:dump][:xml_directory] %>/planet-latest.osm.bz2"); - s/planet\/planet\-latest\.osm\.bz2/planet\/$where/g; - print $_; -} +import os +import sys + +def main(): + for line in sys.stdin: + path = line.strip() + + # Construct the file path and resolve its real path, + # which will consider any symbolic links + file = os.path.realpath(f"/store/planet{path}") + + # Check if the constructed file path starts with '/store/planet' + # and if the file actually exists + if file.startswith('/store/planet') and os.path.isfile(file): + # Print the portion of the path after '/store/planet' + # and immediately flush the output + print(file[len('/store/planet'):], flush=True) + else: + # If the file does not exist or the path does not start with + # the expected prefix, print "NULL" and flush the output + print("NULL", flush=True) + +if __name__ == "__main__": + main()