aboutsummaryrefslogtreecommitdiffstats
path: root/switchtower/bin
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-08-30 20:53:32 +0000
committerJamis Buck <jamis@37signals.com>2005-08-30 20:53:32 +0000
commit6b1864a048ffb9343d4658ec11c32494d7f038db (patch)
tree6c1ad3f9131d644afab6cc6188001cfb73775e33 /switchtower/bin
parentbb7f60ca1cd191fd775fef261b4d2bc7af223604 (diff)
downloadrails-6b1864a048ffb9343d4658ec11c32494d7f038db.tar.gz
rails-6b1864a048ffb9343d4658ec11c32494d7f038db.tar.bz2
rails-6b1864a048ffb9343d4658ec11c32494d7f038db.zip
Move switchtower to the tools directory, to decouple it from rails
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2074 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'switchtower/bin')
-rwxr-xr-xswitchtower/bin/switchtower118
1 files changed, 0 insertions, 118 deletions
diff --git a/switchtower/bin/switchtower b/switchtower/bin/switchtower
deleted file mode 100755
index d567ad7555..0000000000
--- a/switchtower/bin/switchtower
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'optparse'
-require 'switchtower'
-
-begin
- if !defined?(USE_TERMIOS) || USE_TERMIOS
- require 'termios'
- else
- raise LoadError
- end
-
- # Enable or disable stdin echoing to the terminal.
- def echo(enable)
- term = Termios::getattr(STDIN)
-
- if enable
- term.c_lflag |= (Termios::ECHO | Termios::ICANON)
- else
- term.c_lflag &= ~Termios::ECHO
- end
-
- Termios::setattr(STDIN, Termios::TCSANOW, term)
- end
-rescue LoadError
- def echo(enable)
- end
-end
-
-options = { :verbose => 0, :recipes => [], :actions => [], :vars => {} }
-
-OptionParser.new do |opts|
- opts.banner = "Usage: #{$0} [options]"
- opts.separator ""
-
- opts.on("-a", "--action ACTION",
- "An action to execute. Multiple actions may",
- "be specified, and are loaded in the given order."
- ) { |value| options[:actions] << value }
-
- opts.on("-p", "--password PASSWORD",
- "The password to use when connecting.",
- "(Default: prompt for password)"
- ) { |value| options[:password] = value }
-
- opts.on("-P", "--[no-]pretend",
- "Run the task(s), but don't actually connect to or",
- "execute anything on the servers. (For various reasons",
- "this will not necessarily be an accurate depiction",
- "of the work that will actually be performed.",
- "Default: don't pretend.)"
- ) { |value| options[:pretend] = value }
-
- opts.on("-r", "--recipe RECIPE",
- "A recipe file to load. Multiple recipes may",
- "be specified, and are loaded in the given order."
- ) { |value| options[:recipes] << value }
-
- opts.on("-s", "--set NAME=VALUE",
- "Specify a variable and it's value to set. This",
- "will be set after loading all recipe files."
- ) do |pair|
- name, value = pair.split(/=/)
- options[:vars][name.to_sym] = value
- end
-
- opts.on("-v", "--verbose",
- "Specify the verbosity of the output.",
- "May be given multiple times. (Default: silent)"
- ) { options[:verbose] += 1 }
-
- opts.separator ""
- opts.on_tail("-h", "--help", "Display this help message") do
- puts opts
- exit
- end
- opts.on_tail("-V", "--version",
- "Display the version info for this utility"
- ) do
- require 'switchtower/version'
- puts "SwitchTower v#{SwitchTower::Version::STRING}"
- exit
- end
-
- opts.parse!
-end
-
-abort "You must specify at least one recipe" if options[:recipes].empty?
-abort "You must specify at least one action" if options[:actions].empty?
-
-unless options.has_key?(:password)
- options[:password] = Proc.new do
- sync = STDOUT.sync
- begin
- echo false
- STDOUT.sync = true
- print "Password: "
- STDIN.gets.chomp
- ensure
- echo true
- STDOUT.sync = sync
- puts
- end
- end
-end
-
-config = SwitchTower::Configuration.new
-config.logger.level = options[:verbose]
-config.set :password, options[:password]
-config.set :pretend, options[:pretend]
-
-config.load "standard" # load the standard recipe definition
-
-options[:recipes].each { |recipe| config.load(recipe) }
-options[:vars].each { |name, value| config.set(name, value) }
-
-actor = config.actor
-options[:actions].each { |action| actor.send action }