blob: d13b32aa92fdbc21682aa84a75f761812e4dd115 (
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#!/bin/sh
# steps to take following a release of new code to keep things working.
#
# the following scripts may be created to customize behavior:
#
# site_utils/site_sync_code
#
# - pull code from a source repository
#
# site_utils/site_install_cli
#
# - install or update client code (new "atest" build?)
#
# site_utils/site_restart_apache
#
# - suid helper or similar?
#
# site_utils/site_restart_final
#
# - any finishing touches you may require.
# ---
INIT_SCR=/etc/init.d/autotest
# ---
print_status() {
STATUS=$1
echo "--- $STATUS"
}
fatal() {
echo "*** Fatal error. Giving up."
exit 1
}
# ---
MY_DIR=`dirname $0`
if (! test -f $INIT_SCR)
then
echo "Error: $INIT_SCR must be installed."
exit 1
fi
BECOME_USER=`grep ^BECOME_USER= $INIT_SCR`
if (test "$BECOME_USER" == "")
then
echo "Error: BECOME_USER not defined in $INIT_SCR"
exit 1
fi
BASE_DIR=`grep ^BASE_DIR= $INIT_SCR`
if (test "$BASE_DIR" == "")
then
echo "Error: BASE_DIR not defined in $INIT_SCR"
exit 1
fi
eval $BECOME_USER
eval $BASE_DIR
# --- stop autotest persistent code
print_status "Stopping autotest persistent code"
$INIT_SCR stop
# --- sync code (site-specific)
if (test -x $BASE_DIR/site_utils/site_sync_code)
then
print_status "Syncing code"
su $BECOME_USER -c $BASE_DIR/site_utils/site_sync_code || exit 1
fi
# --- run database migrations
# - AFE
print_status "Running AFE migrations"
( cd $BASE_DIR/frontend &&
su $BECOME_USER -c "python ../database/migrate.py \
--database=AUTOTEST_WEB safesync"
su $BECOME_USER -c "python manage.py syncdb --noinput"
su $BECOME_USER -c "python manage.py syncdb --noinput"
)
# - TKO
print_status "Running TKO migrations"
( cd $BASE_DIR/tko &&
su $BECOME_USER -c "python ../database/migrate.py \
--database=TKO safesync"
)
# - SITE_DB
print_status "Running site_db migrations"
( cd $BASE_DIR/site_db &&
su $BECOME_USER -c "python ../database/migrate.py \
--database=TKO safesync"
)
# - Django syncdb
print_status "Running syncdb on Django interface"
# Due to the way Django creates permissions objects, we sometimes need
# to run syncdb twice.
for i in 1 2; do
( cd $BASE_DIR/frontend &&
su $BECOME_USER -c "python manage.py syncdb --noinput"
)
done
# --- compile GWT
print_status "Compiling GWT code."
( cd $BASE_DIR &&
su $BECOME_USER -c "$BASE_DIR/utils/compile_gwt_clients.py -a" || fatal
)
# --- fix gwt permissions
print_status "Fixing permissions"
( cd $BASE_DIR/frontend/client &&
find | xargs chmod o+r &&
find -type d | xargs chmod o+rx ) || fatal
# --- update cli repository (site-specific)
if (test -x $BASE_DIR/site_utils/site_install_cli)
then
print_status "Updating cli repository"
su $BECOME_USER -c $BASE_DIR/site_utils/site_install_cli || fatal
fi
# --- restart autotest persistent code
print_status "Restarting autotest persistent code"
$INIT_SCR start || fatal
# --- possibly restart Apache (site-specific)
if (test -x $BASE_DIR/site_utils/site_restart_apache)
then
print_status "Restarting Apache"
su $BECOME_USER -c $BASE_DIR/site_utils/site_restart_apache || fatal
fi
# --- do any site-specific finalization
if (test -x $BASE_DIR/site_utils/site_restart_final)
then
print_status "Finalizing release"
su $BECOME_USER -c $BASE_DIR/site_utils/site_restart_final || fatal
fi
|