rye 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -2,9 +2,17 @@ RYE, CHANGES
2
2
 
3
3
  TODO
4
4
 
5
+ * Re-implement Rye::Rap as an Observable StringIO object for dynamic printing of output.
5
6
  * Fingerprints: ssh-keygen -l -f id_rsa_repos.pub
6
7
 
7
8
 
9
+ #### 0.6.3 (2009-05-02) #############################
10
+
11
+ * FIXED: Rye::Box.guess_user_home wasn't handling the username arg (only using default name)
12
+ * ADDED: Rye::Cmd.can?
13
+ * ADDED: Rye::Cmd.ostype
14
+
15
+
8
16
  #### 0.6.2 (2009-04-29) #############################
9
17
 
10
18
  * FIXED: I forgot to add highline to the gemspec file manifest. Cripes!
data/bin/rye CHANGED
@@ -41,16 +41,18 @@ option :u, :user, String, "Username"
41
41
  argv :hostname
42
42
  command :authorize do |obj|
43
43
  raise "You must specify a host" unless obj.argv.hostname
44
+ user = Rye.sysinfo.user
44
45
 
45
46
  opts = { :debug => nil, :auth_methods => %w(publickey hostbased) }
46
47
  opts[:user] = obj.option.user if obj.option.user
48
+ opts[:user] ||= user
47
49
 
48
50
  obj.argv.each do |hostname|
49
51
 
50
- puts "Authorizing #{obj.option.user}@#{hostname}"
52
+ puts "Authorizing #{opts[:user]}@#{hostname}"
51
53
  rbox = Rye::Box.new(hostname, opts)
52
54
  puts "Added public keys for: ", rbox.authorize_keys_remote
53
- puts "Now try: " << "ssh #{obj.option.user}@#{hostname}"
55
+ puts "Now try: " << "ssh #{opts[:user]}@#{hostname}"
54
56
 
55
57
  end
56
58
 
@@ -60,6 +62,7 @@ command_alias :authorize, :authorise
60
62
  about "Add your public keys to your current account on this machine"
61
63
  command :authorize_local do |obj|
62
64
  user = Rye.sysinfo.user
65
+
63
66
  puts "Authorizing #{user}@localhost"
64
67
  rbox = Rye::Box.new('localhost')
65
68
  puts "Added public keys for: ", rbox.authorize_keys_local
data/bin/try CHANGED
@@ -194,7 +194,7 @@ p rbox.cat("#{dir_upload}/applejack.txt") # => "Some in-memory content"
194
194
 
195
195
  filecontent = StringIO.new
196
196
  rbox.download("#{dir_upload}/applejack.txt", filecontent)
197
-
197
+ filecontent.rewind
198
198
  p filecontent.read
199
199
 
200
200
 
data/lib/rye/box.rb CHANGED
@@ -301,10 +301,17 @@ module Rye
301
301
  Rye.remote_host_keys(@host)
302
302
  end
303
303
 
304
+
304
305
  # Uses the output of "useradd -D" to determine the default home
305
306
  # directory. This returns a GUESS rather than the a user's real
306
307
  # home directory. Currently used only by authorize_keys_remote.
307
308
  def guess_user_home(other_user=nil)
309
+ this_user = other_user || opts[:user]
310
+ @guessed_homes ||= {}
311
+
312
+ # A simple cache.
313
+ return @guessed_homes[this_user] if @guessed_homes.has_key?(this_user)
314
+
308
315
  # Some junk to determine where user home directories are by default.
309
316
  # We're relying on the command "useradd -D" so this may not work on
310
317
  # different Linuxen and definitely won't work on Windows.
@@ -314,10 +321,22 @@ module Rye
314
321
  user_defaults = {}
315
322
  raw = self.useradd(:D) rescue ["HOME=/home"]
316
323
  raw.each do |nv|
317
- n, v = nv.scan(/\A([\w_-]+?)=(.+)\z/).flatten
318
- user_defaults[n] = v
324
+
325
+ if self.ostype == "sunos"
326
+ #nv.scan(/([\w_-]+?)=(.+?)\s/).each do |n, v|
327
+ # n = 'HOME' if n == 'basedir'
328
+ # user_defaults[n.upcase] = v.strip
329
+ #end
330
+ # In Solaris, useradd -D says the default home path is /home
331
+ # but that directory is not writable. See: http://bit.ly/IJDD0
332
+ user_defaults['HOME'] = '/export/home'
333
+ else
334
+ n, v = nv.scan(/\A([\w_-]+?)=(.+)\z/).flatten
335
+ user_defaults[n] = v
336
+ end
319
337
  end
320
- "#{user_defaults['HOME']}/#{other_user}"
338
+
339
+ @guessed_homes[this_user] = "#{user_defaults['HOME']}/#{this_user}"
321
340
  end
322
341
 
323
342
  # Copy the local public keys (as specified by Rye.keys) to
@@ -402,7 +421,7 @@ module Rye
402
421
  # A handler for undefined commands.
403
422
  # Raises Rye::CommandNotFound exception.
404
423
  def method_missing(meth, *args, &block)
405
- raise Rye::CommandNotFound, "#{meth.to_s} (args: #{args.join(' ')})"
424
+ raise Rye::CommandNotFound, "#{meth.to_s}"
406
425
  end
407
426
  def preview_command(*args)
408
427
  prep_args(*args).join(' ')
@@ -481,6 +500,10 @@ module Rye
481
500
  rap.exit_signal = esignal
482
501
  rap.cmd = cmd
483
502
 
503
+ # It seems a convention for various commands to return -1
504
+ # when something only mildly concerning happens. ls even
505
+ # returns -1 for apparently no reason sometimes. In any
506
+ # case, the real errors are the ones greater than zero
484
507
  raise Rye::CommandError.new(rap) if ecode > 0
485
508
 
486
509
  rap
data/lib/rye/cmd.rb CHANGED
@@ -109,6 +109,17 @@ module Rye;
109
109
  ret.stderr.empty?
110
110
  end
111
111
 
112
+ # Return the value of uname in lowercase
113
+ # This is a temporary fix. We can use SysInfo for this, upload
114
+ # it, execute it directly, parse the output.
115
+ def ostype
116
+ return @ostype if @ostype # simple cache
117
+ os = self.uname.first rescue nil
118
+ os ||= 'unknown'
119
+ os &&= os.downcase
120
+ @ostype = os
121
+ end
122
+
112
123
  # Returns the hash containing the parsed output of "env" on the
113
124
  # remote machine. If the initialize option +:getenv+ was set to
114
125
  # false, this will return an empty hash.
@@ -117,6 +128,9 @@ module Rye;
117
128
  #
118
129
  # puts rbox.getenv['HOME'] # => "/home/gloria" (remote)
119
130
  #
131
+ # NOTE: This method should not raise an exception under normal
132
+ # circumstances.
133
+ #
120
134
  def getenv
121
135
  if @getenv && @getenv.empty? && self.can?(:env)
122
136
  env = self.env rescue []
@@ -143,7 +157,9 @@ module Rye;
143
157
  alias :command? :can?
144
158
  alias :cmd? :can?
145
159
 
146
-
160
+ def Cmd.can?(meth)
161
+ instance_methods.member?(meth)
162
+ end
147
163
 
148
164
  #--
149
165
  # * Consider a lock-down mode using method_added
data/lib/sys.rb CHANGED
@@ -295,3 +295,8 @@ class SystemInfo #:nodoc:all
295
295
 
296
296
 
297
297
  end
298
+
299
+
300
+ if $0 == __FILE__
301
+ puts SystemInfo.new.to_yaml
302
+ 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.6.2"
4
+ s.version = "0.6.3"
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.6.2
4
+ version: 0.6.3
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-04-29 00:00:00 -04:00
12
+ date: 2009-05-02 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency