diff options
author | Francis Irving <francis@mysociety.org> | 2009-10-28 23:32:25 +0000 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2009-10-28 23:32:25 +0000 |
commit | 5f2b80228c3be3ae2526d8995a5b24ab1586ec07 (patch) | |
tree | a521f976f1e45d395b56524f43015ef2511e7367 /script/rails-post-deploy | |
parent | 6244d68b426101a9e8cbae892acac08a1e644477 (diff) |
Fork of rails-post-deploy in mysociety/bin in CVS.
We need it in the same repository, and probably better that it is
specific to WDTK anyway.
Diffstat (limited to 'script/rails-post-deploy')
-rwxr-xr-x | script/rails-post-deploy | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/script/rails-post-deploy b/script/rails-post-deploy new file mode 100755 index 000000000..d30561df3 --- /dev/null +++ b/script/rails-post-deploy @@ -0,0 +1,110 @@ +#!/bin/bash +# +# rails-post-deploy +# For Ruby on Rails, run this in exec_extras in vhosts.pl. It makes symlinks +# from vendor to the server version of rails, and migrates the db to the most +# recent version. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: rails-post-deploy,v 1.18 2009-09-03 23:44:50 francis Exp $ +# + +set -e +#set -x # debug + +MYSOCIETY_DIR=`pwd` + +# $1 should be the directory of the rails app +cd $1 + +# make sure that there is an app directory, so are in a rails app tree +cd app/.. + +# read config file in for later (STAGING_SITE) +if [ -e "config/general" ] +then + . ../shlib/deployfns + read_conf config/general +else + OPTION_DOMAIN=127.0.0.1:3000 + OPTION_STAGING_SITE=1 +fi + +# Go into vendor +mkdir -p vendor +cd vendor + +# see if rails is frozen or not +if [ -d "rails-2.1.0" ] +then + LN_PATH=rails-2.1.0 +elif [ -d "rails" ] +then + LN_PATH=rails +else + LN_PATH=/usr/share/rails +fi + +# make symlinks to global rails installation +for X in actionmailer actionpack activerecord activesupport railties +do + rm -f $X + ln -s $LN_PATH/$X $X +done +rm -f rails +ln -s $LN_PATH rails +rm -f actionwebservice +cd .. +rm -f rails +ln -s $LN_PATH rails + +# create initial log files +if [ -e $MYSOCIETY_DIR/../logs ] +then + # mySociety servers have logs dir in level above + rm -f log + ln -s $MYSOCIETY_DIR/../logs log +else + # otherwise just make the directory + if [ -h log ] + then + # remove any old-style symlink first + rm -f log + fi + mkdir -p log +fi +cd log +touch development.log fastcgi.crash.log production.log test.log +cd .. + +# and for solr logs, if present +# (not now used by any mySociety sites, but hey) +if [ -e vendor/plugins/acts_as_solr/solr ] +then + cd vendor/plugins/acts_as_solr/solr + mkdir -p tmp + # put them inside e.g. mysociety/foi/log/solr + mkdir -p $MYSOCIETY_DIR/$1/log/solr + rm -f logs + ln -s $MYSOCIETY_DIR/$1/log/solr logs + cd - +fi + +# Force appropriate environment (via a hack in config/boot.rb which needs +# applying to your rails app, see foi/config/boot.rb) +if [ "$OPTION_STAGING_SITE" = "0" ] +then + echo "ENV['RAILS_ENV'] = 'production'" > config/rails_env.rb +elif [[ "$OPTION_DOMAIN" == *"test"* ]] +then + echo "ENV['RAILS_ENV'] = 'test'" > config/rails_env.rb +else + echo "ENV['RAILS_ENV'] = 'development'" > config/rails_env.rb +fi + +# upgrade database +rake db:migrate + + |