fileminer 1.0.0RC2 → 1.0.0RC3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fileminer +4 -6
- data/bin/fileminer-genconf +84 -11
- data/lib/fileminer/version.rb +2 -2
- data/lib/fileminer.rb +0 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6899adc461f156ac6e112c5d6e72b45baf51f71d0fd480812b150f112538b6d3
|
4
|
+
data.tar.gz: cd461fe3a027047a9ffa63c8aedbe7352d1e700c14d243823080350649103fbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b00dbaaafabfc8869d2971cb5ce39977b48ee713b4acbd9910336e69f610c95930c68f6ad82f214b1d7696f7cf1cd836113bf5ba4f0d0846e5d4ee71de3aae
|
7
|
+
data.tar.gz: f7bebce4c3a21351f737651b0ea15f8292021a35a94055e8048f36430d9dd316931588b66d5bbb27390e69db828cd7277e744b267281a31dda1f03b3f9983247
|
data/bin/fileminer
CHANGED
@@ -10,8 +10,9 @@ logger = Logger.new STDERR
|
|
10
10
|
|
11
11
|
begin
|
12
12
|
# Usage:
|
13
|
-
#
|
14
|
-
|
13
|
+
# fileminer [/path/to/fileminer.yml]
|
14
|
+
path = ARGV.empty? ? '/etc/fileminer/fileminer.yml' : ARGV[0]
|
15
|
+
yml = File.open(path) { |io| io.read }
|
15
16
|
conf = YAML.load yml
|
16
17
|
# create fileminer instance
|
17
18
|
fileminer = FileMiner.new conf
|
@@ -23,9 +24,6 @@ begin
|
|
23
24
|
fileminer.start_mining
|
24
25
|
rescue => e
|
25
26
|
logger.error e
|
26
|
-
usage =
|
27
|
-
Usage:
|
28
|
-
ruby -Ilib ./bin/fileminer /path/to/fileminer.yml
|
29
|
-
EOS
|
27
|
+
usage = 'Usage: fileminer [/path/to/fileminer.yml]'
|
30
28
|
puts usage
|
31
29
|
end
|
data/bin/fileminer-genconf
CHANGED
@@ -1,20 +1,93 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
|
4
|
+
require 'optparse'
|
4
5
|
require_relative '../lib/fileminer/tools/io'
|
5
6
|
|
6
|
-
current_path = File.absolute_path __FILE__
|
7
|
-
bin_path = File.dirname current_path
|
8
|
-
project_path = File.dirname bin_path
|
9
|
-
default_file_path = File.join project_path, 'conf', 'fileminer_default.yml'
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def gen_fileminer_conf(options)
|
9
|
+
current_path = File.absolute_path __FILE__
|
10
|
+
bin_path = File.dirname current_path
|
11
|
+
project_path = File.dirname bin_path
|
12
|
+
default_file_path = File.join project_path, 'conf', 'fileminer_default.yml'
|
13
|
+
if options.key? :out
|
14
|
+
out = options[:out]
|
15
|
+
dst = out.nil? ? '/etc/fileminer/fileminer.yml' : File.absolute_path(out)
|
16
|
+
unless dst.end_with?('.yml') || dst.end_with?('.yaml')
|
17
|
+
dst = File.join dst, 'fileminer.yml'
|
18
|
+
end
|
19
|
+
|
20
|
+
dst_dir = File.dirname dst
|
21
|
+
Dir.mkdirs dst_dir unless Dir.exist? dst_dir
|
22
|
+
|
23
|
+
File.copy_stream default_file_path, dst
|
24
|
+
puts "generated config file: #{dst}"
|
25
|
+
else
|
26
|
+
content = File.open(default_file_path) { |io| io.read }
|
27
|
+
puts content
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def gen_supervisor_conf(options)
|
32
|
+
wrapper_home = File.join ENV['GEM_HOME'], 'wrappers'
|
33
|
+
content = <<-EOS
|
34
|
+
[program:fileminer]
|
35
|
+
command=#{wrapper_home}/fileminer
|
36
|
+
autostart=true
|
37
|
+
autorestart=true
|
38
|
+
stopsinal=INT
|
39
|
+
user=root
|
40
|
+
EOS
|
41
|
+
if options.key? :out
|
42
|
+
out = options[:out]
|
43
|
+
dst = out.nil? ? './fileminer.ini' : File.absolute_path(out)
|
44
|
+
unless dst.end_with?('.ini') || dst.end_with?('.conf')
|
45
|
+
dst = File.join dst, 'fileminer.ini'
|
46
|
+
end
|
47
|
+
|
48
|
+
dst_dir = File.dirname dst
|
49
|
+
Dir.mkdirs dst_dir unless Dir.exists? dst_dir
|
50
|
+
File.open(dst, 'w') { |io| io.write content }
|
51
|
+
else
|
52
|
+
puts content
|
53
|
+
end
|
14
54
|
end
|
15
55
|
|
16
|
-
dst_dir = File.dirname dst
|
17
|
-
Dir.mkdirs dst_dir unless Dir.exist? dst_dir
|
18
56
|
|
19
|
-
|
20
|
-
|
57
|
+
options = Hash.new
|
58
|
+
OptionParser.new do |opts|
|
59
|
+
# banner
|
60
|
+
opts.banner = "Usage: fileminer-genconf [options]"
|
61
|
+
opts.separator ''
|
62
|
+
opts.separator 'Options:'
|
63
|
+
|
64
|
+
# help
|
65
|
+
opts.on_tail('-h', '--help', 'Print help') do
|
66
|
+
puts opts
|
67
|
+
puts ''
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
|
71
|
+
# type
|
72
|
+
options[:type] = :fileminer
|
73
|
+
opts.on('-t', '--type fileminer|supervisor', [:fileminer, :supervisor],
|
74
|
+
'Type of the config file to be generated', 'Default is fileminer') do |value|
|
75
|
+
options[:type] = value
|
76
|
+
end
|
77
|
+
|
78
|
+
# out
|
79
|
+
opts.on('-o', '--out [path]',
|
80
|
+
'Output content to a file',
|
81
|
+
'For type fileminer, default is /etc/fileminer/fileminer.yml',
|
82
|
+
'For type supervisor, default is ./fileminer.ini') do |value|
|
83
|
+
options[:out] = value
|
84
|
+
end
|
85
|
+
|
86
|
+
end.parse!
|
87
|
+
|
88
|
+
case options[:type]
|
89
|
+
when :fileminer
|
90
|
+
gen_fileminer_conf options
|
91
|
+
when :supervisor
|
92
|
+
gen_supervisor_conf options
|
93
|
+
end
|
data/lib/fileminer/version.rb
CHANGED
data/lib/fileminer.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
1
|
require 'logger'
|
5
2
|
require_relative 'fileminer/miner'
|
6
3
|
require_relative 'fileminer/plugins'
|
@@ -215,15 +212,3 @@ class FileMiner
|
|
215
212
|
end
|
216
213
|
|
217
214
|
end
|
218
|
-
|
219
|
-
|
220
|
-
if __FILE__ == $0
|
221
|
-
# Usage:
|
222
|
-
# ruby fileminer.rb /etc/fileminer/fileminer.yml
|
223
|
-
require 'yaml'
|
224
|
-
yml = File.open(ARGV[0]) { |io| io.read }
|
225
|
-
conf = YAML.load yml
|
226
|
-
fileminer = FileMiner.new conf
|
227
|
-
trap(:INT) { fileminer.stop_mining }
|
228
|
-
fileminer.start_mining
|
229
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileminer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0RC3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fang MinJie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple file/log transfer tool coding by ruby.
|
14
14
|
email:
|