cleanfb 0.1.1.3.5 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cleanfb/version.rb +1 -1
  3. data/lib/cleanfb.rb +25 -10
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a56060692fe2a9a15ef8ea0a595838df9ed0ae2b
4
- data.tar.gz: dda1d94cbba855160ec873b975306f4d67e96709
3
+ metadata.gz: 467b2435df87f3108d8ed71e65f0106fa7b29726
4
+ data.tar.gz: 08b60fa7af284ae45f100c03c9ec44b1c77f9534
5
5
  SHA512:
6
- metadata.gz: dcc1e04c184f2b0be2abed8a093adbba7a30a2502a51bee300a4050f86e0c364b0ee8ab232b4a5d2935f03bf38cdddea975ce0a9e31d2e533a959e749c8a60a0
7
- data.tar.gz: 47ccd231321c40578307f16635cf701a0dec816740850ae20ef467b697c191d23e5612192e17213f9898b2e497a4e4b6f089b5c07bc5f25e0719a8349e057a1f
6
+ metadata.gz: ffd763b7e30cb5bc194a6523d1bef9861ac2b5d313149e2940519a4be307946122966a5a859eb91cdbabde8ecbbb4edd859bee821f34a1eae4e521bd82328b98
7
+ data.tar.gz: 2a8dfe84e85c33c7bed247e0d7d78df6ab136d9b6c04afc37a821e7ae80e57b717fb2ba3a81c3d7399b8024c664b2d83ecb4ce88a98e1d3d202b15e1215faa17
@@ -1,3 +1,3 @@
1
1
  module Cleanfb
2
- VERSION = "0.1.1.3.5"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/cleanfb.rb CHANGED
@@ -3,34 +3,49 @@ require "cleanfb/version"
3
3
  module Cleanfb
4
4
 
5
5
  class Clean
6
+
7
+ ##
8
+ # Method to remove ALL files backed up on the Puppet masters filebucket
9
+ # from a specified agent.
10
+ ##
6
11
  def remove()
12
+
13
+ # return if no args
7
14
  return "Please supply a file" if ARGV[0].nil? || ARGV[0].empty?
8
15
 
16
+ # return the help output if requested
9
17
  if ((ARGV.include? "-h") or (ARGV.include? "--help"))
10
- return "Remove backups of an agent from the Puppet master's filebucket.\n\n Usage: cleanfb <client>\n\n options: -h or --help | help and information\n -y | defaults all input to yes\n"
18
+ return "Remove backups of an agent from the Puppet master's filebucket.\n\n/
19
+ Usage: cleanfb <client>\n\n options: -h or --help | help and information\n/
20
+ -y | defaults all input to yes\n"
21
+
11
22
  end
23
+
12
24
  arg = ARGV[0]
25
+
26
+ # set ans to yes automatically if -y option
13
27
  if !ARGV.nil? and (ARGV.include? "-y") and ARGV.length > 1
14
28
  ans = "y"
15
29
  arg = ARGV[1] if (ARGV.index("-y") == 0)
30
+
31
+ # else prompt for answer
16
32
  else
17
33
  print "Remove #{arg} ? y|n: "
18
34
  ans = STDIN.gets.chomp
19
35
  end
36
+
37
+ # if yes, retrieve the files and remove them
20
38
  if ans == "y" || ans == "yes"
21
39
  cmd = `puppet filebucket list -l|grep -i #{arg}`
22
40
  unless cmd.nil? || cmd.empty?
23
41
  cmd.each_line do |line|
24
- folders = "/opt/puppetlabs/puppet/cache/bucket"
42
+ path = "/opt/puppetlabs/puppet/cache/bucket"
25
43
  sum = line.split(" ")[0]
26
- start = sum.scan /\w/
27
- start = start.join("/")
28
-
29
- folders += "/" + start[0..7] + "/" + sum + "/"
30
- #folders += "/" + sum[0] + "/" + sum[1] + "/" + sum[2] + "/" + sum[3] + "/" + sum[4] + "/" + sum[5] + "/" + sum[6] + "/" + sum[7] + "/"
31
- # folders += sum + "/"
32
- puts "Removing " + folders
33
- cmd = `rm -rf #{folders}`
44
+ start = (sum.scan /\w/).join("/")
45
+
46
+ path += "/" + start[0..7] + sum + "/"
47
+ puts "Removing " + path
48
+ cmd = `rm -rf #{path}`
34
49
  end
35
50
  else
36
51
  puts "No file #{arg} found."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cleanfb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.3.5
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - lhoffl