diff options
author | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-09-29 16:12:00 +0000 |
---|---|---|
committer | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-09-29 16:12:00 +0000 |
commit | 4339b46558cf861ad3b5a52fa41cb2adf4e53e85 (patch) | |
tree | 1fdd5380f66557e4620fb3586877a184f4d80ca1 | |
parent | 82fd8900ae442676e50a4d5dc8cace84ca05031d (diff) | |
download | facter-4339b46558cf861ad3b5a52fa41cb2adf4e53e85.tar.gz facter-4339b46558cf861ad3b5a52fa41cb2adf4e53e85.tar.xz facter-4339b46558cf861ad3b5a52fa41cb2adf4e53e85.zip |
Fixing #26 -- using Resolution.exec instead of executing directly, and also calling lsb_release for every fact, instead of just once at startup
git-svn-id: http://reductivelabs.com/svn/facter/trunk@177 1f5c1d6a-bddf-0310-8f58-fc49e503516a
-rw-r--r-- | lib/facter.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/facter.rb b/lib/facter.rb index cc340d4..012dfb3 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -608,20 +608,23 @@ class Facter setcode 'uname -r' end - {"LSBRelease" => "^LSB Version:\t(.*)$", "LSBDistId" => "^Distributor ID:\t(.*)$", - "LSBDistRelease" => "^Release:\t(.*)$", "LSBDistDescription" => "^Description:\t(.*)$", - "LSBDistCodeName" => "^Codename:\t(.*)$"}.each { |fact, pattern| - output = %x{lsb_release -a 2>&1} - if $? == 0 - Facter.add(fact) do - setcode do - if $? == 0 and output =~ /#{pattern}/ - $1 - end + { "LSBRelease" => "^LSB Version:\t(.*)$", + "LSBDistId" => "^Distributor ID:\t(.*)$", + "LSBDistRelease" => "^Release:\t(.*)$", + "LSBDistDescription" => "^Description:\t(.*)$", + "LSBDistCodeName" => "^Codename:\t(.*)$" + }.each do |fact, pattern| + Facter.add(fact) do + setcode do + output = Resolution.exec('lsb_release -a 2>/dev/null') + if output =~ /#{pattern}/ + $1 + else + nil end - end # end of add + end end - } + end Facter.add("OperatingSystem") do # Default to just returning the kernel as the operating system |