230
# Now we need to update the code and run the upgrade on the DB
231
rsync -a --delete ${SOURCEDIR}/ ${ROOTDIR}/staging/launchpad/
232
cd ${ROOTDIR}/staging/launchpad
233
make build LPCONFIG=staging >> $LOGFILE 2>&1
234
cd ${ROOTDIR}/staging/launchpad/database/schema
235
export LPCONFIG=staging
236
# Kill any connections to the DB. New ones should be stopped by the
237
# maintenance text files being in place
238
psql -U postgres -d template1 -f ${ROOTDIR}/scripts/kill_staging_connections.sql >> $LOGFILE 2>&1
240
echo $(date) "Applying database updates and permissions to DB" >> $LOGFILE
241
./upgrade.py -U postgres >> $LOGFILE 2>&1
243
echo $(date) "ERROR: Failed to run upgrade.py" >> $LOGFILE
244
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
245
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
246
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
247
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
248
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
249
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
251
# Let's email it - since it's being run from
252
# cron, just cat-ing the logfile will do this
257
echo $(date) "DB upgrades applied" >> $LOGFILE
259
./fti.py -U postgres >> $LOGFILE 2>&1
261
echo $(date) "ERROR: Failed to run fti.py" >> $LOGFILE
262
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
263
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
264
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
265
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
266
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
267
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
269
# Let's email it - since it's being run from
270
# cron, just cat-ing the logfile will do this
275
echo $(date) "Full text indexes rebuilt" >> $LOGFILE
277
./security.py -U postgres >> $LOGFILE 2>&1
279
echo $(date) "ERROR: Failed to run security.py" >> $LOGFILE
280
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
281
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
282
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
283
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
284
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
285
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
287
# Let's email it - since it's being run from
288
# cron, just cat-ing the logfile will do this
293
echo $(date) "Security applied to DB" >> $LOGFILE
295
./security.py -U postgres -d lpmain_staging_slave >> $LOGFILE 2>&1
297
echo $(date) "ERROR: Failed to run security.py on slave" >> $LOGFILE
298
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
299
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
300
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
301
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
302
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
303
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
305
# Let's email it - since it's being run from
306
# cron, just cat-ing the logfile will do this
311
echo $(date) "Security applied to slave DB" >> $LOGFILE
236
if [ "$SKIP_DB_UPDATES" = "False" ]; then
238
# Now we need to update the code and run the upgrade on the DB
239
rsync -a --delete ${SOURCEDIR}/ ${ROOTDIR}/staging/launchpad/
240
cd ${ROOTDIR}/staging/launchpad
241
make build LPCONFIG=staging >> $LOGFILE 2>&1
242
cd ${ROOTDIR}/staging/launchpad/database/schema
243
export LPCONFIG=staging
244
# Kill any connections to the DB. New ones should be stopped by the
245
# maintenance text files being in place
246
psql -U postgres -d template1 -f ${ROOTDIR}/scripts/kill_staging_connections.sql >> $LOGFILE 2>&1
248
echo $(date) "Applying database updates and permissions to DB" >> $LOGFILE
249
./upgrade.py -U postgres >> $LOGFILE 2>&1
251
echo $(date) "ERROR: Failed to run upgrade.py" >> $LOGFILE
252
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
253
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
254
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
255
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
256
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
257
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
259
# Let's email it - since it's being run from
260
# cron, just cat-ing the logfile will do this
265
echo $(date) "DB upgrades applied" >> $LOGFILE
267
./fti.py -U postgres >> $LOGFILE 2>&1
269
echo $(date) "ERROR: Failed to run fti.py" >> $LOGFILE
270
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
271
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
272
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
273
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
274
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
275
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
277
# Let's email it - since it's being run from
278
# cron, just cat-ing the logfile will do this
283
echo $(date) "Full text indexes rebuilt" >> $LOGFILE
285
./security.py -U postgres >> $LOGFILE 2>&1
287
echo $(date) "ERROR: Failed to run security.py" >> $LOGFILE
288
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
289
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
290
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
291
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
292
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
293
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
295
# Let's email it - since it's being run from
296
# cron, just cat-ing the logfile will do this
301
echo $(date) "Security applied to DB" >> $LOGFILE
303
./security.py -U postgres -d lpmain_staging_slave >> $LOGFILE 2>&1
305
echo $(date) "ERROR: Failed to run security.py on slave" >> $LOGFILE
306
psql -U postgres -d template1 -c "SELECT * FROM pg_stat_activity" >> $LOGFILE 2>&1
307
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_master_staging-setup.log \
308
${ROOTDIR}/staging-logs/lpslon_main_master_staging-setup.$(date +%Y-%m-%d-%H-%M).log
309
cp ${ROOTDIR}/staging/launchpad/database/replication/lpslon_main_slave_staging-setup.log \
310
${ROOTDIR}/staging-logs/lpslon_main_slave_staging-setup.$(date +%Y-%m-%d-%H-%M).log
311
echo "Replication logs copied to ${ROOTDIR}/staging-logs" >> $LOGFILE
313
# Let's email it - since it's being run from
314
# cron, just cat-ing the logfile will do this
319
echo $(date) "Security applied to slave DB" >> $LOGFILE
316
324
if [ "$PERFORM_REMOTE" = "True" ]