do 0.2.0.c → 0.2.0.d
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.
- data/lib/do/server.rb +14 -4
- data/lib/do/version.rb +1 -1
- metadata +4 -4
data/lib/do/server.rb
CHANGED
@@ -6,6 +6,8 @@ module DO
|
|
6
6
|
include DO::Utils
|
7
7
|
|
8
8
|
attr_reader :name, :host, :user, :role, :options
|
9
|
+
# Configuration
|
10
|
+
attr_accessor :request_pty, :hidden, :silent
|
9
11
|
|
10
12
|
##
|
11
13
|
# Initialize a new DO Server
|
@@ -20,6 +22,7 @@ module DO
|
|
20
22
|
#
|
21
23
|
def initialize(name, host, user, options={})
|
22
24
|
@name, @host, @user, @role, @options = name, host, user, options.delete(:role), options
|
25
|
+
@request_pty, @hidden, @silence = true, false, false
|
23
26
|
end
|
24
27
|
|
25
28
|
##
|
@@ -69,7 +72,12 @@ module DO
|
|
69
72
|
#
|
70
73
|
def run(*args)
|
71
74
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
72
|
-
|
75
|
+
|
76
|
+
# Set default options if not given
|
77
|
+
options[:pty] = request_pty unless options.has_key?(:pty)
|
78
|
+
options[:hidden] = hidden unless options.has_key?(:hidden)
|
79
|
+
options[:silent] = silent unless options.has_key?(:silent)
|
80
|
+
|
73
81
|
cmd = args.join(" ")
|
74
82
|
if options[:as]
|
75
83
|
if options[:as] == 'root'
|
@@ -78,20 +86,22 @@ module DO
|
|
78
86
|
cmd = "su #{options[:as]} -c '#{cmd.gsub("'", "'\\\\''")}'"
|
79
87
|
end
|
80
88
|
end
|
81
|
-
log
|
89
|
+
log(cmd) unless options[:hidden]
|
82
90
|
result = ""
|
83
91
|
ssh.open_channel do |channel|
|
84
92
|
channel.request_pty if options[:input] || options[:pty]
|
85
93
|
channel.exec cmd
|
86
94
|
channel.on_data do |c, data|
|
87
95
|
result << data
|
88
|
-
|
96
|
+
unless options[:silent] || options[:hidden]
|
97
|
+
DO_LOGGER.print(data); DO_LOGGER.flush
|
98
|
+
end
|
89
99
|
if options[:input]
|
90
100
|
match = options[:match] || /password/i
|
91
101
|
if data =~ match
|
92
102
|
options[:input] += "\n" if options[:input][-1] != ?\n
|
93
103
|
channel.send_data(options[:input])
|
94
|
-
DO_LOGGER.puts(options[:input]) unless options[:silent] || data =~ /password/i
|
104
|
+
DO_LOGGER.puts(options[:input]) unless options[:silent] || options[:hidden] || data =~ /password/i
|
95
105
|
end
|
96
106
|
end
|
97
107
|
end
|
data/lib/do/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.2.0.
|
10
|
+
- d
|
11
|
+
version: 0.2.0.d
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Davide D'Agostino
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-12-
|
19
|
+
date: 2011-12-02 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|