Skip to content

Commit

Permalink
Added basic script to setup Engines and the Cookie Store
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Dec 23, 2009
1 parent 642db2f commit a0d48f6
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions lib/tasks/heroku.rake
Original file line number Diff line number Diff line change
@@ -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.