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.
- checksums.yaml +4 -4
- data/lib/cleanfb/version.rb +1 -1
- data/lib/cleanfb.rb +25 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 467b2435df87f3108d8ed71e65f0106fa7b29726
|
4
|
+
data.tar.gz: 08b60fa7af284ae45f100c03c9ec44b1c77f9534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffd763b7e30cb5bc194a6523d1bef9861ac2b5d313149e2940519a4be307946122966a5a859eb91cdbabde8ecbbb4edd859bee821f34a1eae4e521bd82328b98
|
7
|
+
data.tar.gz: 2a8dfe84e85c33c7bed247e0d7d78df6ab136d9b6c04afc37a821e7ae80e57b717fb2ba3a81c3d7399b8024c664b2d83ecb4ce88a98e1d3d202b15e1215faa17
|
data/lib/cleanfb/version.rb
CHANGED
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
|
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
|
-
|
42
|
+
path = "/opt/puppetlabs/puppet/cache/bucket"
|
25
43
|
sum = line.split(" ")[0]
|
26
|
-
start = sum.scan /\w/
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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."
|