summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-08-29 17:12:57 +0000
committerLuke Kanies <luke@madstop.com>2005-08-29 17:12:57 +0000
commitcdfaa5ea36926caae58f30db86ed898cde82b874 (patch)
tree3071f78fa20c14a466e420653ed5178c083ed84e
parentf2795359521709b5d4a64900ebed5e7b0be84c6b (diff)
downloadpuppet-cdfaa5ea36926caae58f30db86ed898cde82b874.tar.gz
puppet-cdfaa5ea36926caae58f30db86ed898cde82b874.tar.xz
puppet-cdfaa5ea36926caae58f30db86ed898cde82b874.zip
adding RDoc::usage documentation to all executables
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@595 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xbin/certmgr.rb44
-rwxr-xr-xbin/filebucketd40
-rwxr-xr-xbin/puppet46
-rwxr-xr-xbin/puppetca154
-rwxr-xr-xbin/puppetd189
-rwxr-xr-xbin/puppetdoc85
-rwxr-xr-xbin/puppetmasterd174
7 files changed, 470 insertions, 262 deletions
diff --git a/bin/certmgr.rb b/bin/certmgr.rb
deleted file mode 100755
index 37f4a406c..000000000
--- a/bin/certmgr.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/ruby -w
-
-#--------------------
-# the puppet client
-#
-# $Id$
-
-
-require 'puppet'
-require 'puppet/openssl'
-require 'getoptlong'
-
-result = GetoptLong.new(
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
-)
-
-check = false
-
-result.each { |opt,arg|
- case opt
- when "--debug":
- when "--check":
- when "--help":
- puts "There is no help yet"
- exit
- else
- puts "Invalid option '#{opt}'"
- exit(10)
- end
-}
-
-Puppet[:logdest] = :console
-Puppet[:loglevel] = :info
-
-rootcert = Puppet[:rootcert]
-rootkey = Puppet[:rootkey]
-rootkey = Puppet[:rootkey]
-
-unless rootcert
- raise "config unset"
-end
-
-#mkcertsdir(File.basename(rootcert))
diff --git a/bin/filebucketd b/bin/filebucketd
deleted file mode 100755
index 2e7177d6a..000000000
--- a/bin/filebucketd
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/ruby -w
-
-#--------------------
-# accept and serve files
-#
-# $Id$
-
-require 'getoptlong'
-require 'puppet/filebucket'
-
- #[ "--size", "-s", GetoptLong::REQUIRED_ARGUMENT ],
-result = GetoptLong.new(
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
-)
-
-result.each { |opt,arg|
- case opt
- when "--help"
- puts "There is no help yet"
- exit
- else
- raise "Invalid option '#{opt}'"
- end
-}
-
-begin
- server = FileBucket::BucketWebserver.new(
- :Bucket => File.expand_path("~/.puppet/bucket"),
- :Debug => true,
- :Port => 8080
- )
- trap(:INT) { server.shutdown }
- server.start
- #server = FileBucket::BucketServer.new(
- # :Bucket => File.expand_path("~/.puppet/bucket")
- #)
-rescue => detail
- $stderr.puts detail
- exit(1)
-end
diff --git a/bin/puppet b/bin/puppet
index 1580cb196..b86d578aa 100755
--- a/bin/puppet
+++ b/bin/puppet
@@ -1,4 +1,4 @@
-#!/usr/bin/ruby -w
+#!/usr/bin/ruby
#
# = Synopsis
@@ -7,11 +7,12 @@
#
# = Usage
#
-# puppet [-V|--version] [-d|--debug] [-v|--verbose] [-l|--logfile <file>] [-h|--help] <file>
+# puppet [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
+# [-l|--logfile <file>] <file>
#
# = Description
#
-# This is the standalone +puppet+ execution script; use it to execute
+# This is the standalone puppet execution script; use it to execute
# individual scripts that you write. If you need to execute site-wide
# scripts, use +puppetd+ and +puppetmasterd+.
#
@@ -37,7 +38,7 @@
# = Copyright
#
# Copyright (c) 2005 Reductive Labs, LLC
-# Licensed under the Gnu Public License
+# Licensed under the GNU Public License
require 'puppet'
require 'puppet/server'
@@ -52,13 +53,13 @@ rescue
$haveusage = false
end
- result = GetoptLong.new(
- [ "--version", "-V", GetoptLong::NO_ARGUMENT ],
- [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
- )
+result = GetoptLong.new(
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
+ [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
+)
debug = false
verbose = false
@@ -82,14 +83,21 @@ begin
when "--debug"
debug = true
when "--logfile"
- logfile = arg
- else
- $stderr.puts "Invalid option '#{opt}'"
- Rdoc::usage(1,'usage')
+ # FIXME we should be able to have log.rb check the validity of the dst
+ case arg
+ when "syslog", "console", /^\//:
+ Puppet[:logdest] = arg
+ else
+ $stderr.puts "Invalid log destination %s" % arg
+ end
end
}
rescue GetoptLong::InvalidOption => detail
- RDoc::usage(1,'usage')
+ $stderr.puts "Try '#{$0} --help'"
+ #if $haveusage
+ # RDoc::usage(1,'usage')
+ #end
+ exit(1)
end
if debug
@@ -98,10 +106,6 @@ elsif verbose
Puppet[:loglevel] = :info
end
-if logfile
- Puppet[:logdest] = logfile
-end
-
begin
server = Puppet::Server::Master.new(
:File => ARGV.shift,
@@ -125,6 +129,6 @@ begin
client.getconfig
client.config
rescue => detail
- $stderr.puts detail
+ Puppet.err detail
exit(1)
end
diff --git a/bin/puppetca b/bin/puppetca
index 358f721b1..b28125a72 100755
--- a/bin/puppetca
+++ b/bin/puppetca
@@ -1,58 +1,134 @@
-#!/usr/bin/ruby -w
+#!/usr/bin/ruby
-#--------------------
-# the puppet client
#
-# $Id$
-
+# = Synopsis
+#
+# Stand-alone certificate authority. Capable of generating certificates
+# but mostly meant for signing certificate requests from puppet clients.
+#
+# = Usage
+#
+# puppetca [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
+# [--cadir <ca directory>] [-g|--generate] [-l|--list]
+# [-s|--sign] [--ssldir <cert directory>]
+#
+# = Description
+#
+# Because the puppetmasterd daemon defaults to not signing client certificate
+# requests, this script is available for signing outstanding requests. It
+# can be used to list outstanding requests and then either sign them individually
+# or sign all of them.
+#
+# = Options
+#
+# all::
+# Operate on all outstanding requests. Only makes sense with '--sign'.
+#
+# cadir::
+# Where to look for the ca directory. Defaults to /etc/puppet/ssl/ca.
+#
+# debug::
+# Enable full debugging.
+#
+# generate::
+# Generate a certificate for a named client. A certificate/keypair will be
+# generated for each client named on the command line.
+#
+# help::
+# Print this help message
+#
+# list::
+# List outstanding certificate requests.
+#
+# sign::
+# Sign an outstanding certificate request. Unless '--all' is specified,
+# hosts must be listed after all flags.
+#
+# ssldir::
+# The directory in which to store certificates. Defaults to /etc/puppet/ssl.
+#
+# verbose::
+# Enable verbosity.
+#
+# = Example
+#
+# $ puppetca -l
+# culain.madstop.com
+# $ puppetca -s culain.madstop.com
+#
+# = Author
+#
+# Luke Kanies
+#
+# = Copyright
+#
+# Copyright (c) 2005 Reductive Labs, LLC
+# Licensed under the GNU Public License
require 'puppet'
require 'puppet/sslcertificates'
require 'getoptlong'
+$haveusage = true
+
+begin
+ require 'rdoc/usage'
+rescue
+ $haveusage = false
+end
+
result = GetoptLong.new(
- [ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--list", "-l", GetoptLong::NO_ARGUMENT ],
- [ "--sign", "-s", GetoptLong::NO_ARGUMENT ],
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
[ "--all", "-a", GetoptLong::NO_ARGUMENT ],
[ "--cadir", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
[ "--generate", "-g", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
+ [ "--list", "-l", GetoptLong::NO_ARGUMENT ],
+ [ "--sign", "-s", GetoptLong::NO_ARGUMENT ],
+ [ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ]
)
mode = nil
all = false
generate = nil
-result.each { |opt,arg|
- case opt
- when "--help"
- puts "There is no help yet"
- exit
- when "--list"
- mode = :list
- when "--sign"
- mode = :sign
- when "--all"
- all = true
- when "--verbose"
- Puppet[:loglevel] = :info
- when "--debug"
- Puppet[:loglevel] = :debug
- when "--generate"
- generate = arg
- mode = :generate
- when "--cadir"
- Puppet[:cadir] = arg
- when "--ssldir"
- Puppet[:ssldir] = arg
- else
- puts "Invalid option '#{opt}'"
- exit(10)
- end
-}
+begin
+ result.each { |opt,arg|
+ case opt
+ when "--all"
+ all = true
+ when "--cadir"
+ Puppet[:cadir] = arg
+ when "--debug"
+ Puppet[:loglevel] = :debug
+ when "--generate"
+ generate = arg
+ mode = :generate
+ when "--help"
+ if $haveusage
+ RDoc::usage && exit
+ else
+ puts "No help available unless you have RDoc::usage installed"
+ exit
+ end
+ when "--list"
+ mode = :list
+ when "--sign"
+ mode = :sign
+ when "--ssldir"
+ Puppet[:ssldir] = arg
+ when "--verbose"
+ Puppet[:loglevel] = :info
+ end
+ }
+rescue GetoptLong::InvalidOption => detail
+ $stderr.puts "Try '#{$0} --help'"
+ #if $haveusage
+ # RDoc::usage_no_exit('usage')
+ #end
+ exit(1)
+end
ca = Puppet::SSLCertificates::CA.new()
@@ -125,3 +201,5 @@ else
$stderr.puts "Invalid mode %s" % mode
exit(42)
end
+
+# $Id$
diff --git a/bin/puppetd b/bin/puppetd
index 7b5184948..d65240c7c 100755
--- a/bin/puppetd
+++ b/bin/puppetd
@@ -1,64 +1,150 @@
#!/usr/bin/ruby
-
-#--------------------
-# the puppet client
+# == Synopsis
#
-# $Id$
-
+# Retrieve the client configuration from the central puppet server and apply
+# it to the local host.
+#
+# Currently must be run out periodically, using cron or something similar.
+#
+# = Usage
+#
+# puppetd [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
+# [--ssldir <cert directory>] [-l|--logdest <syslog|<file>|console>]
+# [--fqdn <host name>] [-p|--port <port>] [-s|--server <server>]
+#
+# = Description
+#
+# This is the main puppet client. Its job is to retrieve the local machine's
+# configuration from a remote server and apply it. In order to successfully
+# communicate with the remote server, the client must have a certificate signed
+# by a certificate authority that the server trusts; the recommended method
+# for this, at the moment, is to run a certificate authority as part of the
+# puppet server (which is the default). The client will connect and request
+# a signed certificate, and will continue connecting until it receives one.
+#
+# Once the client has a signed certificate, it will retrieve its configuration
+# and apply it.
+#
+# = Options
+#
+# debug::
+# Enable full debugging.
+#
+# fqdn::
+# Set the fully-qualified domain name of the client. This is only used for
+# certificate purposes, but can be used to override the discovered hostname.
+# If you need to use this flag, it is generally an indication of a setup problem.
+#
+# help::
+# Print this help message
+#
+# logdest::
+# Where to send messages. Choose between syslog, the console, and a log file.
+# Defaults to sending messages to /var/puppet/log/puppet.log, or the console
+# if debugging or verbosity is enabled.
+#
+# port::
+# The port to which to connect on the remote server. Currently defaults to 8139.
+#
+# server::
+# The remote server from whom to receive the local configuration. Currently
+# must also be the certificate authority. Currently defaults to 'localhost'.
+#
+# ssldir::
+# Where to store and find certificates. Defaults to /etc/puppet/ssl.
+#
+# verbose::
+# Turn on verbose reporting.
+#
+# version::
+# Print the puppet version number and exit.
+#
+# = Example
+#
+# puppet -s puppet.domain.com
+#
+# = Author
+#
+# Luke Kanies
+#
+# = Copyright
+#
+# Copyright (c) 2005 Reductive Labs, LLC
+# Licensed under the GNU Public License
-$:.unshift '../lib'
require 'puppet'
require 'puppet/server'
require 'puppet/client'
require 'getoptlong'
+$haveusage = true
+begin
+ require 'rdoc/usage'
+rescue
+ $haveusage = false
+end
+
result = GetoptLong.new(
- [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
[ "--fqdn", "-f", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--server", "-s", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--secure", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
+ [ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ],
[ "--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--noinit", "-n", GetoptLong::NO_ARGUMENT ],
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--server", "-s", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+ [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
)
-noinit = false
server = "localhost"
-proto = "http"
fqdn = nil
+args = {}
-result.each { |opt,arg|
- case opt
- when "--help"
- puts "There is no help yet"
- exit
- when "--verbose"
- Puppet[:loglevel] = :info
- when "--debug"
- Puppet[:loglevel] = :debug
- when "--ssldir"
- Puppet[:ssldir] = arg
- when "--secure"
- proto = "https"
- when "--noinit"
- noinit = true
- when "--fqdn"
- fqdn = arg
- when "--server"
- server = arg
- when "--port"
- Puppet[:masterport] = arg
- when "--logfile"
- Puppet[:logfile] = arg
- else
- puts "Invalid option '#{opt}'"
- exit(10)
- end
-}
+begin
+ result.each { |opt,arg|
+ case opt
+ when "--help"
+ if $haveusage
+ RDoc::usage && exit
+ else
+ puts "No help available unless you have RDoc::usage installed"
+ exit
+ end
+ when "--version"
+ puts "%s" % Puppet.version
+ exit
+ when "--verbose"
+ Puppet[:loglevel] = :info
+ when "--debug"
+ Puppet[:loglevel] = :debug
+ when "--ssldir"
+ Puppet[:ssldir] = arg
+ when "--fqdn"
+ fqdn = arg
+ when "--server"
+ server = arg
+ when "--port"
+ args[:Port] = arg
+ when "--logdest"
+ # FIXME we should be able to have log.rb check the validity of the dst
+ case arg
+ when "syslog", "console", /^\//:
+ Puppet[:logdest] = arg
+ else
+ $stderr.puts "Invalid log destination %s" % arg
+ end
+ end
+ }
+rescue GetoptLong::InvalidOption => detail
+ $stderr.puts "Try '#{$0} --help'"
+ #$stderr.puts detail
+ # FIXME RDoc::usage doesn't seem to work
+ #if $haveusage
+ # RDoc::usage(1,'usage')
+ #end
+ exit(1)
+end
bg = false
@@ -66,7 +152,7 @@ unless Puppet[:loglevel] == :debug or Puppet[:loglevel] == :info
bg = true
end
-args = {:Server => server}
+args[:Server] = server
if fqdn
args[:FQDN] = fqdn
end
@@ -75,8 +161,8 @@ client = Puppet::Client.new(args)
unless client.readcert
begin
while ! client.requestcert do
- Puppet.notice "Could not request certificate"
- sleep 5
+ Puppet.notice "Did not receive certificate"
+ sleep 60
end
rescue => detail
Puppet.err "Could not request certificate: %s" % detail.to_s
@@ -90,13 +176,6 @@ if bg
end
#client.start
client.getconfig
+client.config
-#threads = []
-#threads << Thread.new {
-# trap(:INT) {
-# client.shutdown
-# }
-# client.start
-#}
-#
-#client.getconfig
+# $Id$
diff --git a/bin/puppetdoc b/bin/puppetdoc
index e64ca0624..4a7693be7 100755
--- a/bin/puppetdoc
+++ b/bin/puppetdoc
@@ -1,45 +1,81 @@
-#!/usr/local/bin/ruby
-#!/usr/bin/ruby -w
+#!/usr/bin/ruby
-#--------------------
-# produce documentation on all of the puppet types
#
-# $Id$
-
-
-$:.unshift '../lib'
+# = Synopsis
+#
+# Generate a reference for all Puppet types. Largely meant for internal Reductive
+# Labs use.
+#
+# = Usage
+#
+# puppetdoc [-h|--help]
+#
+# = Description
+#
+# This command generates a restructured-text document describing all installed
+# Puppet types. It is largely meant for internal use and is used to generate
+# the reference document available on the Reductive Labs web site.
+#
+# = Options
+#
+# help::
+# Print this help message
+#
+# = Example
+#
+# $ puppetdoc > /tmp/reference.rst
+#
+# = Author
+#
+# Luke Kanies
+#
+# = Copyright
+#
+# Copyright (c) 2005 Reductive Labs, LLC
+# Licensed under the GNU Public License
require 'puppet'
require 'getoptlong'
+$haveusage = true
+
+begin
+ require 'rdoc/usage'
+rescue
+ $haveusage = false
+end
+
def tab(num)
return $tab * num
end
result = GetoptLong.new(
- [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
debug = false
-logfile = false
$tab = " "
-result.each { |opt,arg|
- case opt
- when "--help"
- puts "There is no help yet"
- exit
- when "--debug"
- debug = true
- when "--logfile"
- logfile = arg
- else
- raise "Invalid option '#{opt}'"
- end
-}
+begin
+ result.each { |opt,arg|
+ case opt
+ when "--help"
+ if $haveusage
+ RDoc::usage && exit
+ else
+ puts "No help available unless you have RDoc::usage installed"
+ exit
+ end
+ end
+ }
+rescue GetoptLong::InvalidOption => detail
+ $stderr.puts "Try '#{$0} --help'"
+ #if $haveusage
+ # RDoc::usage_no_exit('usage')
+ #end
+ exit(1)
+end
puts %{
==============
@@ -127,3 +163,4 @@ puts "
"
puts "\n*This page autogenerated on %s*" % Time.now
+# $Id$
diff --git a/bin/puppetmasterd b/bin/puppetmasterd
index 0c832aba6..00935ec91 100755
--- a/bin/puppetmasterd
+++ b/bin/puppetmasterd
@@ -1,62 +1,154 @@
-#!/usr/bin/ruby -w
+#!/usr/bin/ruby
-#--------------------
-# the central puppet server
#
-# $Id$
+# = Synopsis
+#
+# The central puppet server. Can also function as a certificate authority.
+#
+# = Usage
+#
+# puppetmasterd [-h|--help] [-d|--debug] [-v|--verbose] [-V|--version]
+# [-l|--logdest <syslog|console|<file>>] [--httplog <file>]
+# [-m|--manifest <site manifest>] [--noca] [-p|--port <port>]
+# [-s|--ssldir <cert directory>]
+#
+# = Description
+#
+# This is the standalone puppet execution script; use it to execute
+# individual scripts that you write. If you need to execute site-wide
+# scripts, use +puppetd+ and +puppetmasterd+.
+#
+# = Options
+#
+# debug::
+# Enable full debugging. Causes the daemon not to go into the background.
+#
+# help::
+# Print this help message.
+#
+# httplog::
+# Where to send http logs (which are currently separate from Puppet logs).
+# Defaults to /var/puppet/log/http.log.
+#
+# logdest::
+# Where to send messages. Choose between syslog, the console, and a log file.
+# Defaults to sending messages to /var/puppet/log/puppet.log, or the console
+# if debugging or verbosity is enabled.
+#
+# manifest::
+# The central site manifest to use for providing clients with their individual
+# configurations. Defaults to /etc/puppet/manifest.pp.
+#
+# noca::
+# Do not function as a certificate authority.
+#
+# port::
+# The port on which to listen. Defaults to 8139.
+#
+# ssldir::
+# The directory in which to store certificates. Defaults to /etc/puppet/ssl.
+#
+# verbose::
+# Enable verbosity. Causes the daemon not to go into the background.
+#
+# version::
+# Print the puppet version number and exit.
+#
+# = Example
+#
+# puppetmasterd
+#
+# = Author
+#
+# Luke Kanies
+#
+# = Copyright
+#
+# Copyright (c) 2005 Reductive Labs, LLC
+# Licensed under the GNU Public License
require 'getoptlong'
require 'puppet'
require 'puppet/server'
result = GetoptLong.new(
- [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--manifest", "-m", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--ssldir", "-s", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--noinit", "-n", GetoptLong::NO_ARGUMENT ],
[ "--autosign", "-a", GetoptLong::NO_ARGUMENT ],
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
+ [ "--httplog", GetoptLong::NO_ARGUMENT ],
+ [ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--manifest", "-m", GetoptLong::REQUIRED_ARGUMENT ],
[ "--noca", GetoptLong::NO_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+ [ "--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--ssldir", "-s", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
)
-noinit = false
+$haveusage = true
+
+begin
+ require 'rdoc/usage'
+rescue
+ $haveusage = false
+end
haveca = true
master = {}
ca = {}
args = {}
-result.each { |opt,arg|
- case opt
- when "--help"
- puts "There is no help yet"
- exit
- when "--verbose"
- Puppet[:loglevel] = :info
- when "--debug"
- Puppet[:debug] = true
- when "--autosign"
- ca[:autosign] = true
- when "--noca"
- haveca = false
- when "--port"
- args[:Port] = arg
- when "--ssldir"
- Puppet[:ssldir] = arg
- when "--manifest"
- master[:File] = arg
- when "--noinit"
- noinit = true
- when "--logfile"
- args[:AccessLog] = arg
- else
- $stderr.puts "Invalid option '#{opt}'"
- exit(1)
- end
-}
+begin
+ result.each { |opt,arg|
+ case opt
+ when "--autosign"
+ ca[:autosign] = true
+ when "--debug"
+ Puppet[:debug] = true
+ when "--help"
+ if $haveusage
+ RDoc::usage && exit
+ else
+ puts "No help available unless you have RDoc::usage installed"
+ exit
+ end
+ when "--httplog"
+ args[:AccessLog] = arg
+ when "--manifest"
+ master[:File] = arg
+ when "--noca"
+ haveca = false
+ when "--port"
+ args[:Port] = arg
+ when "--ssldir"
+ Puppet[:ssldir] = arg
+ when "--logdest"
+ # FIXME we should be able to have log.rb check the validity of the dst
+ case arg
+ when "syslog", "console", /^\//:
+ Puppet[:logdest] = arg
+ else
+ $stderr.puts "Invalid log destination %s" % arg
+ end
+ when "--version"
+ puts "%s" % Puppet.version
+ exit
+ when "--verbose"
+ Puppet[:loglevel] = :info
+ else
+ $stderr.puts "Invalid option '#{opt}'"
+ exit(1)
+ end
+ }
+rescue GetoptLong::InvalidOption => detail
+ $stderr.puts "Try '#{$0} --help'"
+ #$stderr.puts detail
+ # FIXME RDoc::usage doesn't seem to work
+ #if $haveusage
+ # RDoc::usage(1,'usage')
+ #end
+ exit(1)
+end
bg = false
@@ -110,3 +202,5 @@ rescue => detail
Puppet.err "Could not start puppetmaster: %s" % detail
exit(1)
end
+
+# $Id$