diff options
author | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-09-14 21:17:33 +0000 |
---|---|---|
committer | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-09-14 21:17:33 +0000 |
commit | 610fb5d3a576119f644d82285532915261fc7bf0 (patch) | |
tree | e46d9beb844e1a2e1be3112b9fa3855b1241c7e2 | |
parent | 356925372168165994d71b1254a23ab2de6b5bcf (diff) | |
download | facter-610fb5d3a576119f644d82285532915261fc7bf0.tar.gz facter-610fb5d3a576119f644d82285532915261fc7bf0.tar.xz facter-610fb5d3a576119f644d82285532915261fc7bf0.zip |
Applying patch in #23.
git-svn-id: http://reductivelabs.com/svn/facter/trunk@163 1f5c1d6a-bddf-0310-8f58-fc49e503516a
-rw-r--r-- | lib/facter.rb | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/lib/facter.rb b/lib/facter.rb index e147e10..d81c61c 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -840,7 +840,7 @@ class Facter end Facter.add("MacAddress") do - confine :operatingsystem => :solaris + confine :operatingsystem => %w{FreeBSD NetBSD OpenBSD solaris} setcode do ether = nil output = %x{/sbin/ifconfig -a} @@ -867,9 +867,43 @@ class Facter ether end + + Facter.add("MacAddress") do + confine :kernel => :linux + setcode do + ether = nil + output = %x{/sbin/ifconfig -a} + + output =~ /HWaddr (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ + ether = $1 + + ether + end + end + + + Facter.add("IPAddress") do + confine :kernel => :linux + setcode do + ip = nil + output = %x{/sbin/ifconfig} + + output.split(/^\S/).each { |str| + if str =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ + tmp = $1 + unless tmp =~ /127\./ + ip = tmp + break + end + end + } + + ip + end + end end Facter.add("IPAddress") do - confine :kernel => :darwin + confine :kernel => %w{FreeBSD NetBSD OpenBSD solaris darwin} setcode do ip = nil output = %x{/sbin/ifconfig} |