Skip to content

Instantly share code, notes, and snippets.

@gaffneyc
Created November 19, 2012 19:47
Show Gist options
  • Save gaffneyc/4113321 to your computer and use it in GitHub Desktop.
Save gaffneyc/4113321 to your computer and use it in GitHub Desktop.
Rack app to serve the current chef repo as a tar file
require "open3"
class TarApp
def call(env)
data = nil
status = nil
if(env["REQUEST_PATH"] !~ /(tgz|tar\.gz)/)
return [ 301, { "Location" => "/current.tgz" }, "" ]
end
Dir.chdir(File.expand_path("..", __FILE__)) do
data, status = Open3.capture2e("tar cz cookbooks/ data_bags/ roles/")
end
if status.success?
[ 200, { "Content-Type" => "application/octet-stream" }, data ]
else
[ 500, { "Content-Type" => "text/plain", }, data ]
end
end
end
run TarApp.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment