9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/sysutil/functions.rb', line 9
def linux_variant
r = { :distro => nil, :family => nil }
if File.exists?('/etc/lsb-release')
File.open('/etc/lsb-release', 'r').read.each_line do |line|
r = { :distro => $1 } if line =~ /^DISTRIB_ID=(.*)/
end
end
if File.exists?('/etc/debian_version')
r[:distro] = 'Debian' if r[:distro].nil?
r[:family] = 'Debian' if r[:variant].nil?
elsif File.exists?('/etc/redhat-release') or File.exists?('/etc/centos-release')
r[:family] = 'RedHat' if r[:family].nil?
r[:distro] = 'CentOS' if File.exists?('/etc/centos-release')
elsif File.exists?('/etc/SuSE-release')
r[:distro] = 'SLES' if r[:distro].nil?
end
return r
end
|