summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-05 16:25:36 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-03 18:55:01 +0100
commit7bc240c0750fcffa36f5c8df234542578b20ae1f (patch)
treeca98ffab0bac1e632a138c755c4fe9318046c8fb /lib
downloadsyslinux-7bc240c0750fcffa36f5c8df234542578b20ae1f.tar.gz
syslinux-7bc240c0750fcffa36f5c8df234542578b20ae1f.tar.xz
Setup syslinux.
Diffstat (limited to 'lib')
-rw-r--r--lib/facter/blkid.rb17
-rw-r--r--lib/facter/efibootmgr.rb19
-rw-r--r--lib/facter/partid.rb16
3 files changed, 52 insertions, 0 deletions
diff --git a/lib/facter/blkid.rb b/lib/facter/blkid.rb
new file mode 100644
index 0000000..79c6135
--- /dev/null
+++ b/lib/facter/blkid.rb
@@ -0,0 +1,17 @@
+Facter.add('blkid') do
+ setcode do
+ lines = Facter::Core::Execution.execute('blkid').split("\n")
+ out = {}
+ lines.each do |line|
+ a = line.match(/^([^:]*): (.*)/)
+ d = {}
+ a[2].split(' ').each do |pair|
+ m = pair.match(/(\w*)="(([^"]|\\")*)"/)
+ d[m[1]] = m[2]
+ end
+ out[a[1]] = d
+ end
+ out
+ end
+end
+
diff --git a/lib/facter/efibootmgr.rb b/lib/facter/efibootmgr.rb
new file mode 100644
index 0000000..fdf95e0
--- /dev/null
+++ b/lib/facter/efibootmgr.rb
@@ -0,0 +1,19 @@
+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
diff --git a/lib/facter/partid.rb b/lib/facter/partid.rb
new file mode 100644
index 0000000..53fc37c
--- /dev/null
+++ b/lib/facter/partid.rb
@@ -0,0 +1,16 @@
+Facter.add('partinfo') do
+ setcode do
+ obj = {}
+ Dir.entries('/sys/class/block/').each do |entry|
+ if entry == '.' or entry == '..' then next end
+ path = "/sys/class/block/#{entry}/partition"
+ if File.file?(path) then
+ obj[entry] = {
+ 'partid' => File.read(path).strip(),
+ 'device' => File.basename(File.dirname(File.readlink("/sys/class/block/#{entry}"))),
+ }
+ end
+ end
+ obj
+ end
+end