gitlab-org--gitlab-foss/db/fixtures/production/001_admin.rb

39 lines
904 B
Ruby
Raw Normal View History

user_args = {
email: ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com',
name: 'Administrator',
username: 'root',
admin: true
}
if ENV['GITLAB_ROOT_PASSWORD'].blank?
user_args[:password_automatically_set] = true
user_args[:force_random_password] = true
else
user_args[:password] = ENV['GITLAB_ROOT_PASSWORD']
end
user = User.new(user_args)
user.skip_confirmation!
2011-10-08 17:36:38 -04:00
if user.save
2016-06-06 17:17:42 -04:00
puts "Administrator account created:".color(:green)
puts
2016-06-06 17:17:42 -04:00
puts "login: root".color(:green)
2011-10-21 13:58:04 -04:00
if user_args.key?(:password)
2016-06-06 17:17:42 -04:00
puts "password: #{user_args[:password]}".color(:green)
else
2016-06-06 17:17:42 -04:00
puts "password: You'll be prompted to create one on your first visit.".color(:green)
end
puts
else
2016-06-06 17:17:42 -04:00
puts "Could not create the default administrator account:".color(:red)
puts
user.errors.full_messages.map do |message|
2016-06-06 17:17:42 -04:00
puts "--> #{message}".color(:red)
end
puts
2011-10-21 13:58:04 -04:00
exit 1
2011-10-21 13:58:04 -04:00
end