diff options
author | Robin Houston <robin.houston@gmail.com> | 2011-09-07 15:01:49 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2011-09-07 15:01:49 +0100 |
commit | 72345d12a7dac9eb5a0680286677fcdbc82d46d1 (patch) | |
tree | 15cbb68cfd0fa19d423b7675b1f70dbe5b809d1d /script/handle-mail-replies | |
parent | e73c5b6b1ffddc19ba0eef0a228ec2574d511525 (diff) |
Set cwd to alaveteli root
In the handle-mail-replies script, set the current directory to the
alaveteli root, otherwise Rails fails to load.
Diffstat (limited to 'script/handle-mail-replies')
-rwxr-xr-x | script/handle-mail-replies | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/script/handle-mail-replies b/script/handle-mail-replies index 5762ddd31..868381a7e 100755 --- a/script/handle-mail-replies +++ b/script/handle-mail-replies @@ -18,13 +18,15 @@ MySociety::Config.set_file(File.join($alaveteli_dir, 'config', 'general'), true) MySociety::Config.load_default def main - load_rails - raw_message = $stdin.read - pfa = permanently_failed_address(raw_message) - if pfa.nil? - not_a_bounce(raw_message) - else - record_bounce(pfa, raw_message) + File.chdir($alaveteli_dir) do + load_rails + raw_message = $stdin.read + pfa = permanently_failed_address(raw_message) + if pfa.nil? + not_a_bounce(raw_message) + else + record_bounce(pfa, raw_message) + end end end @@ -57,7 +59,7 @@ def not_a_bounce(raw_message) end def load_rails - require File.join($alaveteli_dir, 'config', 'boot') + require File.join('config', 'boot') require RAILS_ROOT + '/config/environment' end |