aboutsummaryrefslogblamecommitdiffstats
path: root/lib/capistrano/tasks/create_secret_token.rake
blob: e51a4861c62db7a30cf6dbfc03edda5a3bfa8001 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                                              
                                                                    
   
# :mode=ruby:
require 'securerandom'

namespace :deploy do
  desc 'Generate secret token if not already set'
  task :generate_secret_token do
    target_file = File.join(shared_path, 'config', 'initializers', 'secret_token.rb')
    on roles(:app) do
      unless test "[ -f #{target_file} ]"
        result = %Q{ BetaWebApp::Application.config.secret_token = "#{SecureRandom.hex(64)}" }
        upload!(StringIO.new(result), target_file)
      end
    end
  end

  before 'deploy:check:linked_files', 'deploy:generate_secret_token'
end