From cfaee58f4db99544e531962717c35639085065ef Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 10 Aug 2005 03:20:30 +0000 Subject: more progress towards a functional daemon git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@533 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/client.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb index 199e59b29..efeee68c2 100644 --- a/lib/puppet/client.rb +++ b/lib/puppet/client.rb @@ -12,6 +12,7 @@ require 'openssl' require 'puppet/transaction' require 'puppet/transportable' require 'puppet/metric' +require 'puppet/daemon' $noclientnetworking = false begin @@ -31,6 +32,8 @@ module Puppet Puppet.err "Could not load client network libs: %s" % $noclientnetworking else class NetworkClient < XMLRPC::Client + include Puppet::Daemon + @@methods = [ :getconfig, :getcert ] @@methods.each { |method| @@ -124,6 +127,8 @@ module Puppet Puppet.recmkdir(dir, 0770) end } + + inited = false if File.exists?(keyfile) # load the key @key = OpenSSL::PKey::RSA.new(File.read(keyfile)) @@ -132,8 +137,9 @@ module Puppet Puppet.info "Creating a new SSL key at %s" % keyfile @key = OpenSSL::PKey::RSA.new(Puppet[:keylength]) File.open(keyfile, "w", 0660) { |f| f.print @key.to_pem } - File.open(publickeyfile, "w", 0660) { |f| f.print @key.public_key.to_pem } - + File.open(publickeyfile, "w", 0660) { |f| + f.print @key.public_key.to_pem + } end unless File.exists?(certfile) @@ -156,12 +162,15 @@ module Puppet File.open(certfile, "w", 0660) { |f| f.print cert } begin @cert = OpenSSL::X509::Certificate.new(cert) + inited = true rescue => detail raise Puppet::Error.new( "Invalid certificate: %s" % detail ) end end + + return inited end def getconfig -- cgit