Description: FHS through env vars Forwarded: not-needed Author: Jérémy Lal Last-Update: 2010-01-10 Index: b/app/models/attachment.rb =================================================================== --- a/app/models/attachment.rb 2011-03-07 20:44:37.000000000 +0100 +++ b/app/models/attachment.rb 2011-03-08 10:26:55.000000000 +0100 @@ -43,7 +43,7 @@ "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"} cattr_accessor :storage_path - @@storage_path = "#{RAILS_ROOT}/files" + @@storage_path = ENV['RAILS_VAR'] ? File.join(ENV['RAILS_VAR'], 'files') : "#{RAILS_ROOT}/files" def validate if self.filesize > Setting.attachment_max_size.to_i.kilobytes Index: b/config/environment.rb =================================================================== --- a/config/environment.rb 2011-03-07 20:44:40.000000000 +0100 +++ b/config/environment.rb 2011-03-08 10:26:55.000000000 +0100 @@ -2,7 +2,15 @@ # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way -# ENV['RAILS_ENV'] ||= 'production' +ENV['RAILS_ENV'] ||= 'production' + +# for debian package : setup proper environment variables and paths +# To run redmine as unprivileged user, see /usr/share/doc/redmine/README.Debian +ENV['X_DEBIAN_SITEID'] ||= 'default' +ENV['RAILS_ETC'] ||= "/etc/redmine/#{ENV['X_DEBIAN_SITEID']}" +ENV['RAILS_LOG'] ||= "/var/log/redmine/#{ENV['X_DEBIAN_SITEID']}" +ENV['RAILS_VAR'] ||= "/var/lib/redmine/#{ENV['X_DEBIAN_SITEID']}" +ENV['RAILS_CACHE'] ||= "/var/cache/redmine/#{ENV['X_DEBIAN_SITEID']}" # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION @@ -30,9 +38,18 @@ # (by default production uses :info, the others :debug) # config.log_level = :debug + # log path + config.log_path = File.join(ENV['RAILS_LOG'], "#{ENV['RAILS_ENV']}.log") unless !ENV['RAILS_LOG'] + # Enable page/fragment caching by setting a file-based store # (remember to create the caching directory and make it readable to the application) # config.action_controller.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache" + + # the file cache store + config.cache_store = :file_store, ENV['RAILS_CACHE'] + + # Set Active Record's database.yml path + config.database_configuration_file = File.join(ENV['RAILS_ETC'], 'database.yml') unless !ENV['RAILS_ETC'] # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector Index: b/config/initializers/10-patches.rb =================================================================== --- a/config/initializers/10-patches.rb 2011-03-07 20:44:40.000000000 +0100 +++ b/config/initializers/10-patches.rb 2011-03-08 10:26:55.000000000 +0100 @@ -79,6 +79,9 @@ ActionMailer::Base.send :include, AsynchronousMailer +# the session store +ActionController::Base.session_options[:tmpdir] = File.join(ENV['RAILS_VAR'], 'sessions') unless !ENV['RAILS_VAR'] + # TODO: Hack to support i18n 4.x on Rails 2.3.5. Remove post 2.3.6. # See http://www.redmine.org/issues/6428 and http://www.redmine.org/issues/5608 module I18n Index: b/config/initializers/40-email.rb =================================================================== --- a/config/initializers/40-email.rb 2011-03-07 20:44:40.000000000 +0100 +++ b/config/initializers/40-email.rb 2011-03-08 10:26:55.000000000 +0100 @@ -1,7 +1,7 @@ # Loads action_mailer settings from email.yml # and turns deliveries on if configuration file is found -filename = File.join(File.dirname(__FILE__), '..', 'email.yml') +filename = ENV['RAILS_ETC'] ? File.join(ENV['RAILS_ETC'], 'email.yml') : File.join(File.dirname(__FILE__), '..', 'email.yml') if File.file?(filename) mailconfig = YAML::load_file(filename) Index: b/public/dispatch.fcgi.example =================================================================== --- a/public/dispatch.fcgi.example 2011-03-07 20:44:41.000000000 +0100 +++ b/public/dispatch.fcgi.example 2011-03-08 10:26:55.000000000 +0100 @@ -20,5 +20,8 @@ # require File.dirname(__FILE__) + "/../config/environment" require 'fcgi_handler' - -RailsFCGIHandler.process! +if ENV['RAILS_LOG'] + RailsFCGIHandler.process! File.join(ENV['RAILS_LOG'], 'fastcgi.crash.log') +else + RailsFCGIHandler.process! +end