-
Notifications
You must be signed in to change notification settings - Fork 17
configure
Pierre-Alexandre Meyer edited this page Feb 23, 2011
·
1 revision
Example of configure script:
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
require 'yaml'
Root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
begin
require 'galaxy/host'
require 'galaxy/properties'
require 'galaxy/repository'
rescue LoadError
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
retry
end
options = {}
begin
OptionParser.new do |opts|
opts.on("--base BASE") { |base| options[:base] = base }
opts.on("--config-path PATH") { |path| options[:config_path] = path }
opts.on("--repository URL") { |url| options[:repository] = url }
opts.on("--binaries URL") { |url| options[:binaries] = url }
end.parse! ARGV
rescue Exception => e
puts e
end
options[:repository] ||= "http://gepo.company.com/config"
repository = Galaxy::Repository.new options[:repository]
prop_builder = Galaxy::Properties::Builder.new options[:repository]
# Fetch an extra kitties.config file from Gepo in the deployment directory (etc/)
# This does a line-by-line copy
kitties_config = repository.walk(options[:config_path], "kitties.config")
path = File.join(options[:base], "etc", "kitties.config")
File.delete(path) if File.exist?(path)
if !kitties_config.empty?
File.open path, "w" do |file|
file.print kitties_config.last
end
end
# The dogs.dat file is binary - cannot do a line-by-line copy
dogs_config = repository.walk(options[:config_path], "dogs.dat")
path = File.join(options[:base], "etc", "dogs.dat")
File.delete(path) if File.exist?(path)
if !dogs_config.empty?
output = File.open path, "w"
output.write(dogs_config)
end