module Mac::Exec

Public Instance Methods

modified_at(file, timestamp = nil) click to toggle source

Update ModifiedDate on a file @param [String] file Path to the file @param [String] timestamp Timestamp to set

# File lib/beaker/host/mac/exec.rb, line 41
def modified_at(file, timestamp = nil)
  require 'date'
  time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
  timestamp = time.strftime('%Y%m%d%H%M')
  execute("touch -mt #{timestamp} #{file}")
end
selinux_enabled?() click to toggle source

 Checks if selinux is enabled selinux is not availble on OS X

@return [Boolean] false

# File lib/beaker/host/mac/exec.rb, line 34
def selinux_enabled?
  false
end
ssh_permit_user_environment() click to toggle source

Sets the PermitUserEnvironment setting & restarts the SSH service

@api private @return [Result] result of the command starting the SSH service

(from {#ssh_service_restart})
# File lib/beaker/host/mac/exec.rb, line 22
def ssh_permit_user_environment
  ssh_config_file = '/etc/sshd_config'
  ssh_config_file = '/private/etc/ssh/sshd_config' if /^osx-/.match?(self['platform'])

  exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> #{ssh_config_file}"))
  ssh_service_restart
end
ssh_service_restart() click to toggle source

Restarts the SSH service

@return [Result] result of starting SSH service

# File lib/beaker/host/mac/exec.rb, line 11
def ssh_service_restart
  launch_daemons_plist = '/System/Library/LaunchDaemons/ssh.plist'
  exec(Beaker::Command.new("launchctl unload #{launch_daemons_plist}"))
  exec(Beaker::Command.new("launchctl load #{launch_daemons_plist}"))
end
touch(file, abs = true) click to toggle source
# File lib/beaker/host/mac/exec.rb, line 4
def touch(file, abs = true)
  (abs ? '/usr/bin/touch' : 'touch') + " #{file}"
end