Method: Unix::Exec#ssh_set_user_environment

Defined in:
lib/beaker/host/unix/exec.rb

#ssh_set_user_environment(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fills the user SSH environment file.

Parameters:

  • env (Hash{String=>String})

    Environment variables to set on the system, in the form of a hash of String variable names to their corresponding String values.

Returns:

  • nil



388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/beaker/host/unix/exec.rb', line 388

def ssh_set_user_environment(env)
  # ensure that ~/.ssh/environment exists
  ssh_env_file_dir = Pathname.new(self[:ssh_env_file]).dirname
  mkdir_p(ssh_env_file_dir)
  exec(Beaker::Command.new("chmod 0600 #{ssh_env_file_dir}"))
  exec(Beaker::Command.new("touch #{self[:ssh_env_file]}"))
  # add the constructed env vars to this host
  add_env_var('PATH', '$PATH')
  if self['platform'].variant == 'openbsd'
    arch = self['platform'].arch
    arch = 'amd64' if %w[x64 x86_64].include?(arch)
    add_env_var('PKG_PATH', "http://ftp.openbsd.org/pub/OpenBSD/#{self['platform'].version}/packages/#{arch}/")
  elsif self['platform'].include?('solaris-10')
    add_env_var('PATH', '/opt/csw/bin')
  end

  # add the env var set to this test host
  env.each_pair do |var, value|
    add_env_var(var, value)
  end
end