BigW Consortium Gitlab

001_admin.rb 856 Bytes
Newer Older
1 2 3 4 5 6 7
user_args = {
  email:    ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com',
  name:     'Administrator',
  username: 'root',
  admin:    true
}

8
if ENV['GITLAB_ROOT_PASSWORD'].blank?
9 10
  user_args[:password_automatically_set] = true
  user_args[:force_random_password] = true
11
else
12
  user_args[:password] = ENV['GITLAB_ROOT_PASSWORD']
13
end
14

15 16
user = User.new(user_args)
user.skip_confirmation!
gitlabhq committed
17

18 19 20 21
if user.save
  puts "Administrator account created:".green
  puts
  puts "login:    root".green
gitlabhq committed
22

23 24 25 26 27 28 29 30 31 32 33 34 35
  if user_args.key?(:password)
    puts "password: #{user_args[:password]}".green
  else
    puts "password: You'll be prompted to create one on your first visit.".green
  end
  puts
else
  puts "Could not create the default administrator account:".red
  puts
  user.errors.full_messages.map do |message|
    puts "--> #{message}".red
  end
  puts
gitlabhq committed
36

37
  exit 1
gitlabhq committed
38
end