Module: Train::Extras::DetectUnix
- Included in:
- OSCommon
- Defined in:
- lib/train/extras/os_detect_unix.rb
Instance Method Summary collapse
-
#detect_solaris ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity.
-
#detect_via_uname ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#detect_solaris ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/train/extras/os_detect_unix.rb', line 53 def detect_solaris # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity # read specific os name # DEPRECATED: os[:family] is going to be deprecated, use os.solaris? rel = get_config('/etc/release') if /^.*(SmartOS).*$/ =~ rel @platform[:name] = 'smartos' @platform[:family] = 'smartos' elsif !(m = /^\s*(OmniOS).*r(\d+).*$/.match(rel)).nil? @platform[:name] = 'omnios' @platform[:family] = 'omnios' @platform[:release] = m[2] elsif !(m = /^\s*(OpenIndiana).*oi_(\d+).*$/.match(rel)).nil? @platform[:name] = 'openindiana' @platform[:family] = 'openindiana' @platform[:release] = m[2] elsif /^\s*(OpenSolaris).*snv_(\d+).*$/ =~ rel @platform[:name] = 'opensolaris' @platform[:family] = 'opensolaris' @platform[:release] = m[2] elsif !(m = /Oracle Solaris (\d+)/.match(rel)).nil? # TODO: should be string! @platform[:release] = m[1] @platform[:name] = 'solaris' @platform[:family] = 'solaris' elsif /^\s*(Solaris)\s.*$/ =~ rel @platform[:name] = 'solaris' @platform[:family] = 'solaris' elsif /^\s*(NexentaCore)\s.*$/ =~ rel @platform[:name] = 'nexentacore' @platform[:family] = 'nexentacore' else # unknown solaris @platform[:name] = 'solaris_distro' @platform[:family] = 'solaris' end # read release version unless (version = /^5\.(?<release>\d+)$/.match(uname_r)).nil? @platform[:release] = version['release'] end # read architecture arch = @backend.run_command('uname -p') @platform[:arch] = arch.stdout.chomp if arch.exit_status == 0 end |
#detect_via_uname ⇒ Object
rubocop:disable Metrics/AbcSize
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/train/extras/os_detect_unix.rb', line 13 def detect_via_uname # rubocop:disable Metrics/AbcSize case uname_s.downcase when /aix/ @platform[:family] = 'aix' out = @backend.run_command('uname -rvp').stdout m = out.match(/(\d+)\s+(\d+)\s+(.*)/) unless m.nil? @platform[:release] = "#{m[2]}.#{m[1]}" @platform[:arch] = m[3].to_s end when /hp-ux/ @platform[:family] = 'hpux' @platform[:name] = uname_s.lines[0].chomp @platform[:release] = uname_r.lines[0].chomp when /freebsd/ @platform[:family] = 'freebsd' @platform[:name] = uname_s.lines[0].chomp @platform[:release] = uname_r.lines[0].chomp when /netbsd/ @platform[:family] = 'netbsd' @platform[:name] = uname_s.lines[0].chomp @platform[:release] = uname_r.lines[0].chomp when /openbsd/ @platform[:family] = 'openbsd' @platform[:name] = uname_s.lines[0].chomp @platform[:release] = uname_r.lines[0].chomp when /sunos/ detect_solaris else # in all other cases we didn't detect it return false end # when we get here the detection returned a result true end |