summaryrefslogtreecommitdiff
path: root/bin/check
blob: 2eec54e97124b5fcbc45f9a0e52e2f3fe1094c43 (plain)
1
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env ruby

require_relative '../lib/gitlab_init'
require_relative '../lib/gitlab_net'

def ping_redis
  print "Send ping to redis server: "
  if GitlabNet.new.redis_client.ping
    print 'OK'
  else
    abort 'FAILED'
  end

  puts "\n"
end

#
# GitLab shell check task
#

print "Check GitLab API access: "
begin
  resp = GitlabNet.new.check

  if resp.code != "200"
    abort "FAILED. code: #{resp.code}"
  end

  puts 'OK'

  check_values = JSON.parse(resp.body)

  if check_values.key?('redis')
    print 'Redis available via internal API: '
    if check_values['redis']
      puts 'OK'
    else
      abort 'FAILED'
    end
  else
    ping_redis
  end
rescue GitlabNet::ApiUnreachableError
  abort "FAILED: Failed to connect to internal API"
end

config = GitlabConfig.new

abort("ERROR: missing option in config.yml") unless config.auth_file

print "\nAccess to #{config.auth_file}: "
if system(File.dirname(__FILE__) + '/gitlab-keys', 'check-permissions')
  print 'OK'
else
  abort "FAILED"
end
puts "\n"