diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/client/dipper.rb | 2 | ||||
-rwxr-xr-x | lib/puppet/server/filebucket.rb | 16 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 3 | ||||
-rwxr-xr-x | lib/puppet/type/pfilebucket.rb | 14 |
4 files changed, 20 insertions, 15 deletions
diff --git a/lib/puppet/client/dipper.rb b/lib/puppet/client/dipper.rb index bc85236a3..5965c6b7d 100644 --- a/lib/puppet/client/dipper.rb +++ b/lib/puppet/client/dipper.rb @@ -10,7 +10,7 @@ module Puppet def initialize(hash = {}) if hash.include?(:Path) bucket = Puppet::Server::FileBucket.new( - :Bucket => hash[:Path] + :Path => hash[:Path] ) hash.delete(:Path) hash[:Bucket] = bucket diff --git a/lib/puppet/server/filebucket.rb b/lib/puppet/server/filebucket.rb index 8a4d1a0a4..d07fc93af 100755 --- a/lib/puppet/server/filebucket.rb +++ b/lib/puppet/server/filebucket.rb @@ -16,7 +16,7 @@ class Server Puppet.config.setdefaults("filebucket", :bucketdir => { :default => "$vardir/bucket", - :mode => 0770, + :mode => 0750, :owner => "$user", :group => "$group", :desc => "Where FileBucket files are stored." @@ -28,7 +28,7 @@ class Server } Puppet::Util.logmethods(self, true) - attr_reader :name + attr_reader :name, :path # this doesn't work for relative paths def FileBucket.paths(base,md5) @@ -48,19 +48,19 @@ class Server end if hash.include?(:Path) - @bucket = hash[:Path] + @path = hash[:Path] hash.delete(:Path) else if defined? Puppet - @bucket = Puppet[:bucketdir] + @path = Puppet[:bucketdir] else - @bucket = File.expand_path("~/.filebucket") + @path = File.expand_path("~/.filebucket") end end Puppet.config.use(:filebucket) - @name = "filebucket[#{Puppet[:bucketdir]}]" + @name = "filebucket[#{@path}]" end # accept a file from a client @@ -68,7 +68,7 @@ class Server contents = Base64.decode64(string) md5 = Digest::MD5.hexdigest(contents) - bpath, bfile, pathpath = FileBucket.paths(@bucket,md5) + bpath, bfile, pathpath = FileBucket.paths(@path,md5) # if it's a new directory... if Puppet.recmkdir(bpath) @@ -131,7 +131,7 @@ class Server end def getfile(md5, client = nil, clientip = nil) - bpath, bfile, bpaths = FileBucket.paths(@bucket,md5) + bpath, bfile, bpaths = FileBucket.paths(@path,md5) unless FileTest.exists?(bfile) return false diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index a6b8c5a1f..08f003f8c 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -271,8 +271,7 @@ module Puppet end end begin - FileUtils.cp(file, - file + backup) + FileUtils.cp(file, file + backup) return true rescue => detail # since they said they want a backup, let's error out diff --git a/lib/puppet/type/pfilebucket.rb b/lib/puppet/type/pfilebucket.rb index 15c968dcf..c337ffa77 100755 --- a/lib/puppet/type/pfilebucket.rb +++ b/lib/puppet/type/pfilebucket.rb @@ -2,8 +2,6 @@ require 'puppet/server/filebucket' module Puppet newtype(:filebucket) do - attr_reader :bucket - @doc = "A repository for backing up files. If no filebucket is defined, then files will be backed up in their current directory, but the filebucket can be either a host- or site-global repository @@ -42,6 +40,8 @@ module Puppet desc "The path to the local filebucket. If this is not specified, then the bucket is remote and *server* must be specified." + + defaultto { Puppet[:bucketdir] } end # get the actual filebucket object @@ -57,9 +57,15 @@ module Puppet self.collect do |obj| obj.name end end - def initialize(hash) - super + def bucket + unless defined? @bucket + mkbucket() + end + + @bucket + end + def mkbucket if self[:server] begin @bucket = Puppet::Client::Dipper.new( |