toolrack 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/lib/toolrack.rb +10 -5
- data/lib/toolrack/process_utils.rb +3 -3
- data/lib/toolrack/version.rb +1 -1
- data/process_test/pty_test.rb +74 -0
- data/toolrack.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b1c1f58f027b8a0b847c9c196c2f2e74ba75f2df78595cb1024f06560bf8ee6
|
4
|
+
data.tar.gz: bdbb04df325bf9f979de7497051267e6925ffc74c8a91c2e49008f03c1021401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97627d8aba3e40cc3cba8f3fe3e0639f349001f548627267fca52d4ee820b8af027ebb33ae1dfff1b46f719b26d36d5aaaf4d2d7e392a918f59dc2bd4ec9e921
|
7
|
+
data.tar.gz: 932804f41294d61ceaa32eec0bdb20a8e6eb32d9abb746861cf5591ab09b29aba2980ad3b4d0508d8d2881240d91e2a64d28d83a9552cca669f3fd54521a4c90
|
data/Rakefile
CHANGED
data/lib/toolrack.rb
CHANGED
@@ -3,6 +3,8 @@ require "toolrack/version"
|
|
3
3
|
require 'tlogger'
|
4
4
|
require 'singleton'
|
5
5
|
|
6
|
+
require 'fileutils'
|
7
|
+
|
6
8
|
require_relative 'toolrack/exception_utils'
|
7
9
|
require_relative 'toolrack/condition_utils'
|
8
10
|
require_relative 'toolrack/process_utils'
|
@@ -21,16 +23,19 @@ module Antrapol
|
|
21
23
|
def initialize
|
22
24
|
# boolean
|
23
25
|
loggerDebug = ENV['TOOLRACK_DEBUG']
|
24
|
-
logFile = ENV['TOOLRACK_LOGFILE']
|
26
|
+
logFile = ENV['TOOLRACK_LOGFILE'] || File.join(Dir.home, 'antrapol_logs','toolrack.log')
|
25
27
|
maxLogNo = ENV['TOOLRACK_MAX_LOGFILE'] || 10
|
26
28
|
logFileSize = ENV['TOOLRACK_MAX_LOGFILE_SIZE'] || 10*1024*1024
|
29
|
+
|
30
|
+
logFileDir = File.dirname(logFile)
|
31
|
+
if not File.exist?(logFileDir)
|
32
|
+
FileUtils.mkdir_p(logFileDir)
|
33
|
+
end
|
27
34
|
|
28
|
-
if
|
35
|
+
if not_empty?(loggerDebug) and (loggerDebug.downcase == 'true')
|
29
36
|
@glogger = Tlogger.new(STDOUT)
|
30
|
-
elsif not is_empty?(logFile)
|
31
|
-
@glogger = Tlogger.new(logFile,maxLogNo,logFileSize)
|
32
37
|
else
|
33
|
-
@glogger = Tlogger.new(
|
38
|
+
@glogger = Tlogger.new(logFile,maxLogNo,logFileSize)
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -13,13 +13,13 @@ module Antrapol
|
|
13
13
|
def exec(cmd, opts = { }, &block)
|
14
14
|
type = opts[:exec_type]
|
15
15
|
if not type.nil?
|
16
|
-
|
16
|
+
instance(type, cmd, opts, &block)
|
17
17
|
else
|
18
|
-
|
18
|
+
instance(:basic, cmd, opts, &block)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def instance(type, cmd, opts = { }, &block)
|
23
23
|
case type
|
24
24
|
when :basic
|
25
25
|
Antrapol::ToolRack::Logger.instance.glogger.debug "Basic execution"
|
data/lib/toolrack/version.rb
CHANGED
data/process_test/pty_test.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
require 'pty'
|
5
|
+
require 'expect'
|
6
|
+
|
7
|
+
#m, s = PTY.open
|
8
|
+
#r, w = IO.pipe
|
9
|
+
#
|
10
|
+
#pid = spawn("/usr/bin/openvpn --config /home/chris/.openvpn_cli/sg2-ovpn-tcp.ovpn", in: r, out: s)
|
11
|
+
#r.close
|
12
|
+
#s.close
|
13
|
+
#
|
14
|
+
#
|
15
|
+
#ret = begin
|
16
|
+
# p m.gets
|
17
|
+
# rescue Errno::EIO
|
18
|
+
# nil
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
|
22
|
+
|
23
|
+
##PTY.spawn("/usr/bin/sudo /usr/bin/openvpn --config /home/chris/.openvpn_cli/sg2-ovpn-tcp.ovpn") do |read, write, pid|
|
24
|
+
#PTY.spawn("/usr/bin/openvpn --config /home/chris/.openvpn_cli/sg2-ovpn-tcp.ovpn") do |read, write, pid|
|
25
|
+
# #read.expect(/\[sudo\] password for chris:/) { |m|
|
26
|
+
# # p m
|
27
|
+
# # puts "expect"
|
28
|
+
# # write.printf("chr1st0pher1120\n")
|
29
|
+
# #}
|
30
|
+
# #read.expect(/Username:/) { |msg|
|
31
|
+
# # puts "-- #{msg}"
|
32
|
+
# # write.printf("purevpn0s2643230\r\n")
|
33
|
+
# #}
|
34
|
+
#
|
35
|
+
# #read.expect(/no echo\)/) { |msg|
|
36
|
+
# # puts "++ #{msg}"
|
37
|
+
# # write.printf("\t@ntr@p0l.c0m\r\n")
|
38
|
+
# #}
|
39
|
+
#
|
40
|
+
# loop do
|
41
|
+
# read.expect(/\n/) { |l|
|
42
|
+
# p l
|
43
|
+
# @ln = l
|
44
|
+
# }
|
45
|
+
# break if @ln.nil?
|
46
|
+
# end
|
47
|
+
#end
|
48
|
+
|
49
|
+
read, write, pid = PTY.spawn("/usr/bin/openvpn --config /home/chris/.openvpn_cli/sg2-ovpn-tcp.ovpn")
|
50
|
+
|
51
|
+
puts "PID : #{pid}"
|
52
|
+
|
53
|
+
trap "SIGINT" do
|
54
|
+
read.close
|
55
|
+
write.close
|
56
|
+
begin
|
57
|
+
puts "Killing process"
|
58
|
+
Process.kill("HUP",pid)
|
59
|
+
puts "Kill done. Start waiting"
|
60
|
+
Process.wait(pid)
|
61
|
+
STDERR.puts "Cleanup Done!"
|
62
|
+
rescue PTY::ChildExited
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
loop do
|
67
|
+
read.expect(/\n/) do |l|
|
68
|
+
puts l
|
69
|
+
@ln = l
|
70
|
+
end
|
71
|
+
break if @ln.nil?
|
72
|
+
end
|
73
|
+
|
74
|
+
|
data/toolrack.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toolrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tlogger
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.21'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: devops_helper
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
27
41
|
description: Just collections of utilities
|
28
42
|
email:
|
29
43
|
- chrisliaw@antrapol.com
|