#!/bin/sh # update the SBoTools.sqlite3 for the SBoTools limnoria plugin. # should be run from cron probably daily. also can be run manually. # run this as the slackfacts user, not root. # configurables: BOTDIR=/home/slackfacts/supybot DBFILE=$BOTDIR/SBoTools.sqlite3 SCRIPT=$BOTDIR/limnoria.slackfacts.plugins/bin/sbodb.pl SBOTREE=/data/mirrors/slackbuilds.org/14.2 SQLITE3=/usr/bin/sqlite3 LOG=$BOTDIR/sbotools-update-db.log DATEFILE=$BOTDIR/sbotools-update-db.lastdate # 1st line of ChangeLog.txt is the date of the last SBo update. head -n 1 $SBOTREE/ChangeLog.txt > $DATEFILE.new # 'diff' returns true if the files are the same (non-intuitive). # if there hasn't been an SBo update since the last DB update, we # don't need to update the DB again. if [ -e $DATEFILE && diff $DATEFILE $DATEFILE.new > /dev/null ]; then rm -f $DATEFILE.new exit 0 fi ( $SCRIPT $SBOTREE | $SQLITE3 $DBFILE.update ) &> $LOG if [ "$?" = "0" ]; then mv $DBFILE.update $DBFILE.new mv $DATEFILE.new $DATEFILE rm -f $LOG exit 0 else echo "$0: update failed" cat $LOG exit 1 fi