diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-08-07 12:14:05 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-08-07 12:24:34 +0100 |
commit | efa7f24c08c0cffa373b44ec4745a698003f85f2 (patch) | |
tree | c17a5b7d658854b3025076179101364521d07412 /lib/tasks/config_files.rake | |
parent | 91bc1c4963aa8f31d4d708dd87f1a5a4ccb401f1 (diff) |
Tidy config_files:convert_init_script
Diffstat (limited to 'lib/tasks/config_files.rake')
-rw-r--r-- | lib/tasks/config_files.rake | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake index 438b63fc0..8ebd3fc07 100644 --- a/lib/tasks/config_files.rake +++ b/lib/tasks/config_files.rake @@ -28,22 +28,23 @@ namespace :config_files do 'VHOST_DIR', 'SCRIPT_FILE'], example) - script_file = ENV['SCRIPT_FILE'] - site = ENV.fetch('SITE', 'foi') - replacements = { :user => ENV['DEPLOY_USER'], :vhost_dir => ENV['VHOST_DIR'], - :vcspath => ENV.fetch('VCSPATH', 'alaveteli'), - :site => site + :vcspath => ENV.fetch('VCSPATH'), { 'alaveteli' }, + :site => ENV.fetch('SITE') { 'foi' } } - daemon_name = File.basename(script_file, '-debian.ugly') - replacements.update(:daemon_name => "#{ site }-#{ daemon_name }") - converted = convert_ugly(script_file, replacements) - rails_env_file = File.expand_path(File.join(Rails.root, 'config', 'rails_env.rb')) + # Use the filename for the $daemon_name ugly variable + daemon_name = File.basename(ENV['SCRIPT_FILE'], '-debian.ugly') + replacements.update(:daemon_name => "#{ replacements[:site] }-#{ daemon_name }") + + # Generate the template for potential further processing + converted = convert_ugly(ENV['SCRIPT_FILE'], replacements) - unless File.exists?(rails_env_file) + # gsub the RAILS_ENV in to the generated template if its not set by the + # hard coded config file + unless File.exists?("#{ Rails.root }/config/rails_env.rb") converted.each do |line| line.gsub!(/^#\s*RAILS_ENV=your_rails_env/, "RAILS_ENV=#{Rails.env}") line.gsub!(/^#\s*export RAILS_ENV/, "export RAILS_ENV") |