aboutsummaryrefslogtreecommitdiffstats
path: root/lib/capistrano/tasks
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2014-12-07 23:01:33 +0100
committerHarald Eilertsen <haraldei@anduin.net>2014-12-07 23:01:33 +0100
commite49b8c0b0e58e8cd50d1675473ff4bc737b068ed (patch)
tree57441b3512da5b9ff6f50d119e63c5cb42997852 /lib/capistrano/tasks
parent1809e9b04ac41154ced5e5b54bbd5e1190c02cd2 (diff)
downloadhmnoweb-e49b8c0b0e58e8cd50d1675473ff4bc737b068ed.tar.gz
hmnoweb-e49b8c0b0e58e8cd50d1675473ff4bc737b068ed.tar.bz2
hmnoweb-e49b8c0b0e58e8cd50d1675473ff4bc737b068ed.zip
Add refinery setup tasks for capistrano.
Copied from Åsatru.no setup.
Diffstat (limited to 'lib/capistrano/tasks')
-rw-r--r--lib/capistrano/tasks/create_secret_token.rake17
-rw-r--r--lib/capistrano/tasks/refinery_setup.rake22
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/capistrano/tasks/create_secret_token.rake b/lib/capistrano/tasks/create_secret_token.rake
new file mode 100644
index 0000000..5b048b9
--- /dev/null
+++ b/lib/capistrano/tasks/create_secret_token.rake
@@ -0,0 +1,17 @@
+# :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', 'deploy:generate_secret_token'
+end
diff --git a/lib/capistrano/tasks/refinery_setup.rake b/lib/capistrano/tasks/refinery_setup.rake
new file mode 100644
index 0000000..d5d21bc
--- /dev/null
+++ b/lib/capistrano/tasks/refinery_setup.rake
@@ -0,0 +1,22 @@
+# :mode=ruby:
+require 'securerandom'
+require 'active_support/inflector'
+
+namespace :deploy do
+ namespace :refinery do
+ desc 'Initialize refinery config for new deployments.'
+ task :setup do
+ output_file = File.join(shared_path, "config", "initializers", "refinery", "core.rb")
+ on roles(:app) do
+ unless test "[ -f #{output_file} ]"
+ template = IO.read(File.join("config", "initializers", "refinery", "core.rb.erb"))
+ core = ERB.new(template)
+ site_name = fetch(:site_name, "Beta")
+ upload!(StringIO.new(core.result(binding)), output_file)
+ end
+ end
+ end
+ end
+
+ before 'deploy', 'deploy:refinery:setup'
+end