-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic script to setup Engines and the Cookie Store
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |