Class: Specinfra::Helper::DetectOs::Redhat
- Inherits:
-
Specinfra::Helper::DetectOs
- Object
- Specinfra::Helper::DetectOs
- Specinfra::Helper::DetectOs::Redhat
- Defined in:
- lib/specinfra/helper/detect_os/redhat.rb
Instance Method Summary collapse
Methods inherited from Specinfra::Helper::DetectOs
detect, #initialize, #run_command
Constructor Details
This class inherits a constructor from Specinfra::Helper::DetectOs
Instance Method Details
#detect ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/specinfra/helper/detect_os/redhat.rb', line 2 def detect # Fedora also has an /etc/redhat-release so the Fedora check must # come before the RedHat check if run_command('ls /etc/fedora-release').success? line = run_command('cat /etc/redhat-release').stdout if line =~ /release (\d[\d]*)/ release = $1 end { :family => 'fedora', :release => release } elsif run_command('ls /etc/redhat-release').success? line = run_command('cat /etc/redhat-release').stdout if line =~ /release (\d[\d.]*)/ release = $1 end { :family => 'redhat', :release => release } elsif run_command('ls /etc/system-release').success? line = run_command('cat /etc/system-release').stdout if line =~ /release (\d[\d.]*)/ release = $1 elsif line =~ /Amazon Linux (\d+)/ release = $1 end { :family => 'amazon', :release => release } end end |