debian-mirror-gitlab/config/initializers/gitlab_shell_secret_token.rb

20 lines
583 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
# Be sure to restart your server when you modify this file.
require 'securerandom'
# Your secret key for verifying the gitlab_shell.
2015-09-11 14:41:01 +05:30
secret_file = Gitlab.config.gitlab_shell.secret_file
2015-04-26 12:48:37 +05:30
unless File.exist? secret_file
# Generate a new token of 16 random hexadecimal characters and store it in secret_file.
token = SecureRandom.hex(16)
File.write(secret_file, token)
end
2015-09-11 14:41:01 +05:30
link_path = File.join(Gitlab.config.gitlab_shell.path, '.gitlab_shell_secret')
if File.exist?(Gitlab.config.gitlab_shell.path) && !File.exist?(link_path)
FileUtils.symlink(secret_file, link_path)
2015-04-26 12:48:37 +05:30
end