Added fact which determines if console is serial or vga.
This commit is contained in:
parent
f91faebb7e
commit
340bf65d56
1 changed files with 30 additions and 0 deletions
30
custom/plugins/facter/console_type.rb
Normal file
30
custom/plugins/facter/console_type.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
Facter.add('console_type') do
|
||||||
|
setcode do
|
||||||
|
begin
|
||||||
|
Facter.kernel
|
||||||
|
rescue
|
||||||
|
Facter.loadfacts()
|
||||||
|
end
|
||||||
|
console = 'vga'
|
||||||
|
kernel = Facter.value('kernel')
|
||||||
|
if kernel == 'Linux'
|
||||||
|
File.open('/proc/cmdline', 'r') do |f|
|
||||||
|
while line = f.gets
|
||||||
|
if line =~ /console=ttyS[0-9]/
|
||||||
|
console = 'serial'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elsif kernel == 'OpenBSD'
|
||||||
|
File.open('/etc/boot.conf', 'r') do |f|
|
||||||
|
while line = f.gets
|
||||||
|
if line =~ /^set tty com[0-9]$/
|
||||||
|
console = 'serial'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
console
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue