lib/rye/box.rb in rye-0.8.7 vs lib/rye/box.rb in rye-0.8.8
- old
+ new
@@ -60,11 +60,13 @@
def current_umask; @rye_current_umask; end
def info; @rye_info; end
def debug; @rye_debug; end
def error; @rye_error; end
-
+
+ def ostype=(val); @rye_ostype = val; end
+ def impltype=(val); @rye_impltype = val; end
def pre_command_hook=(val); @rye_pre_command_hook = val; end
def post_command_hook=(val); @rye_post_command_hook = val; end
# A Hash. The keys are exception classes, the values are Procs to execute
def exception_hook=(val); @rye_exception_hook = val; end
@@ -109,10 +111,11 @@
# @rye_opts gets sent to Net::SSH so we need to remove the keys
# that are not meant for it.
@rye_safe, @rye_debug = @rye_opts.delete(:safe), @rye_opts.delete(:debug)
@rye_info, @rye_error = @rye_opts.delete(:info), @rye_opts.delete(:error)
@rye_getenv = {} if @rye_opts.delete(:getenv) # Enable getenv with a hash
+ @rye_ostype, @rye_impltype = @rye_opts.delete(:ostype), @rye_opts.delete(:impltype)
@rye_quiet = @rye_opts.delete(:quiet)
# Just in case someone sends a true value rather than IO object
@rye_debug = STDERR if @rye_debug == true
@rye_error = STDERR if @rye_error == true
@@ -247,10 +250,14 @@
os ||= 'unknown'
os &&= os.downcase
@rye_ostype = os
end
+ def impltype
+ @rye_impltype
+ end
+
# Returns the hash containing the parsed output of "env" on the
# remote machine. If the initialize option +:getenv+ was set to
# false, this will return an empty hash.
# This is a lazy loaded method so it fetches the remote envvars
# the first time this method is called.
@@ -326,25 +333,28 @@
# different Linuxen and definitely won't work on Windows.
# This code will be abstracted out once I find a decent home for it.
# /etc/default/useradd, HOME=/home OR useradd -D
# /etc/adduser.config, DHOME=/home OR ??
user_defaults = {}
- raw = self.quietly { useradd(:D) } rescue ["HOME=/home"]
ostmp = self.ostype
- raw.each do |nv|
-
- if ostmp == "sunos"
- #nv.scan(/([\w_-]+?)=(.+?)\s/).each do |n, v|
- # n = 'HOME' if n == 'basedir'
- # user_defaults[n.upcase] = v.strip
- #end
- # In Solaris, useradd -D says the default home path is /home
- # but that directory is not writable. See: http://bit.ly/IJDD0
- user_defaults['HOME'] = '/export/home'
- elsif ostmp == "darwin"
- user_defaults['HOME'] = '/Users'
- else
+ ostmp &&= ostype.to_s
+
+ if ostmp == "sunos"
+ #nv.scan(/([\w_-]+?)=(.+?)\s/).each do |n, v|
+ # n = 'HOME' if n == 'basedir'
+ # user_defaults[n.upcase] = v.strip
+ #end
+ # In Solaris, useradd -D says the default home path is /home
+ # but that directory is not writable. See: http://bit.ly/IJDD0
+ user_defaults['HOME'] = '/export/home'
+ elsif ostmp == "darwin"
+ user_defaults['HOME'] = '/Users'
+ elsif ostmp == "win32"
+ user_defaults['HOME'] = 'C:/Documents and Settings'
+ else
+ raw = self.quietly { useradd(:D) } rescue ["HOME=/home"]
+ raw.each do |nv|
n, v = nv.scan(/\A([\w_-]+?)=(.+)\z/).flatten
user_defaults[n] = v
end
end
@@ -767,10 +777,10 @@
@rye_post_command_hook.call(rap)
end
rap
end
- alias :cmd :run_command
+ alias :__allow :run_command
# Takes a list of arguments appropriate for run_command or
# preview_command and returns: [cmd, args].
# Single character symbols with be converted to command line
# switches. Example: +:l+ becomes +-l+