aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rwxr-xr-xscript/about2
-rwxr-xr-xscript/breakpointer2
-rwxr-xr-xscript/dbconsole2
-rwxr-xr-xscript/destroy2
-rwxr-xr-xscript/generate2
-rwxr-xr-xscript/generate_pot.sh4
-rwxr-xr-xscript/handle-mail-replies38
-rwxr-xr-xscript/load-sample-data2
-rwxr-xr-xscript/performance/benchmarker2
-rwxr-xr-xscript/performance/profiler2
-rwxr-xr-xscript/performance/request2
-rwxr-xr-xscript/plugin2
-rwxr-xr-xscript/process/inspector2
-rwxr-xr-xscript/process/reaper2
-rwxr-xr-xscript/process/spawner2
-rwxr-xr-xscript/purge-varnish11
-rwxr-xr-xscript/rails-post-deploy9
-rwxr-xr-xscript/rebuild-xapian-index2
-rwxr-xr-xscript/spec-all-pairs2
-rwxr-xr-xscript/spec_server4
-rwxr-xr-xscript/test-run2
-rwxr-xr-xscript/update-xapian-index2
22 files changed, 67 insertions, 33 deletions
diff --git a/script/about b/script/about
index f2b98742d..49a7c2609 100755
--- a/script/about
+++ b/script/about
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/about'
diff --git a/script/breakpointer b/script/breakpointer
index 609564148..46a01d1b2 100755
--- a/script/breakpointer
+++ b/script/breakpointer
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/breakpointer'
diff --git a/script/dbconsole b/script/dbconsole
index c25c5afcd..39042fad3 100755
--- a/script/dbconsole
+++ b/script/dbconsole
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/dbconsole'
diff --git a/script/destroy b/script/destroy
index e63ac0ef5..fddc5160d 100755
--- a/script/destroy
+++ b/script/destroy
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/destroy'
diff --git a/script/generate b/script/generate
index 8c0486a09..fb8139d12 100755
--- a/script/generate
+++ b/script/generate
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/generate'
diff --git a/script/generate_pot.sh b/script/generate_pot.sh
index f6c82dda7..c0540c3d9 100755
--- a/script/generate_pot.sh
+++ b/script/generate_pot.sh
@@ -10,8 +10,8 @@ git status | grep app.po | awk '{print $3}' | xargs git add
git commit -m "Backup latest po files from Transifex"
# now regenerate POT and PO files from Alaveteli source
-rake gettext:store_model_attributes
-rake gettext:findpot
+bundle exec rake gettext:store_model_attributes
+bundle exec rake gettext:findpot
# upload the result to Transifex
tx push -t
diff --git a/script/handle-mail-replies b/script/handle-mail-replies
index 68cab9035..7590f5848 100755
--- a/script/handle-mail-replies
+++ b/script/handle-mail-replies
@@ -18,13 +18,7 @@ load "config.rb"
MySociety::Config.set_file(File.join($alaveteli_dir, 'config', 'general'), true)
MySociety::Config.load_default
-require 'rubygems'
-if File.exist? File.join($alaveteli_dir,'vendor','rails','Rakefile')
- $:.push(File.join($alaveteli_dir, "vendor", "rails", "actionmailer", "lib", "action_mailer", "vendor", "tmail-1.2.7"))
- require 'tmail'
-else
- require 'action_mailer'
-end
+require 'action_mailer'
def main(in_test_mode)
Dir.chdir($alaveteli_dir) do
@@ -49,9 +43,22 @@ def main(in_test_mode)
return 1
end
- if is_oof? message
- # Discard out-of-office messages
- return 2
+ # If we are still here, there are no permanent failures,
+ # so if the message is a multipart/report then it must be
+ # reporting a temporary failure. In this case we discard it
+ if message.content_type == "multipart/report"
+ return 1
+ end
+
+ # Another style of temporary failure message
+ subject = message.header_string("Subject")
+ if message.content_type == "multipart/mixed" && subject == "Delivery Status Notification (Delay)"
+ return 1
+ end
+
+ # Discard out-of-office messages
+ if is_oof?(message)
+ return 2 # Use a different return code, to distinguish OOFs from bounces
end
# Otherwise forward the message on
@@ -100,6 +107,15 @@ def permanently_failed_addresses(message)
end
end
+ subject = message.header_string("Subject")
+ # Then look for the style we’ve seen in WebShield bounces
+ # (These do not have a return path of <> in the cases I have seen.)
+ if subject == "Returned Mail: Error During Delivery"
+ if message.body =~ /^\s*---- Failed Recipients ----\s*((?:<[^>]+>\n)+)/
+ return $1.scan(/<([^>]+)>/).flatten
+ end
+ end
+
return []
end
@@ -151,7 +167,7 @@ end
def load_rails
require File.join('config', 'boot')
- require RAILS_ROOT + '/config/environment'
+ require Rails.root + '/config/environment'
end
def record_bounce(email_address, bounce_message)
diff --git a/script/load-sample-data b/script/load-sample-data
index e5f1be4cd..86e1af128 100755
--- a/script/load-sample-data
+++ b/script/load-sample-data
@@ -6,7 +6,7 @@
LOC=`dirname "$0"`
-rake --silent spec:db:fixtures:load
+bundle exec rake --silent spec:db:fixtures:load
"$LOC/runner" /dev/stdin <<END
env = ENV["RAILS_ENV"]
diff --git a/script/performance/benchmarker b/script/performance/benchmarker
index a94253aba..28bfceea0 100755
--- a/script/performance/benchmarker
+++ b/script/performance/benchmarker
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/performance/benchmarker'
diff --git a/script/performance/profiler b/script/performance/profiler
index e9e5b071d..11baf44f2 100755
--- a/script/performance/profiler
+++ b/script/performance/profiler
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/performance/profiler'
diff --git a/script/performance/request b/script/performance/request
index 658c80ef2..fff6fe660 100755
--- a/script/performance/request
+++ b/script/performance/request
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/performance/request'
diff --git a/script/plugin b/script/plugin
index 18ae72620..49f5c441f 100755
--- a/script/plugin
+++ b/script/plugin
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/plugin'
diff --git a/script/process/inspector b/script/process/inspector
index 696551c6b..467962602 100755
--- a/script/process/inspector
+++ b/script/process/inspector
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/process/inspector'
diff --git a/script/process/reaper b/script/process/reaper
index a03da9387..2eea898db 100755
--- a/script/process/reaper
+++ b/script/process/reaper
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/process/reaper'
diff --git a/script/process/spawner b/script/process/spawner
index 6852fba27..ac417c3a7 100755
--- a/script/process/spawner
+++ b/script/process/spawner
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot.rb'
+require File.expand_path(File.dirname(__FILE__) + '/../config/boot.rb')
require 'commands/process/spawner'
diff --git a/script/purge-varnish b/script/purge-varnish
new file mode 100755
index 000000000..932cf6635
--- /dev/null
+++ b/script/purge-varnish
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+LOC=`dirname $0`
+
+if [ "$1" == "--loop" ]
+then
+ "$LOC/runner" 'PurgeRequest.purge_all_loop'
+else
+ "$LOC/runner" 'PurgeRequest.purge_all'
+fi
+
diff --git a/script/rails-post-deploy b/script/rails-post-deploy
index d9e9bb3f1..4edabc9a7 100755
--- a/script/rails-post-deploy
+++ b/script/rails-post-deploy
@@ -74,12 +74,19 @@ then
echo "ENV['RAILS_ENV'] ||= 'production'" > config/rails_env.rb
fi
+if [ "$OPTION_STAGING_SITE" = "0" ]
+then
+ bundle install --without development:test --deployment
+else
+ bundle install
+fi
+
if [ -n "$OPTION_THEME_URL" ]
then
script/plugin install --force $OPTION_THEME_URL
fi
# upgrade database
-rake db:migrate #--trace
+bundle exec rake db:migrate #--trace
diff --git a/script/rebuild-xapian-index b/script/rebuild-xapian-index
index 5986f5259..3012511de 100755
--- a/script/rebuild-xapian-index
+++ b/script/rebuild-xapian-index
@@ -1,4 +1,4 @@
#!/bin/bash
cd `dirname $0`
-rake --silent "$@" xapian:rebuild_index models="PublicBody User InfoRequestEvent"
+bundle exec rake --silent "$@" xapian:rebuild_index models="PublicBody User InfoRequestEvent"
diff --git a/script/spec-all-pairs b/script/spec-all-pairs
index 5b6439a4e..6d7bb17c4 100755
--- a/script/spec-all-pairs
+++ b/script/spec-all-pairs
@@ -6,7 +6,7 @@
log_file=/dev/null
test_pair () {
- rake db:test:prepare > /dev/null 2>&1
+ bundle exec rake db:test:prepare > /dev/null 2>&1
output=$(script/spec "$1" "$2" 2>&1)
if [ $? -eq 0 ]
then
diff --git a/script/spec_server b/script/spec_server
index 1e839355f..dfdf8ff6c 100755
--- a/script/spec_server
+++ b/script/spec_server
@@ -41,7 +41,7 @@ module Spec
load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
if in_memory_database?
- load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
+ load "#{Rails.root}/db/schema.rb" # use db agnostic schema by default
ActiveRecord::Migrator.up('db/migrate') # use migrations
end
@@ -80,7 +80,7 @@ def daemonize(pid_file = nil)
return yield if $DEBUG
pid = Process.fork{
Process.setsid
- Dir.chdir(RAILS_ROOT)
+ Dir.chdir(Rails.root)
trap("SIGINT"){ exit! 0 }
trap("SIGTERM"){ exit! 0 }
trap("SIGHUP"){ restart_test_server }
diff --git a/script/test-run b/script/test-run
index 4c7a0e3ec..7810b57d5 100755
--- a/script/test-run
+++ b/script/test-run
@@ -1,5 +1,5 @@
#!/bin/bash
cd ../
-rake spec
+bundle exec rake spec
diff --git a/script/update-xapian-index b/script/update-xapian-index
index 6ece02de0..e365e2fec 100755
--- a/script/update-xapian-index
+++ b/script/update-xapian-index
@@ -1,5 +1,5 @@
#!/bin/bash
cd `dirname $0`
-rake --silent xapian:update_index "$@"
+bundle exec rake --silent xapian:update_index "$@"