#!/bin/bash
export LANG=en_US.UTF-8 # need for dbf module's locale detection
DIR=`dirname $0`
# files exist
if [[ -s $DIR/family.dbf && -s $DIR/member.dbf ]]
then
source $DIR/../python_virtualenv/bin/activate
echo `date` - running the logos2web update >> $DIR/update.log
python $DIR/update.py "$@"
echo `date` - deleting dbf files >> $DIR/update.log
rm $DIR/*.dbf
# log is older than 3 days
elif [[ `find $DIR/update.log -mtime +3` ]]
then
msg="`date` - No database files processed since `stat -c '%y' $DIR/update.log`"
# for cron output -> mail
echo $msg
# to update the log, so this doesn't trigger again for a while
echo $msg >> $DIR/update.log
fi