Module: Xilinx::Provision::Udev

Defined in:
lib/xilinx/provision/udev.rb

Overview

Runs the impact tool.

Class Method Summary collapse

Class Method Details

.add_rules(rules, group_name) ⇒ Object

Installs a group of udev rules.



12
13
14
15
16
17
# File 'lib/xilinx/provision/udev.rb', line 12

def self.add_rules(rules, group_name)
  file = File.join rules_path, group_name + '.rules'
  File.open file, 'w' do |f|
    f.write rules.map { |rule| rule + "\n" }.join
  end
end

.reload_rulesObject

Asks udev to reload its rules to reflect updates done by add_rules.

Returns a false value for success, or a string containing error output if something goes wrong.



29
30
31
32
# File 'lib/xilinx/provision/udev.rb', line 29

def self.reload_rules
  output = `/etc/init.d/udev restart 2>&1`
  $CHILD_STATUS.to_i == 0 ? nil : output
end

.remove_rules(group_name) ⇒ Object

Removes a group of udev rules.



20
21
22
23
# File 'lib/xilinx/provision/udev.rb', line 20

def self.remove_rules(group_name)
  file = File.join rules_path, group_name + '.rules'
  File.unlink file if File.exist?(file)
end

.rules_pathObject

Directory or file containing the udev rules.



35
36
37
38
39
40
41
# File 'lib/xilinx/provision/udev.rb', line 35

def self.rules_path
  if File.exist? '/etc/udev/rules.d'
    return '/etc/udev/rules.d'
  else
    raise "Unsupported OS or distribution."
  end
end