Module: OS::Linux

Extended by:
T::Sig
Defined in:
os/linux.rb,
os/linux/glibc.rb,
os/linux/kernel.rb

Overview

Helper module for querying system information on Linux.

Defined Under Namespace

Modules: Glibc, Kernel

Class Method Summary collapse

Class Method Details

.os_versionString

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'os/linux.rb', line 12

def os_version
  if which("lsb_release")
    lsb_info = Utils.popen_read("lsb_release", "-a")
    description = lsb_info[/^Description:\s*(.*)$/, 1]
    codename = lsb_info[/^Codename:\s*(.*)$/, 1]
    if codename.blank? || (codename == "n/a")
      description
    else
      "#{description} (#{codename})"
    end
  elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable?
    redhat_release.read.chomp
  else
    "Unknown"
  end
end