Merge pull request #59 from hunter/bluepill

Bluepill export
This commit is contained in:
David Dollar
2011-09-09 13:56:02 -07:00
6 changed files with 143 additions and 0 deletions
+1
View File
@@ -40,6 +40,7 @@ class Foreman::CLI < Thor
formatter = case format
when "inittab" then Foreman::Export::Inittab
when "upstart" then Foreman::Export::Upstart
when "bluepill" then Foreman::Export::Bluepill
else error "Unknown export format: #{format}."
end
+1
View File
@@ -7,3 +7,4 @@ end
require "foreman/export/base"
require "foreman/export/inittab"
require "foreman/export/upstart"
require "foreman/export/bluepill"
+29
View File
@@ -0,0 +1,29 @@
require "erb"
require "foreman/export"
class Foreman::Export::Bluepill < Foreman::Export::Base
def export(location, options={})
error("Must specify a location") unless location
FileUtils.mkdir_p location
app = options[:app] || File.basename(engine.directory)
user = options[:user] || app
log_root = options[:log] || "/var/log/#{app}"
template_root = options[:template]
Dir["#{location}/#{app}.pill"].each do |file|
say "cleaning up: #{file}"
FileUtils.rm(file)
end
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
master_template = export_template("bluepill", "master.pill.erb", template_root)
master_config = ERB.new(master_template).result(binding)
write_file "#{location}/#{app}.pill", master_config
end
end