aboutsummaryrefslogtreecommitdiffstats
path: root/script/rails-post-deploy
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-09-19 11:05:37 +0100
committerMark Longair <mhl@pobox.com>2013-10-29 13:52:39 +0000
commit90fa620147476b9215eed17da53b156e395ec144 (patch)
tree2d5c54f56b8e0a61c2a9a5c2eed9ffa5784ae972 /script/rails-post-deploy
parent0d956b0928b30d348d1646adaec429741a72139a (diff)
Deal with ../logs existing, and log not being a symlink
The rails-post-deploy script would error if the log directory existed (rather than being a symlink to another directory, for example) and the ../logs directory also existed. This commit changes this behaviour to move the existing log directory out of the way in this case. In addition, this commit switches from removing the old symlink and creating a new one (which creates a gap in time during which the log directory doesn't exist) to using "ln -snf" to just overwrite any existing symlink or file. (Note that this is still not an atomic operation, but it's bound to leave less time between removal and creation.)
Diffstat (limited to 'script/rails-post-deploy')
-rwxr-xr-xscript/rails-post-deploy9
1 files changed, 7 insertions, 2 deletions
diff --git a/script/rails-post-deploy b/script/rails-post-deploy
index bf639855b..c09868347 100755
--- a/script/rails-post-deploy
+++ b/script/rails-post-deploy
@@ -35,8 +35,13 @@ fi
if [ -e $TOP_DIR/../logs ]
then
# mySociety servers have logs dir in level above
- rm -f log
- ln -s $TOP_DIR/../logs log
+ if ! [ -h log ] && [ -d log ]
+ then
+ # If log is a directory rather than a symlink, move that
+ # directory out of the way:
+ mv log log.original
+ fi
+ ln -sfn $TOP_DIR/../logs log
else
# otherwise just make the directory
if [ -h log ]