File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # push in a new copy of the database from a dump of the master database, and
4+ # do the fixups needed to run the django apps.
5+
6+ # set -x
7+
8+ program=${0##*/ }
9+ progdir=${0%/* }
10+
11+ cd $progdir /..
12+ build=$PWD
13+
14+ function log() { logger -i -t $program -s " $* " ; }
15+ function die() { log " $* ; terminating." ; echo " $program : Error: $* " 1>&2 ; exit 1; }
16+
17+
18+ [ $DBDUMP ] || DBDUMP=/www/tools.ietf.org/events/raw/sqldump/sqldump.raw
19+ [ $DBFIX ] || DBFIX=$build /test/sql_fixup.sql
20+
21+ LOCKDIR=/var/lock/ietfdb
22+ PIDFILE=$LOCKDIR /pid
23+
24+ while true ; do
25+ if mkdir $LOCKDIR ; then
26+ echo " $$ " > $PIDFILE
27+ log " Updating local database from $DBDUMP ..."
28+ python ietf/manage.py dbshell < $DBDUMP
29+ log " Updating local database from $DBFIX ..."
30+ python ietf/manage.py dbshell < $DBFIX
31+ log " Running Django syncdb ..."
32+ python ietf/manage.py syncdb
33+ log " Done."
34+ rm -rf $LOCKDIR
35+ exit 0
36+ else
37+ pid=$( < $PIDFILE ) || die " Couldn't read pidfile '$PIDFILE '"
38+ if kill -0 $pid ; then
39+ log " Pidfile for process $pid exists, and process is running. Sleeping."
40+ sleep 10
41+ else
42+ log " Pidfile for process $pid exists, but process isn't running."
43+ log " Removing lock and old pid file $pidfile ."
44+ rm -rf $LOCKDIR
45+ fi
46+ fi
47+ done
You can’t perform that action at this time.
0 commit comments