blob: eadf8c3de6294cd8a1a94092d9139d2a7b6a02c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/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/15.0
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
|