aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-05-29 15:44:04 +0100
committerLouise Crow <louise.crow@gmail.com>2013-05-29 16:20:48 +0100
commitb4346ad162eb153fbe785cf9f6322f3e6305088a (patch)
tree50bcf67a5b354c4f2a3b31478f059ba64cefa9eb
parent16c075c68159ef79dd196196a4171f54934f9c41 (diff)
Now that runner is invoked via the rails command and not directly from the script directory, it's more important to cd to the app directory in order to pick up the bundler gemfile. Fixes #964.
-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/purge-varnish7
-rwxr-xr-xscript/rails-post-deploy14
-rwxr-xr-xscript/stop-new-responses-on-old-requests3
11 files changed, 32 insertions, 24 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/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/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'