debian-mirror-gitlab/db/fixtures/production/001_admin.rb

39 lines
856 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
user_args = {
email: ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com',
name: 'Administrator',
username: 'root',
admin: true
}
2015-04-26 12:48:37 +05:30
if ENV['GITLAB_ROOT_PASSWORD'].blank?
2016-06-02 11:05:42 +05:30
user_args[:password_automatically_set] = true
user_args[:force_random_password] = true
2015-04-26 12:48:37 +05:30
else
2016-06-02 11:05:42 +05:30
user_args[:password] = ENV['GITLAB_ROOT_PASSWORD']
2015-04-26 12:48:37 +05:30
end
2016-06-02 11:05:42 +05:30
user = User.new(user_args)
user.skip_confirmation!
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
if user.save
puts "Administrator account created:".green
puts
puts "login: root".green
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
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
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
exit 1
2014-09-02 18:07:02 +05:30
end