blob: d13b32aa92fdbc21682aa84a75f761812e4dd115 [file] [log] [blame]
mbligh88e12a12009-03-09 21:48:33 +00001#!/bin/sh
2
3# steps to take following a release of new code to keep things working.
4#
5# the following scripts may be created to customize behavior:
6#
7# site_utils/site_sync_code
8#
9# - pull code from a source repository
10#
11# site_utils/site_install_cli
12#
13# - install or update client code (new "atest" build?)
14#
15# site_utils/site_restart_apache
16#
17# - suid helper or similar?
18#
19# site_utils/site_restart_final
20#
21# - any finishing touches you may require.
22
23# ---
24
25INIT_SCR=/etc/init.d/autotest
26
27# ---
28
29print_status() {
30 STATUS=$1
31
32 echo "--- $STATUS"
33}
34
35fatal() {
36 echo "*** Fatal error. Giving up."
37 exit 1
38}
39
40# ---
41
42MY_DIR=`dirname $0`
43
44if (! test -f $INIT_SCR)
45then
46 echo "Error: $INIT_SCR must be installed."
47 exit 1
48fi
49
50BECOME_USER=`grep ^BECOME_USER= $INIT_SCR`
51
52if (test "$BECOME_USER" == "")
53then
54 echo "Error: BECOME_USER not defined in $INIT_SCR"
55 exit 1
56fi
57
58BASE_DIR=`grep ^BASE_DIR= $INIT_SCR`
59
60if (test "$BASE_DIR" == "")
61then
62 echo "Error: BASE_DIR not defined in $INIT_SCR"
63 exit 1
64fi
65
66eval $BECOME_USER
67eval $BASE_DIR
68
69# --- stop autotest persistent code
70
71print_status "Stopping autotest persistent code"
72$INIT_SCR stop
73
74# --- sync code (site-specific)
75
76if (test -x $BASE_DIR/site_utils/site_sync_code)
77then
78 print_status "Syncing code"
79 su $BECOME_USER -c $BASE_DIR/site_utils/site_sync_code || exit 1
80fi
81
mblighcc1b9992009-03-25 19:28:06 +000082# --- run database migrations
83
84# - AFE
85
86print_status "Running AFE migrations"
87( cd $BASE_DIR/frontend &&
88 su $BECOME_USER -c "python ../database/migrate.py \
89 --database=AUTOTEST_WEB safesync"
90 su $BECOME_USER -c "python manage.py syncdb --noinput"
91 su $BECOME_USER -c "python manage.py syncdb --noinput"
92)
93
94# - TKO
95
96print_status "Running TKO migrations"
97( cd $BASE_DIR/tko &&
98 su $BECOME_USER -c "python ../database/migrate.py \
99 --database=TKO safesync"
100)
101
102# - SITE_DB
103
104print_status "Running site_db migrations"
105( cd $BASE_DIR/site_db &&
106 su $BECOME_USER -c "python ../database/migrate.py \
107 --database=TKO safesync"
108)
109
mbligh7e2d9522009-04-08 21:15:35 +0000110# - Django syncdb
111
112print_status "Running syncdb on Django interface"
113# Due to the way Django creates permissions objects, we sometimes need
114# to run syncdb twice.
115for i in 1 2; do
116 ( cd $BASE_DIR/frontend &&
117 su $BECOME_USER -c "python manage.py syncdb --noinput"
118 )
119done
120
mbligha766c2b2009-11-06 03:01:32 +0000121# --- compile GWT
mbligh88e12a12009-03-09 21:48:33 +0000122
mbligha766c2b2009-11-06 03:01:32 +0000123print_status "Compiling GWT code."
124( cd $BASE_DIR &&
125 su $BECOME_USER -c "$BASE_DIR/utils/compile_gwt_clients.py -a" || fatal
126)
mbligh88e12a12009-03-09 21:48:33 +0000127
128# --- fix gwt permissions
129
130print_status "Fixing permissions"
131( cd $BASE_DIR/frontend/client &&
132 find | xargs chmod o+r &&
133 find -type d | xargs chmod o+rx ) || fatal
134
135# --- update cli repository (site-specific)
136
137if (test -x $BASE_DIR/site_utils/site_install_cli)
138then
139 print_status "Updating cli repository"
140 su $BECOME_USER -c $BASE_DIR/site_utils/site_install_cli || fatal
141fi
142
143# --- restart autotest persistent code
144
145print_status "Restarting autotest persistent code"
146$INIT_SCR start || fatal
147
148# --- possibly restart Apache (site-specific)
149
150if (test -x $BASE_DIR/site_utils/site_restart_apache)
151then
152 print_status "Restarting Apache"
153 su $BECOME_USER -c $BASE_DIR/site_utils/site_restart_apache || fatal
154fi
155
156# --- do any site-specific finalization
157
158if (test -x $BASE_DIR/site_utils/site_restart_final)
159then
160 print_status "Finalizing release"
161 su $BECOME_USER -c $BASE_DIR/site_utils/site_restart_final || fatal
162fi