Only run the database update if there is a new dump
- Legacy-Id: 377
This commit is contained in:
parent
95a629020f
commit
5ad4c9fc3a
|
@ -15,22 +15,29 @@ function log() { logger -i -t $program -s "$*"; }
|
||||||
function die() { log "$*; terminating."; echo "$program: Error: $*" 1>&2; exit 1; }
|
function die() { log "$*; terminating."; echo "$program: Error: $*" 1>&2; exit 1; }
|
||||||
|
|
||||||
|
|
||||||
|
[ $DBDUMP ] || DBDUMP="$1"
|
||||||
[ $DBDUMP ] || DBDUMP=/www/tools.ietf.org/events/raw/sqldump/sqldump.raw
|
[ $DBDUMP ] || DBDUMP=/www/tools.ietf.org/events/raw/sqldump/sqldump.raw
|
||||||
[ $DBFIX ] || DBFIX=$build/test/sql_fixup.sql
|
[ $DBFIX ] || DBFIX=$build/test/sql_fixup.sql
|
||||||
|
[ $DBTIME ] || DBTIME=$build/update-db.time
|
||||||
|
|
||||||
LOCKDIR=/var/lock/ietfdb
|
LOCKDIR=/var/lock/ietfdb
|
||||||
PIDFILE=$LOCKDIR/pid
|
PIDFILE=$LOCKDIR/pid
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if mkdir $LOCKDIR; then
|
if mkdir $LOCKDIR; then
|
||||||
echo "$$" > $PIDFILE
|
if [ $DBDUMP -nt $DBTIME ]; then
|
||||||
log "Updating local database from $DBDUMP ..."
|
echo "$$" > $PIDFILE
|
||||||
python ietf/manage.py dbshell < $DBDUMP
|
log "Updating local database from $DBDUMP ..."
|
||||||
log "Updating local database from $DBFIX ..."
|
python ietf/manage.py dbshell < $DBDUMP
|
||||||
python ietf/manage.py dbshell < $DBFIX
|
log "Updating local database from $DBFIX ..."
|
||||||
log "Running Django syncdb ..."
|
python ietf/manage.py dbshell < $DBFIX
|
||||||
python ietf/manage.py syncdb
|
log "Running Django syncdb ..."
|
||||||
log "Done."
|
python ietf/manage.py syncdb
|
||||||
|
touch -r $DBDUMP $DBTIME
|
||||||
|
log "Done."
|
||||||
|
else
|
||||||
|
log "Database dump not newer than at previous update. Quitting."
|
||||||
|
fi
|
||||||
rm -rf $LOCKDIR
|
rm -rf $LOCKDIR
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue