summaryrefslogtreecommitdiff
path: root/lib/facter/efibootmgr.rb
blob: f4a03f45fcc31634ee008711596bf60eee89827b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
if Facter::Core::Execution.which('efibootmgr') do
  Facter.add('efi') do
    setcode do
      out = {}
      data = Facter::Core::Execution.execute('efibootmgr')
      boots = {}
      data.split("\n").each do |item|
        if a = item.match(/BootOrder: (.*)/) then
          out['BootOrder'] = a[1].split(',')
        elsif a = item.match(/(\w*): (.*)/) then
          out[a[1]] = a[2]
        elsif a = item.match(/Boot(\d*)(\*?) (.*)/)
          # a[2] contains if it's active
          boots[a[1]] = a[3]
        end
      end
      out['boots'] = boots
      out
    end
  end
end