cleanfb 0.1.5.0 → 0.2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d603676a6ca95f5d14686b165f29cf4b4140a4e
4
- data.tar.gz: 91d8e19a731c3c60a4dcc10fbdf24a5a32059735
3
+ metadata.gz: 89bb9afdedece34a64562247912640a103e15107
4
+ data.tar.gz: 4875c18855bd4c88997d3a692fe84242a7e289c8
5
5
  SHA512:
6
- metadata.gz: 05dca4425aea4bdd575f71f3a6536a2048b0629d5c846005e2b66235cc7e5e729cc4fb64085bdcfe087af5913e663cccd13cd2e450375405e12dcae890fad5e9
7
- data.tar.gz: 0365ec54817217f08df05e080c41cbfa8fc2faa2076a54e1456a6c4bf2550be0554e7e14d468fadb0c49ab7da8082510bd0d20e3c972a4159eb0b4e8e09344c5
6
+ metadata.gz: 63950e72bb3cd07dffc49a8554814f35b7f014cfef9da9a995fa29ee0b0b5d11db867312dee83bc7066bdbce2336d444694949ea4467d6fd6699922f383935aa
7
+ data.tar.gz: 54d33fd1e44b4665dc8de0ca895422c5cf24c6132bd66f625ddf25088f6bd5e5529462cdcbb1e3e578237e4fdbadc91e93fcd26547dab340e6e28776bb0bde2b
data/exe/cleanfb CHANGED
@@ -8,7 +8,12 @@ end
8
8
 
9
9
  cleaner = Cleanfb::Clean.new
10
10
 
11
- response = cleaner.remove
11
+ unless ARGV.include? "restore"
12
+ response = cleaner.remove
13
+ else
14
+ respone = cleaner.restore
15
+ end
16
+
12
17
  unless response.nil? || response.empty? || (response.include? "Please")
13
18
  puts response.magenta
14
19
  else
@@ -1,3 +1,3 @@
1
1
  module Cleanfb
2
- VERSION = "0.1.5.0"
2
+ VERSION = "0.2.0.0"
3
3
  end
data/lib/cleanfb.rb CHANGED
@@ -98,5 +98,52 @@ module Cleanfb
98
98
  end
99
99
  return
100
100
  end
101
- end
101
+
102
+ def restore()
103
+
104
+ # return if no args
105
+ return "Please supply a file" if ARGV[0].nil? || ARGV[0].empty?
106
+
107
+ # return the help output if requested
108
+ if ((ARGV.include? "-h") or (ARGV.include? "--help"))
109
+ return "Remove backups of an agent from the Puppet master's filebucket.\nBackups are stored at /root/saved_configs/\n\n Usage: cleanfb <client> <options>\n\n options: -h or --help | help and information\n
110
+ -y | defaults all input to yes\n"
111
+
112
+ end
113
+
114
+ arg = ARGV[0]
115
+
116
+ # set ans to yes automatically if -y option
117
+ if !ARGV.nil? and (ARGV.include? "-y") and ARGV.length > 1
118
+ ans = "y"
119
+ arg = ARGV[1] if (ARGV.index("-y") == 0)
120
+
121
+ # else prompt for answer
122
+ else
123
+ print "Restore #{arg} ? y|n: "
124
+ ans = STDIN.gets.chomp
125
+ end
126
+
127
+ # if yes, retrieve the files and remove them
128
+ if ans == "y" || ans == "yes"
129
+
130
+ file = arg
131
+ sum = Digest::MD5.file file
132
+ start = (sum.scan /\w/).join("/")
133
+ path = "/opt/puppetlabs/puppet/cache/bucket"
134
+
135
+ path += "/" + start[0..15] + sum + "/"
136
+
137
+ if File.exist? "#{path}/contents"
138
+
139
+ puts "Restoring " + path
140
+ cmd = `mv -f #{file} #{path}contents`
141
+ else
142
+ puts "No file #{arg} found."
143
+ end
144
+ else
145
+ puts "No file #{arg} found."
146
+ end
147
+ return
148
+ end
102
149
  end
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.1.5.0
4
+ version: 0.2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lhoffl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler