Sha256: 95316c5afb02b44ab099a499b350bac6f4dbc5a7e83186d100db0dda2dad8acc

Contents?: true

Size: 1.48 KB

Versions: 95

Compression:

Stored size: 1.48 KB

Contents

require 'facter/util/file_read'
require 'facter/operatingsystem/base'

module Facter
  module Operatingsystem
    class SunOS < Base
      def get_operatingsystem
        output = Facter::Core::Execution.exec('uname -v')
        if output =~ /^joyent_/
          "SmartOS"
        elsif output =~ /^oi_/
          "OpenIndiana"
        elsif output =~ /^omnios-/
          "OmniOS"
        elsif FileTest.exists?("/etc/debian_version")
          "Nexenta"
        else
          "Solaris"
        end
      end

      def get_osfamily
        "Solaris"
      end

      def get_operatingsystemrelease
        if release = Facter::Util::FileRead.read('/etc/release')
          line = release.split("\n").first

          # Solaris 10: Solaris 10 10/09 s10x_u8wos_08a X86
          # Solaris 11 (old naming scheme): Oracle Solaris 11 11/11 X86
          # Solaris 11 (new naming scheme): Oracle Solaris 11.1 SPARC
          if match = /\s+s(\d+)[sx]?(_u\d+)?.*(?:SPARC|X86)/.match(line)
            match.captures.join('')
          elsif match = /Solaris ([0-9\.]+(?:\s*[0-9\.\/]+))\s*(?:SPARC|X86)/.match(line)
            match.captures[0]
          else
            Facter[:kernelrelease].value
          end
        else
          Facter[:kernelrelease].value
        end
      end

      def get_operatingsystemmajorrelease
        if get_operatingsystem == "Solaris"
          if match = get_operatingsystemrelease.match(/^(\d+)/)
            match.captures[0]
          end
        end
      end
    end
  end
end

Version data entries

95 entries across 95 versions & 2 rubygems

Version Path
facter-2.5.7 lib/facter/operatingsystem/sunos.rb
facter-2.5.7-x86-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.7-x64-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.7-universal-darwin lib/facter/operatingsystem/sunos.rb
facter-2.5.6-x86-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.6-x64-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.6-universal-darwin lib/facter/operatingsystem/sunos.rb
facter-2.5.6 lib/facter/operatingsystem/sunos.rb
facter-2.5.5-x86-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.5-x64-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.5-universal-darwin lib/facter/operatingsystem/sunos.rb
facter-2.5.5 lib/facter/operatingsystem/sunos.rb
facter-2.5.4-x86-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.4-x64-mingw32 lib/facter/operatingsystem/sunos.rb
facter-2.5.4-universal-darwin lib/facter/operatingsystem/sunos.rb
facter-2.5.4 lib/facter/operatingsystem/sunos.rb
bolt-0.24.0 vendored/facter/lib/facter/operatingsystem/sunos.rb
bolt-0.23.0 vendored/facter/lib/facter/operatingsystem/sunos.rb
bolt-0.22.0 vendored/facter/lib/facter/operatingsystem/sunos.rb
bolt-0.21.8 vendored/facter/lib/facter/operatingsystem/sunos.rb