aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rwxr-xr-xscript/alert-comment-on-request3
-rwxr-xr-xscript/alert-new-response-reminders3
-rwxr-xr-xscript/alert-not-clarified-request3
-rwxr-xr-xscript/alert-overdue-requests3
-rwxr-xr-xscript/alert-tracks3
-rwxr-xr-xscript/check-recent-requests-sent3
-rwxr-xr-xscript/clear-caches11
-rwxr-xr-xscript/delete-old-things3
-rwxr-xr-xscript/handle-mail-replies.rb4
-rwxr-xr-xscript/purge-varnish7
-rwxr-xr-xscript/rails-post-deploy14
-rwxr-xr-xscript/runner5
-rwxr-xr-xscript/stop-new-responses-on-old-requests3
13 files changed, 39 insertions, 26 deletions
diff --git a/script/alert-comment-on-request b/script/alert-comment-on-request
index 1222eecf1..849f4a8d8 100755
--- a/script/alert-comment-on-request
+++ b/script/alert-comment-on-request
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_comment_on_request'
diff --git a/script/alert-new-response-reminders b/script/alert-new-response-reminders
index 97f558f43..148706d49 100755
--- a/script/alert-new-response-reminders
+++ b/script/alert-new-response-reminders
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_new_response_reminders'
diff --git a/script/alert-not-clarified-request b/script/alert-not-clarified-request
index fb562beeb..8d61c1800 100755
--- a/script/alert-not-clarified-request
+++ b/script/alert-not-clarified-request
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_not_clarified_request'
diff --git a/script/alert-overdue-requests b/script/alert-overdue-requests
index 9e597d17d..ebc2897a0 100755
--- a/script/alert-overdue-requests
+++ b/script/alert-overdue-requests
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_overdue_requests'
diff --git a/script/alert-tracks b/script/alert-tracks
index 9fd32f2a1..17426b4e0 100755
--- a/script/alert-tracks
+++ b/script/alert-tracks
@@ -1,5 +1,6 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
if [ "$1" == "--loop" ]
then
bundle exec rails runner 'TrackMailer.alert_tracks_loop'
diff --git a/script/check-recent-requests-sent b/script/check-recent-requests-sent
index 1eb87d498..8f21fb6e7 100755
--- a/script/check-recent-requests-sent
+++ b/script/check-recent-requests-sent
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'MailServerLog.check_recent_requests_have_been_sent'
diff --git a/script/clear-caches b/script/clear-caches
index f97c1f777..20ee3df19 100755
--- a/script/clear-caches
+++ b/script/clear-caches
@@ -1,12 +1,11 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
# Clear the cache of attachment and body text.
-LOC="`dirname "$0"`"
-
bundle exec rails runner "ActiveRecord::Base.connection.execute(\"update incoming_messages set cached_attachment_text_clipped = null, cached_main_body_text_unfolded = null, cached_main_body_text_folded = null, sent_at = null, subject = null, mail_from = null, mail_from_domain = null, valid_to_reply_to = null, last_parsed = null\")"
# Remove page cache (do it in two stages so live site gets cache cleared faster)
-rm -fr $LOC/../old-cache
-mv $LOC/../cache $LOC/../old-cache
-rm -fr $LOC/../old-cache
+rm -fr $TOP_DIR/old-cache
+mv $TOP_DIR/cache $TOP_DIR/old-cache
+rm -fr $TOP_DIR/old-cache
diff --git a/script/delete-old-things b/script/delete-old-things
index 58c144958..a97ba4869 100755
--- a/script/delete-old-things
+++ b/script/delete-old-things
@@ -1,4 +1,5 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'PostRedirect.delete_old_post_redirects'
bundle exec rails runner 'TrackThingsSentEmail.delete_old_track_things_sent_email'
diff --git a/script/handle-mail-replies.rb b/script/handle-mail-replies.rb
index be6bd10da..da0fc8e96 100755
--- a/script/handle-mail-replies.rb
+++ b/script/handle-mail-replies.rb
@@ -21,6 +21,10 @@ load 'configuration.rb'
MySociety::Config.set_file(File.join($alaveteli_dir, 'config', 'general'), true)
MySociety::Config.load_default
require 'mail_handler'
+if RUBY_VERSION.to_f >= 1.9
+ # the default encoding for IO is utf-8, and we use utf-8 internally
+ Encoding.default_external = Encoding.default_internal = Encoding::UTF_8
+end
def main(in_test_mode)
Dir.chdir($alaveteli_dir) do
diff --git a/script/purge-varnish b/script/purge-varnish
index 7dcecd4f9..abc6daeaf 100755
--- a/script/purge-varnish
+++ b/script/purge-varnish
@@ -1,11 +1,12 @@
#!/bin/bash
-LOC=`dirname $0`
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
if [ "$1" == "--loop" ]
then
- rails runner 'PurgeRequest.purge_all_loop'
+ bundle exec rails runner 'PurgeRequest.purge_all_loop'
else
- rails runner 'PurgeRequest.purge_all'
+ bundle exec rails runner 'PurgeRequest.purge_all'
fi
diff --git a/script/rails-post-deploy b/script/rails-post-deploy
index a9e239423..4048c852f 100755
--- a/script/rails-post-deploy
+++ b/script/rails-post-deploy
@@ -11,8 +11,8 @@
set -e
#set -x # debug
-APP_DIR="$(readlink -f $(dirname "$BASH_SOURCE")/..)"
-cd "$APP_DIR"
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
# make sure that there is an app directory, so are in a rails app tree
if ! [ -d app ]
@@ -32,11 +32,11 @@ else
fi
# create initial log files
-if [ -e $APP_DIR/../logs ]
+if [ -e $TOP_DIR/../logs ]
then
# mySociety servers have logs dir in level above
rm -f log
- ln -s $APP_DIR/../logs log
+ ln -s $TOP_DIR/../logs log
else
# otherwise just make the directory
if [ -h log ]
@@ -47,10 +47,10 @@ else
mkdir -p log
fi
# link the "downloads" directory in the cache to somewhere it can be served
-if [ ! -e "$APP_DIR/public/download" ]
+if [ ! -e "$TOP_DIR/public/download" ]
then
- mkdir -p "$APP_DIR/cache/zips/download"
- ln -s "$APP_DIR/cache/zips/download" "$APP_DIR/public/"
+ mkdir -p "$TOP_DIR/cache/zips/download"
+ ln -s "$TOP_DIR/cache/zips/download" "$TOP_DIR/public/"
fi
cd log
diff --git a/script/runner b/script/runner
index 73b03847d..32a0e6b7e 100755
--- a/script/runner
+++ b/script/runner
@@ -19,12 +19,13 @@ Dir.chdir(alaveteli_dir) do
# Load the runner in a subprocess
pid = fork do
- `bundle exec rails runner #{ARGV[1]}`
+ exec("bundle exec rails runner #{ARGV[1]}")
exit 0
end
# If the environment variable PIDFILE is present,
# write the pid of the daemon process to that file.
+
if ENV.has_key? "PIDFILE"
File.open(ENV["PIDFILE"], 'w') do |fh|
fh.puts pid
@@ -34,6 +35,6 @@ Dir.chdir(alaveteli_dir) do
Process.detach(pid)
else
# Not daemon mode
- `bundle exec rails runner #{ARGV[1]}`
+ exec("bundle exec rails runner #{ARGV[1]}")
end
end
diff --git a/script/stop-new-responses-on-old-requests b/script/stop-new-responses-on-old-requests
index f317f11ff..07257d6b2 100755
--- a/script/stop-new-responses-on-old-requests
+++ b/script/stop-new-responses-on-old-requests
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'InfoRequest.stop_new_responses_on_old_requests'