aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2013-01-25 23:17:35 +0100
committerHarald Eilertsen <haraldei@anduin.net>2013-01-25 23:17:35 +0100
commit429fd2cc1332ce3406eda363998eef6883465be7 (patch)
tree91739d0ecbc4501678bd39f5894d04db3ea25a50
parentb98cef6e533b998c7f24f6f5e6177816ec63af42 (diff)
downloadhmnoweb-429fd2cc1332ce3406eda363998eef6883465be7.tar.gz
hmnoweb-429fd2cc1332ce3406eda363998eef6883465be7.tar.bz2
hmnoweb-429fd2cc1332ce3406eda363998eef6883465be7.zip
Add deploy script to generate unique secret token upon setup.
-rw-r--r--config/deploy/secret_token.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/config/deploy/secret_token.rb b/config/deploy/secret_token.rb
new file mode 100644
index 0000000..80f2cd9
--- /dev/null
+++ b/config/deploy/secret_token.rb
@@ -0,0 +1,36 @@
+unless Capistrano::Configuration.respond_to?(:instance)
+ abort "This extension requires Capistrano 2"
+end
+
+Capistrano::Configuration.instance.load do
+
+ namespace :deploy do
+ namespace :token do
+
+ desc <<-DESC
+ Creates the secret token for the application.
+ DESC
+ task :setup, :except => { :no_release => true } do
+
+ default_template = <<-EOF
+ ReligionsfrihetNo::Application.config.secret_token = '#{`bundle exec rake secret`}'
+ EOF
+
+ run "mkdir -p #{shared_path}/config"
+ IO.write("#{shared_path}/config/secret_token.rb", default_template);
+ 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/secret_token.rb #{release_path}/config/secret_token.rb"
+ end
+
+ end
+
+ after "deploy:setup", "deploy:token:setup" unless fetch(:skip_token_setup, false)
+ after "deploy:finalize_update", "deploy:token:symlink"
+ end
+
+end