summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-01-18 20:12:53 +0100
committerBrice Figureau <brice-puppet@daysofwonder.com>2009-02-16 20:12:10 +0100
commit8265d6eaf7dd7d4fb2af30363bfbcc698dea1436 (patch)
treed7ff5c50ca2fe0f7036277bf85302e077688f292 /bin
parentaf219bf45fe58287f1b46bcfd98dfbe548958b33 (diff)
downloadpuppet-8265d6eaf7dd7d4fb2af30363bfbcc698dea1436.tar.gz
puppet-8265d6eaf7dd7d4fb2af30363bfbcc698dea1436.tar.xz
puppet-8265d6eaf7dd7d4fb2af30363bfbcc698dea1436.zip
Move puppetmasterd to Puppet::Application
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/puppetmasterd168
1 files changed, 2 insertions, 166 deletions
diff --git a/bin/puppetmasterd b/bin/puppetmasterd
index 3abdb77ea..9f12f678c 100755
--- a/bin/puppetmasterd
+++ b/bin/puppetmasterd
@@ -62,169 +62,5 @@
# Copyright (c) 2005 Reductive Labs, LLC
# Licensed under the GNU Public License
-# Do an initial trap, so that cancels don't get a stack trace.
-trap(:INT) do
- $stderr.puts "Cancelling startup"
- exit(0)
-end
-
-require 'getoptlong'
-require 'puppet'
-require 'puppet/daemon'
-require 'puppet/network/server'
-
-# Create this first-off, so we have ARGV
-daemon = Puppet::Daemon.new
-daemon.argv = ARGV.dup
-
-options = [
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
- [ "--logdest", "-l", GetoptLong::REQUIRED_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 = {
- :setdest => false,
- :verbose => false,
- :debug => false
-}
-
-begin
- result.each { |opt,arg|
- case opt
- # First check to see if the argument is a valid configuration parameter;
- # if so, set it. NOTE: there is a catch-all at the bottom for defaults.rb
- when "--debug"
- options[:debug] = true
- when "--help"
- if Puppet.features.usage?
- RDoc::usage && exit
- else
- puts "No help available unless you have RDoc::usage installed"
- exit
- end
- when "--logdest"
- begin
- Puppet::Util::Log.newdestination(arg)
- options[:setdest] = true
- rescue => detail
- if Puppet[:debug]
- puts detail.backtrace
- end
- $stderr.puts detail.to_s
- end
- when "--version"
- puts "%s" % Puppet.version
- exit
- when "--verbose"
- options[:verbose] = true
- else
- Puppet.settings.handlearg(opt, arg)
- end
- }
-rescue GetoptLong::InvalidOption => detail
- $stderr.puts "Try '#{$0} --help'"
- #$stderr.puts detail
- exit(1)
-end
-
-# Now parse the config
-Puppet.parse_config
-
-# Handle the logging settings.
-if options[:debug] or options[:verbose]
- if options[:debug]
- Puppet::Util::Log.level = :debug
- else
- Puppet::Util::Log.level = :info
- end
-
- unless Puppet[:daemonize]
- Puppet::Util::Log.newdestination(:console)
- options[:setdest] = true
- end
-end
-
-unless options[:setdest]
- Puppet::Util::Log.newdestination(:syslog)
-end
-
-if Puppet.settings.print_configs?
- exit(Puppet.settings.print_configs ? 0 : 1)
-end
-
-Puppet.settings.use :main, :puppetmasterd, :ssl
-
-# A temporary solution, to at least make the master work for now.
-Puppet::Node::Facts.terminus_class = :yaml
-
-# Cache our nodes in yaml. Currently not configurable.
-Puppet::Node.cache_class = :yaml
-
-# Configure all of the SSL stuff.
-if Puppet::SSL::CertificateAuthority.ca?
- Puppet::SSL::Host.ca_location = :local
- Puppet.settings.use :ca
- Puppet::SSL::CertificateAuthority.instance
-else
- Puppet::SSL::Host.ca_location = :none
-end
-
-require 'etc'
-
-if Puppet[:parseonly]
- begin
- Puppet::Parser::Interpreter.new.parser(Puppet[:environment])
- rescue => detail
- Puppet.err detail
- exit 1
- end
- exit(0)
-end
-
-require 'puppet/file_serving/content'
-require 'puppet/file_serving/metadata'
-require 'puppet/checksum'
-
-xmlrpc_handlers = [:Status, :FileServer, :Master, :Report, :Filebucket]
-
-# Just set up serving to all of the indirected classes.
-rest_handlers = Puppet::Indirector::Indirection.instances
-
-if Puppet[:ca]
- xmlrpc_handlers << :CA
-end
-
-daemon.server = Puppet::Network::Server.new(:handlers => rest_handlers, :xmlrpc_handlers => xmlrpc_handlers)
-
-# Make sure we've got a localhost ssl cert
-Puppet::SSL::Host.localhost
-
-# And now configure our server to *only* hit the CA for data, because that's
-# all it will have write access to.
-if Puppet::SSL::CertificateAuthority.ca?
- Puppet::SSL::Host.ca_location = :only
-end
-
-if Process.uid == 0
- begin
- Puppet::Util.chuser
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- $stderr.puts "Could not change user to %s: %s" % [Puppet[:user], detail]
- exit(39)
- end
-end
-
-daemon.daemonize if Puppet[:daemonize]
-
-Puppet.notice "Starting Puppet server version %s" % [Puppet.version]
-
-daemon.start
+require 'puppet/application/puppetmasterd'
+Puppet::Application[:puppetmasterd].run