cleanfb 0.2.1.122 → 0.2.2.1
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 +17 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f491b92acd5cc8e0c705a5d768eeee7a2d5f1e22
|
4
|
+
data.tar.gz: 28abe3e63df503fb2cf8b8d863fbfdd2f26b0b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a378da897a522873c33a0ebc7cb6014b763dd7b82b5803149b8054b5fa984cb29792192722d93a4441a5b46045c60e71c239e457b3d79c8948d8cdd62b9181e
|
7
|
+
data.tar.gz: 103c90e3e5183e2fc3a1886b9ea520305ddf73472e8405a4e4f54bd51038c5d9dce432fac9e447a5a33e800c24440fefe990f952409055aaed54a849bf9ccdbe
|
data/lib/cleanfb/version.rb
CHANGED
data/lib/cleanfb.rb
CHANGED
@@ -6,8 +6,7 @@ module Cleanfb
|
|
6
6
|
|
7
7
|
class Clean
|
8
8
|
|
9
|
-
options
|
10
|
-
hostname = ""
|
9
|
+
attr_accessor :options
|
11
10
|
|
12
11
|
def show_help
|
13
12
|
puts "HELP"
|
@@ -18,23 +17,22 @@ module Cleanfb
|
|
18
17
|
OptionParser.new do |opts|
|
19
18
|
opts.banner = ""
|
20
19
|
opts.on("-h", "--help", "Display help information") {show_help}
|
21
|
-
opts.on("-f", "--force", "Ignore all prompts") { |f| options[:force] = f }
|
22
|
-
opts.on("-nNAME", "--name=NAME", "Hostname") { |n| hostname = n }
|
23
|
-
end
|
20
|
+
opts.on("-f", "--force", "Ignore all prompts") { |f| @options[:force] = f }
|
21
|
+
opts.on("-nNAME", "--name=NAME", "Hostname") { |n| @options[:hostname] = n }
|
22
|
+
end.parse!
|
24
23
|
end
|
25
24
|
|
25
|
+
def remove
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
unless options[:force]
|
30
|
-
print "Remove #{hostname} ? y|n: "
|
27
|
+
unless @options[:force]
|
28
|
+
print "Remove #{@options[:hostname]} ? y|n: "
|
31
29
|
ans = STDIN.gets.chomp
|
32
30
|
end
|
33
31
|
|
34
|
-
if(options[:force] || ans =~ /^y/)
|
35
|
-
cmd = `puppet filebucket list -l|grep -i #{hostname}`
|
32
|
+
if(@options[:force] || ans =~ /^y/)
|
33
|
+
cmd = `puppet filebucket list -l|grep -i #{@options[:hostname]}`
|
36
34
|
|
37
|
-
unless options[:force]
|
35
|
+
unless @options[:force]
|
38
36
|
test = cmd.split(" ").last
|
39
37
|
multi_match = false
|
40
38
|
|
@@ -44,7 +42,7 @@ module Cleanfb
|
|
44
42
|
print "Matched multiple hosts. Remove all? y|n: "
|
45
43
|
ans = STDIN.gets.chomp
|
46
44
|
|
47
|
-
return "Ending run" unless (options[:force] || ans =~/^y/)
|
45
|
+
return "Ending run" unless (@options[:force] || ans =~/^y/)
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -56,10 +54,10 @@ module Cleanfb
|
|
56
54
|
|
57
55
|
start = (sum.scan /\w/).join("/")
|
58
56
|
|
59
|
-
file = line.split(" ")[3].split("/").last
|
60
57
|
name = file.split("_")[0]
|
61
58
|
date = line.split(" ")[1]
|
62
59
|
time = line.split(" ")[2]
|
60
|
+
file = line.split(" ")[3].split("/").last
|
63
61
|
|
64
62
|
save_dir = "/root/saved_configs/"
|
65
63
|
|
@@ -75,19 +73,19 @@ module Cleanfb
|
|
75
73
|
cmd = `mv -f #{path}contents /root/saved_configs/#{name}/#{date}_#{time}_#{file}`
|
76
74
|
cmd = `rm -rf #{path}`
|
77
75
|
else
|
78
|
-
puts "No file #{hostname} found."
|
76
|
+
puts "No file #{@options[:hostname]} found."
|
79
77
|
end
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
81
|
else
|
84
|
-
puts "No file #{hostname} found."
|
82
|
+
puts "No file #{@options[:hostname]} found."
|
85
83
|
end
|
86
84
|
|
87
85
|
return
|
88
86
|
end
|
89
87
|
|
90
|
-
def store
|
88
|
+
def store host
|
91
89
|
|
92
90
|
cmd = `puppet filebucket list -l|grep -i #{host}`
|
93
91
|
unless(cmd.nil? || cmd.empty?)
|
@@ -96,10 +94,10 @@ module Cleanfb
|
|
96
94
|
sum = line.split(" ")[0]
|
97
95
|
start = (sum.scan /\w/).join("/")
|
98
96
|
|
99
|
-
file = line.split(" ")[3].split("/").last
|
100
97
|
name = file.split("_")[0]
|
101
98
|
date = line.split(" ")[1]
|
102
99
|
time = line.split(" ")[2]
|
100
|
+
file = line.split(" ")[3].split("/").last
|
103
101
|
|
104
102
|
save_dir = "/root/saved_configs/"
|
105
103
|
|
@@ -124,7 +122,7 @@ module Cleanfb
|
|
124
122
|
return
|
125
123
|
end
|
126
124
|
|
127
|
-
def restore
|
125
|
+
def restore
|
128
126
|
|
129
127
|
return "Please supply a file" if (ARGV[0].nil? || ARGV[0].empty?)
|
130
128
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cleanfb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.1
|
4
|
+
version: 0.2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lhoffl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|