Permalink
Browse files

Added basic script to setup Engines and the Cookie Store

  • Loading branch information...
1 parent 642db2f commit a0d48f652dcf05065a4550c148cbde35cffef6c9 @edavis10 committed Dec 23, 2009
Showing with 61 additions and 0 deletions.
  1. +61 −0 lib/tasks/heroku.rake
View
@@ -0,0 +1,61 @@
+require 'fileutils'
+
+def heroku_app
+ if ENV['HEROKU_APP'].present?
+ "--app #{ENV['HEROKU_APP']}"
+ else
+ ''
+ end
+end
+
+namespace :heroku do
+ desc <<-END_DESC
+Setup Heroku for Redmine.
+
+If you are using a non-standard application setup, set the HEROKU_APP
+variable in your shell.
+
+Examples:
+ rake heroku:setup HEROKU_APP=redmine-demo
+
+END_DESC
+
+ task :setup => [:environment] do
+ # 1. Engines
+ FileUtils.mkdir_p File.join(RAILS_ROOT, 'public', 'plugin_assets')
+ File.open(File.join(RAILS_ROOT, 'public', 'plugin_assets','README'), 'w') do |f|
+ f.puts ''
+ end
+
+ system("git add #{File.join(RAILS_ROOT, 'public', 'plugin_assets','README')}")
+ system("git commit -m 'Added plugin_asset README for Heroku'")
+
+ # 2. Cookie Store
+ path = File.join(RAILS_ROOT, 'config', 'initializers', 'session_store.rb')
+ secret = ActiveSupport::SecureRandom.hex(40)
+ File.open(path, 'w') do |f|
+ f.write <<"EOF"
+# This file was generated by 'rake config/initializers/session_store.rb',
+# and should not be made visible to public.
+# If you have a load-balancing Redmine cluster, you will need to use the
+# same version of this file on each machine. And be sure to restart your
+# server when you modify this file.
+
+# Your secret key for verifying cookie session data integrity. If you
+# change this key, all old sessions will become invalid! Make sure the
+# secret is at least 30 characters and all random, no regular words or
+# you'll be exposed to dictionary attacks.
+ActionController::Base.session = {
+ :session_key => '_redmine_session',
+ :secret => ENV['SESSION_SECRET']
+}
+EOF
+ end
+
+ system("git add -f #{path}")
+ system("git commit -m 'Added session secret for Heroku using ENV'")
+
+ system("heroku config:add SESSION_SECRET=#{secret} #{heroku_app}")
+
+ end
+end

0 comments on commit a0d48f6

Please sign in to comment.