Class: Bixby::Help::SystemTime

Inherits:
Object
  • Object
show all
Extended by:
Script::Distro, Script::Platform
Defined in:
lib/bixby-agent/help/system_time.rb

Class Method Summary collapse

Class Method Details

.messageObject

Registration may fail if the system clock is too far in the past (more than 15 minutes) Show the user how to fix the issue and try again



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bixby-agent/help/system_time.rb', line 15

def self.message
  s = "  it appears your system clock is out of sync"

  res = HTTPI.get("http://google.com")
  if not res.error? then
    current_time = Time.parse(res.headers["Date"]).utc
    s += "  > current time: #{current_time}"
    s += "  >  system time: #{Time.new.utc}"
  end

  $stderr.puts
  if linux? && ubuntu? then
    s += "  to fix:"
    s += "  sudo apt-get install ntpdate && sudo ntpdate ntp.ubuntu.com"
  elsif linux? && centos? then
    s += "  to fix:"
    s += "  sudo yum install ntpdate && sudo ntpdate ntp.ubuntu.com"
  else
    s += "  you can fix this on most unix systems by running 'sudo ntpdate ntp.ubuntu.com'"
  end

  s
end


9
10
11
# File 'lib/bixby-agent/help/system_time.rb', line 9

def self.print
  $stderr.puts self.message
end