rye 0.8.7 → 0.8.8
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/CHANGES.txt +8 -0
- data/bin/try +1 -1
- data/lib/rye.rb +1 -1
- data/lib/rye/box.rb +26 -16
- data/lib/rye/cmd.rb +85 -68
- data/rye.gemspec +1 -1
- metadata +2 -2
data/CHANGES.txt
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
RYE, CHANGES
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
#### 0.8.8 (2009-08-25) #############################
|
|
5
|
+
|
|
6
|
+
* FIXED: Rye::Box#guess_user_home for Windows SSH support
|
|
7
|
+
* CHANGE: Renamed Rye::Box#cmd -> Rye::Box#__allow
|
|
8
|
+
* ADDED: New whitelist commands: wget, curl, dir
|
|
9
|
+
* ADDED: Rye::Box#file_write
|
|
10
|
+
|
|
11
|
+
|
|
4
12
|
#### 0.8.7 (2009-08-11) #############################
|
|
5
13
|
|
|
6
14
|
* FIXED: Rye::Box info level output is cleaner
|
data/bin/try
CHANGED
|
@@ -179,7 +179,7 @@ rbox = Rye::Box.new("localhost", :info => false)
|
|
|
179
179
|
|
|
180
180
|
# Rye ships without an rm method (for safety!). Here
|
|
181
181
|
# we add the rm method only to this instance of rbox.
|
|
182
|
-
def rbox.rm(*args);
|
|
182
|
+
def rbox.rm(*args); __allow('rm', args); end
|
|
183
183
|
|
|
184
184
|
rbox.rm(:r, :f, dir_upload) # Silently delete test dirs
|
|
185
185
|
rbox.rm(:r, :f, dir_download)
|
data/lib/rye.rb
CHANGED
data/lib/rye/box.rb
CHANGED
|
@@ -62,7 +62,9 @@ module Rye
|
|
|
62
62
|
def info; @rye_info; end
|
|
63
63
|
def debug; @rye_debug; end
|
|
64
64
|
def error; @rye_error; end
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
def ostype=(val); @rye_ostype = val; end
|
|
67
|
+
def impltype=(val); @rye_impltype = val; end
|
|
66
68
|
def pre_command_hook=(val); @rye_pre_command_hook = val; end
|
|
67
69
|
def post_command_hook=(val); @rye_post_command_hook = val; end
|
|
68
70
|
# A Hash. The keys are exception classes, the values are Procs to execute
|
|
@@ -111,6 +113,7 @@ module Rye
|
|
|
111
113
|
@rye_safe, @rye_debug = @rye_opts.delete(:safe), @rye_opts.delete(:debug)
|
|
112
114
|
@rye_info, @rye_error = @rye_opts.delete(:info), @rye_opts.delete(:error)
|
|
113
115
|
@rye_getenv = {} if @rye_opts.delete(:getenv) # Enable getenv with a hash
|
|
116
|
+
@rye_ostype, @rye_impltype = @rye_opts.delete(:ostype), @rye_opts.delete(:impltype)
|
|
114
117
|
@rye_quiet = @rye_opts.delete(:quiet)
|
|
115
118
|
|
|
116
119
|
# Just in case someone sends a true value rather than IO object
|
|
@@ -249,6 +252,10 @@ module Rye
|
|
|
249
252
|
@rye_ostype = os
|
|
250
253
|
end
|
|
251
254
|
|
|
255
|
+
def impltype
|
|
256
|
+
@rye_impltype
|
|
257
|
+
end
|
|
258
|
+
|
|
252
259
|
# Returns the hash containing the parsed output of "env" on the
|
|
253
260
|
# remote machine. If the initialize option +:getenv+ was set to
|
|
254
261
|
# false, this will return an empty hash.
|
|
@@ -328,21 +335,24 @@ module Rye
|
|
|
328
335
|
# /etc/default/useradd, HOME=/home OR useradd -D
|
|
329
336
|
# /etc/adduser.config, DHOME=/home OR ??
|
|
330
337
|
user_defaults = {}
|
|
331
|
-
raw = self.quietly { useradd(:D) } rescue ["HOME=/home"]
|
|
332
338
|
ostmp = self.ostype
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
339
|
+
ostmp &&= ostype.to_s
|
|
340
|
+
|
|
341
|
+
if ostmp == "sunos"
|
|
342
|
+
#nv.scan(/([\w_-]+?)=(.+?)\s/).each do |n, v|
|
|
343
|
+
# n = 'HOME' if n == 'basedir'
|
|
344
|
+
# user_defaults[n.upcase] = v.strip
|
|
345
|
+
#end
|
|
346
|
+
# In Solaris, useradd -D says the default home path is /home
|
|
347
|
+
# but that directory is not writable. See: http://bit.ly/IJDD0
|
|
348
|
+
user_defaults['HOME'] = '/export/home'
|
|
349
|
+
elsif ostmp == "darwin"
|
|
350
|
+
user_defaults['HOME'] = '/Users'
|
|
351
|
+
elsif ostmp == "win32"
|
|
352
|
+
user_defaults['HOME'] = 'C:/Documents and Settings'
|
|
353
|
+
else
|
|
354
|
+
raw = self.quietly { useradd(:D) } rescue ["HOME=/home"]
|
|
355
|
+
raw.each do |nv|
|
|
346
356
|
n, v = nv.scan(/\A([\w_-]+?)=(.+)\z/).flatten
|
|
347
357
|
user_defaults[n] = v
|
|
348
358
|
end
|
|
@@ -769,7 +779,7 @@ module Rye
|
|
|
769
779
|
|
|
770
780
|
rap
|
|
771
781
|
end
|
|
772
|
-
alias :
|
|
782
|
+
alias :__allow :run_command
|
|
773
783
|
|
|
774
784
|
# Takes a list of arguments appropriate for run_command or
|
|
775
785
|
# preview_command and returns: [cmd, args].
|
data/lib/rye/cmd.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Rye;
|
|
|
11
11
|
#
|
|
12
12
|
# require 'rye'
|
|
13
13
|
# module Rye::Box::Cmd
|
|
14
|
-
# def special(*args);
|
|
14
|
+
# def special(*args); __allow("/your/special/command", args); end
|
|
15
15
|
# end
|
|
16
16
|
#
|
|
17
17
|
# rbox = Rye::Box.new('somehost')
|
|
@@ -19,73 +19,77 @@ module Rye;
|
|
|
19
19
|
#
|
|
20
20
|
module Cmd
|
|
21
21
|
|
|
22
|
-
#--
|
|
23
|
-
# TODO: Clean this trite mess up!
|
|
24
|
-
#++
|
|
25
|
-
|
|
26
22
|
# NOTE: See Rye::Box for the implementation of cd
|
|
27
|
-
#def cd(*args);
|
|
28
|
-
#def rm(*args);
|
|
29
|
-
def wc(*args);
|
|
30
|
-
def cp(*args);
|
|
31
|
-
def mv(*args);
|
|
32
|
-
def ls(*args);
|
|
33
|
-
def ps(*args);
|
|
34
|
-
def sh(*args);
|
|
35
|
-
def df(*args);
|
|
36
|
-
def du(*args);
|
|
23
|
+
#def cd(*args); __allow('cd', args); end
|
|
24
|
+
#def rm(*args); __allow('rm', args); end
|
|
25
|
+
def wc(*args); __allow('wc', args); end
|
|
26
|
+
def cp(*args); __allow("cp", args); end
|
|
27
|
+
def mv(*args); __allow("mv", args); end
|
|
28
|
+
def ls(*args); __allow('ls', args); end
|
|
29
|
+
def ps(*args); __allow('ps', args); end
|
|
30
|
+
def sh(*args); __allow('sh', args); end
|
|
31
|
+
def df(*args); __allow('df', args); end
|
|
32
|
+
def du(*args); __allow('du', args); end
|
|
33
|
+
|
|
34
|
+
def env; __allow "env"; end
|
|
35
|
+
def rye(*args); __allow "rye", args; end
|
|
36
|
+
def pwd(*args); __allow "pwd", args; end
|
|
37
|
+
def svn(*args); __allow('svn', args); end
|
|
38
|
+
def cvs(*args); __allow('cvs', args); end
|
|
39
|
+
def git(*args); __allow('git', args); end
|
|
40
|
+
def sed(*args); __allow('sed', args); end
|
|
41
|
+
def awk(*args); __allow('awk', args); end
|
|
42
|
+
def cat(*args); __allow('cat', args); end
|
|
43
|
+
def tar(*args); __allow('tar', args); end
|
|
37
44
|
|
|
38
|
-
def
|
|
39
|
-
def
|
|
40
|
-
def
|
|
41
|
-
def
|
|
42
|
-
def
|
|
43
|
-
def
|
|
44
|
-
def
|
|
45
|
-
def
|
|
46
|
-
def
|
|
47
|
-
def
|
|
45
|
+
#def kill(*args); __allow('kill', args); end
|
|
46
|
+
def rake(*args); __allow('sudo', args); end
|
|
47
|
+
def sudo(*args); __allow('sudo', args); end
|
|
48
|
+
def grep(*args); __allow('grep', args); end
|
|
49
|
+
def date(*args); __allow('date', args); end
|
|
50
|
+
def ruby(*args); __allow('ruby', args); end
|
|
51
|
+
def rudy(*args); __allow('rudy', args); end
|
|
52
|
+
def perl(*args); __allow('perl', args); end
|
|
53
|
+
def bash(*args); __allow('bash', args); end
|
|
54
|
+
def echo(*args); __allow('echo', args); end
|
|
55
|
+
def test(*args); __allow('test', args); end
|
|
56
|
+
def mkfs(*args); __allow('mkfs', args); end
|
|
57
|
+
def gzip(*args); __allow('gzip', args); end
|
|
58
|
+
def make(*args); __allow('make', args); end
|
|
59
|
+
def wget(*args); __allow('wget', args); end
|
|
60
|
+
def curl(*args); __allow('curl', args); end
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
def
|
|
51
|
-
def
|
|
52
|
-
def
|
|
53
|
-
def
|
|
54
|
-
def
|
|
55
|
-
def
|
|
56
|
-
def
|
|
57
|
-
def
|
|
58
|
-
def
|
|
59
|
-
def test(*args); cmd('test', args); end
|
|
60
|
-
def mkfs(*args); cmd('mkfs', args); end
|
|
61
|
-
def gzip(*args); cmd('gzip', args); end
|
|
62
|
-
def make(*args); cmd('make', args); end
|
|
62
|
+
def mount(*args); __allow("mount", args); end
|
|
63
|
+
def sleep(*args); __allow("sleep", args); end
|
|
64
|
+
def mkdir(*args); __allow('mkdir', args); end
|
|
65
|
+
def touch(*args); __allow('touch', args); end
|
|
66
|
+
def uname(*args); __allow('uname', args); end
|
|
67
|
+
def chmod(*args); __allow('chmod', args); end
|
|
68
|
+
def chown(*args); __allow('chown', args); end
|
|
69
|
+
def unzip(*args); __allow('unzip', args); end
|
|
70
|
+
def bzip2(*args); __allow('bzip2', args); end
|
|
71
|
+
def which(*args); __allow('which', args); end
|
|
63
72
|
|
|
64
|
-
def
|
|
65
|
-
def
|
|
66
|
-
def
|
|
67
|
-
def
|
|
68
|
-
def
|
|
69
|
-
def
|
|
70
|
-
def
|
|
71
|
-
def
|
|
72
|
-
def
|
|
73
|
-
def
|
|
73
|
+
def umount(*args); __allow("umount", args); end
|
|
74
|
+
def uptime(*args); __allow("uptime", args); end
|
|
75
|
+
def python(*args); __allow('python', args); end
|
|
76
|
+
def gunzip(*args); __allow('gunzip', args); end
|
|
77
|
+
def useradd(*args); __allow('useradd', args); end
|
|
78
|
+
def bunzip2(*args); __allow('bunzip2', args); end
|
|
79
|
+
def getconf(*args); __allow('getconf', args); end
|
|
80
|
+
def history(*args); __allow('history', args); end
|
|
81
|
+
def rudy_s3(*args); __allow('rudy-s3', args); end
|
|
82
|
+
def printenv(*args); __allow('printenv', args); end
|
|
83
|
+
def hostname(*args); __allow('hostname', args); end
|
|
84
|
+
def rudy_ec2(*args); __allow('rudy-ec2', args); end
|
|
85
|
+
def rudy_sdb(*args); __allow('rudy-sdb', args); end
|
|
86
|
+
def configure(*args); __allow('./configure', args); end
|
|
87
|
+
|
|
88
|
+
#--
|
|
89
|
+
# WINDOWS
|
|
90
|
+
#++
|
|
91
|
+
def dir(*args); __allow('cmd', args); end
|
|
74
92
|
|
|
75
|
-
def umount(*args); cmd("umount", args); end
|
|
76
|
-
def uptime(*args); cmd("uptime", args); end
|
|
77
|
-
def python(*args); cmd('python', args); end
|
|
78
|
-
def gunzip(*args); cmd('gunzip', args); end
|
|
79
|
-
def useradd(*args); cmd('useradd', args); end
|
|
80
|
-
def bunzip2(*args); cmd('bunzip2', args); end
|
|
81
|
-
def getconf(*args); cmd('getconf', args); end
|
|
82
|
-
def history(*args); cmd('history', args); end
|
|
83
|
-
def rudy_s3(*args); cmd('rudy-s3', args); end
|
|
84
|
-
def printenv(*args); cmd('printenv', args); end
|
|
85
|
-
def hostname(*args); cmd('hostname', args); end
|
|
86
|
-
def rudy_ec2(*args); cmd('rudy-ec2', args); end
|
|
87
|
-
def rudy_sdb(*args); cmd('rudy-sdb', args); end
|
|
88
|
-
def configure(*args); cmd('./configure', args); end
|
|
89
93
|
|
|
90
94
|
# Transfer files to a machine via Net::SCP.
|
|
91
95
|
# * +paths+ is an Array of files to upload. The last element is the
|
|
@@ -151,15 +155,28 @@ module Rye;
|
|
|
151
155
|
file_content = self.file_download filepath
|
|
152
156
|
end
|
|
153
157
|
|
|
154
|
-
|
|
158
|
+
content ||= StringIO.new
|
|
155
159
|
if newcontent.is_a?(StringIO)
|
|
156
160
|
newcontent.rewind
|
|
157
|
-
|
|
161
|
+
content.puts newcontent.read
|
|
158
162
|
else
|
|
159
|
-
|
|
163
|
+
content.puts newcontent
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
self.file_upload content, filepath
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Write +newcontent+ to remote +filepath+. If the file exists
|
|
170
|
+
# it will be overwritten. If +backup+ is specified, +filepath+
|
|
171
|
+
# will be copied to +filepath-previous+ before appending.
|
|
172
|
+
def file_write(filepath, newcontent, backup=false)
|
|
173
|
+
if self.file_exists?(filepath)
|
|
174
|
+
self.cp filepath, "#{filepath}-previous" if backup
|
|
160
175
|
end
|
|
161
176
|
|
|
162
|
-
|
|
177
|
+
content = StringIO.new
|
|
178
|
+
content.puts newcontent
|
|
179
|
+
self.file_upload content, filepath
|
|
163
180
|
end
|
|
164
181
|
|
|
165
182
|
#--
|
|
@@ -252,7 +269,7 @@ module Rye;
|
|
|
252
269
|
define_method(meth) do |*args|
|
|
253
270
|
local_args = hard_args.clone
|
|
254
271
|
local_args += args
|
|
255
|
-
|
|
272
|
+
__allow(path, *local_args)
|
|
256
273
|
end
|
|
257
274
|
end
|
|
258
275
|
end
|
data/rye.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
|
2
2
|
s.name = "rye"
|
|
3
3
|
s.rubyforge_project = "rye"
|
|
4
|
-
s.version = "0.8.
|
|
4
|
+
s.version = "0.8.8"
|
|
5
5
|
s.summary = "Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby)."
|
|
6
6
|
s.description = s.summary
|
|
7
7
|
s.author = "Delano Mandelbaum"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rye
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Delano Mandelbaum
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-08-
|
|
12
|
+
date: 2009-08-26 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|