blob: 1dce32797e20dd95e200301fa2bfed4d70245f4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/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
APP_DIR=`pwd`
# 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
. commonlib/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.3.2" ]
then
LN_PATH=rails-2.3.2
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 activeresource 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 ..
# create initial log files
if [ -e $APP_DIR/../logs ]
then
# mySociety servers have logs dir in level above
rm -f log
ln -s $APP_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 ..
# 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 #--trace
|