aboutsummaryrefslogtreecommitdiffstats
path: root/config/deploy/refinery_setup.rb
blob: da6616a9c3649cf1d7154ad67ffa64bb29274108 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'securerandom'

unless Capistrano::Configuration.respond_to?(:instance)
  abort "This extension requires Capistrano 2"
end

Capistrano::Configuration.instance.load do

  namespace :deploy do
    namespace :refinery do

      desc <<-DESC
        Creates the refinery core config for the application.
      DESC
      task :setup, :except => { :no_release => true } do

        default_template = <<-EOF
        # encoding: utf-8
        Refinery::Core.configure do |config|
          config.rescue_not_found = Rails.env.production?
          config.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?)
          config.site_name = "Company Name"
          config.base_cache_key = #{config.site_name.parameterize('_').to_sym}
          config.authenticity_token_on_frontend = true
          config.dragonfly_secret = "#{SecureRandom.hex(24)}"
          config.ie6_upgrade_message_enabled = true
          config.show_internet_explorer_upgrade_message = false
        end
        EOF

        run "mkdir -p #{shared_path}/config/refinery"
        put default_template, "#{shared_path}/config/refinery/core.rb"
      end

      desc <<-DESC
        [internal] Updates the symlink for secret_token.rb file to the just deployed release.
      DESC
      task :symlink, :except => { :no_release => true } do
        run "ln -nfs #{shared_path}/config/refinery/core.rb #{release_path}/config/initializers/refinery/core.rb"
      end

    end

    after "deploy:setup",           "deploy:refinery:setup"   unless fetch(:skip_refinery_setup, false)
    after "deploy:finalize_update", "deploy:refinery:symlink"
  end

end