X-Git-Url: https://git.donarmstrong.com/?p=infobot.git;a=blobdiff_plain;f=scripts%2Fprocesslog.example;fp=scripts%2Fprocesslog.example;h=fadee64b60fdb8b85caf5ec17522ad54b8b45908;hp=0000000000000000000000000000000000000000;hb=b39f7388e9970b6acebd0c0edc422554c318de76;hpb=de9ba421b308e658a84413cd17ddaedf8fead5a1 diff --git a/scripts/processlog.example b/scripts/processlog.example new file mode 100755 index 0000000..fadee64 --- /dev/null +++ b/scripts/processlog.example @@ -0,0 +1,54 @@ +#!/bin/sh + +# copy or link this to processlog to make it run when logs are rotated + +if [ -z "$1" ] ; then + echo "Syntax: $0 " + exit -1 +elif [ ! -r $file ] ; then + echo $file does not exist + exit -1 +fi + +file="`readlink -fm "$1"`" +irclog2html=`readlink -fm scripts/irclog2html.pl` +htmlcalidx=`readlink -fm scripts/htmlcalidx.sh` +# pull date out of path +date=`echo "${file}"|sed -e 's~.*\([0-9]\{4\}\)/\([0-9]\{4\}\)$~\1\2~'` +web=$HOME/web + +# delete old web pages if present (to allow re-running) +rm -f $web/$date.html $web/*/$date.html $web/$date.html.gz $web/*/$date.html.gz +# create new ones +(cd $web;${irclog2html} ${date} < $file) +# set the date to the log date +touch -r $file $web/$date.html $web/*/$date.html +# compress them +gzip -f -9 $web/$date.html $web/*/$date.html + +#don't run stats if not yesterdays log +if [ "$date" != "`date -u -d '1 day ago' +'%Y%m%d'`" ] ; then + NOSTATS=1 + NOIDX=1 +fi + +# only do stats if NOSTATS not set +if [ -z "$NOSTATS" ] ; then + cd $web/stats + [ -r .log ] && rm .log + ln -s $file .log + nice -n 20 pisg + rm .log *gz + gzip -9 *html +fi + +if [ -z "$NOSTATS" ] ; then + for a in `find $web -type d|sort` ; do + (cd $a ; ${htmlcalidx} > HEADER.html) + done + rm $web/stats/HEADER.html +fi + +if [ -z "$NOCOMPRESS" ] ; then + bzip2 -9 $file +fi