Skip to content
Pierre-Alexandre Meyer edited this page Feb 22, 2011 · 2 revisions

Example of xndeploy script:

#!/usr/bin/env ruby

require 'optparse'
require 'yaml'

Root = File.expand_path(File.join(File.dirname(__FILE__), ".."))

begin
  require 'galaxy/fetcher'
  require 'galaxy/host'
  require 'galaxy/properties'
  require 'galaxy/repository'
rescue LoadError
  $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
  retry
end

# Parse options given by Galaxy core
options = {}
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

options[:repository] ||= "http://gepo.company.com/config"
options[:binaries] ||= "http://gepo.company.com/binaries"

# Pre-deploy script, if needed
unless system("#{File.join(File.dirname(__FILE__), "configure")} --base #{options[:base]} --config-path #{options[:config_path]} --repository #{options[:repository]}")
  raise "Unable to invoke the configure script"
end

# You can now do a bunch of interesting things
#
# You can get access to Galaxy properties...
prop_builder = Galaxy::Properties::Builder.new options[:repository]
# Download extra resources (see also Galaxy::HostUtils)...
fetcher = Galaxy::Fetcher.new options[:binaries], Logger.new(STDOUT)
# Do random stuff on the host, like getting the IP address...
ip = `/sbin/ifconfig -a | grep -w inet | awk '{ print $2 }' | fgrep -v 127.0.0.1 | head -1 | sed 's/addr://'`.strip
Clone this wiki locally