summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-02-14 16:17:20 +0100
committerBrice Figureau <brice-puppet@daysofwonder.com>2009-02-16 20:12:10 +0100
commitd51398c3eb3c09a9912fff8b4b7656a9ddb6b873 (patch)
tree2fda33dbe8cced21f3c377b3d0ca13940b604218 /bin
parent9b9e5e895bef9e59f7d592d6eb687ab1f683c117 (diff)
downloadpuppet-d51398c3eb3c09a9912fff8b4b7656a9ddb6b873.tar.gz
puppet-d51398c3eb3c09a9912fff8b4b7656a9ddb6b873.tar.xz
puppet-d51398c3eb3c09a9912fff8b4b7656a9ddb6b873.zip
Move filebucket to the Application Controller paradigm
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/filebucket122
1 files changed, 4 insertions, 118 deletions
diff --git a/bin/filebucket b/bin/filebucket
index ea75cb6de..911bd2ec7 100755
--- a/bin/filebucket
+++ b/bin/filebucket
@@ -94,122 +94,8 @@
# Copyright (c) 2005 Reductive Labs, LLC
# Licensed under the GNU Public License
-require 'puppet'
-require 'puppet/network/client'
-require 'getoptlong'
-
-options = [
- [ "--bucket", "-b", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
- [ "--local", "-l", GetoptLong::NO_ARGUMENT ],
- [ "--remote", "-r", GetoptLong::NO_ARGUMENT ],
- [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
- [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
-]
-
-# Add all of the config parameters as valid options.
-Puppet.settings.addargs(options)
-
-result = GetoptLong.new(*options)
-
-options = {}
-
-begin
- result.each { |opt,arg|
- case opt
- when "--version"
- puts "%s" % Puppet.version
- exit
- when "--help"
- if Puppet.features.usage?
- RDoc::usage && exit
- else
- puts "No help available unless you have RDoc::usage installed"
- exit
- end
- when "--bucket"
- options[:bucket] = arg
- when "--verbose"
- options[:verbose] = true
- when "--debug"
- options[:debug] = true
- when "--local"
- options[:local] = true
- when "--remote"
- options[:remote] = true
- else
- Puppet.settings.handlearg(opt, arg)
- end
- }
-rescue GetoptLong::InvalidOption => detail
- $stderr.puts "Try '#{$0} --help'"
- exit(1)
-end
-
-Puppet::Log.newdestination(:console)
-
-client = nil
-server = nil
-
-trap(:INT) do
- $stderr.puts "Cancelling"
- exit(1)
-end
-
-if options[:debug]
- Puppet::Log.level = :debug
-elsif options[:verbose]
- Puppet::Log.level = :info
-end
-
-# Now parse the config
-Puppet.parse_config
-
-if Puppet.settings.print_configs?
- exit(Puppet.settings.print_configs ? 0 : 1)
-end
-
-begin
- if options[:local] or options[:bucket]
- path = options[:bucket] || Puppet[:bucketdir]
- client = Puppet::Network::Client.dipper.new(:Path => path)
- else
- require 'puppet/network/handler'
- client = Puppet::Network::Client.dipper.new(:Server => Puppet[:server])
- end
-rescue => detail
- $stderr.puts detail
- if Puppet[:trace]
- puts detail.backtrace
- end
- exit(1)
-end
-
-mode = ARGV.shift
-case mode
-when "get":
- md5 = ARGV.shift
- out = client.getfile(md5)
- print out
-when "backup":
- ARGV.each do |file|
- unless FileTest.exists?(file)
- $stderr.puts "%s: no such file" % file
- next
- end
- unless FileTest.readable?(file)
- $stderr.puts "%s: cannot read file" % file
- next
- end
- md5 = client.backup(file)
- puts "%s: %s" % [file, md5]
- end
-when "restore":
- file = ARGV.shift
- md5 = ARGV.shift
- client.restore(file, md5)
-else
- raise "Invalid mode %s" % mode
-end
+require 'puppet/application'
+require 'puppet/application/filebucket'
+# launch the filebucket
+Puppet::Application[:filebucket].run \ No newline at end of file