Class: Enterprise::Welcome

Inherits:
Object
  • Object
show all
Defined in:
lib/enterprise/scripts.rb

Constant Summary collapse

'

        _ __  __        __              __                   _
  ___ _(_) /_/ /  __ __/ /    ___ ___  / /____ _______  ____(_)__ ___
 / _ `/ / __/ _ \/ // / _ \  / -_) _ \/ __/ -_) __/ _ \/ __/ (_-</ -_)
 \_, /_/\__/_//_/\_,_/_.__/  \__/_//_/\__/\__/_/ / .__/_/ /_/___/\__/
/___/                                           /_/

'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



17
18
19
# File 'lib/enterprise/scripts.rb', line 17

def self.run
  new.run
end

Instance Method Details

#hostnameObject



61
62
63
# File 'lib/enterprise/scripts.rb', line 61

def hostname
  node['hostname']
end

#ipObject



53
54
55
# File 'lib/enterprise/scripts.rb', line 53

def ip
  node['ipaddress'] || 'X.X.X.X'
end

#macObject



57
58
59
# File 'lib/enterprise/scripts.rb', line 57

def mac
  node['macaddress'] || 'XX:XX:XX:XX:XX:XX'
end

#networkObject



65
66
67
# File 'lib/enterprise/scripts.rb', line 65

def network
  node['network']
end

#nodeObject



69
70
71
72
73
74
75
# File 'lib/enterprise/scripts.rb', line 69

def node
  @node ||= begin
    system = Ohai::System.new
    system.all_plugins
    system.data
  end
end

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/enterprise/scripts.rb', line 21

def run
  puts BANNER.green

  wait_for_ip

  puts <<-MESSAGE.gsub(/^ {6}/, '')
                     Welcome to GitHub Enterprise

  ----------------------------------------------------------------------

                        IP Address: #{ip}
                       MAC Address: #{mac}
                          Hostname: #{hostname}


    Visit http://#{ip}/setup to setup GitHub Enterprise.


  MESSAGE
end

#wait_for_ipObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/enterprise/scripts.rb', line 42

def wait_for_ip
  1.upto(5) do
    address = node['ipaddress']

    return if address.to_s =~ /^(?:\d+\.){3}\d+$/

    @node = nil
    sleep 1
  end
end