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