]> git.donarmstrong.com Git - infobot.git/blob - scripts/processlog.example
dunno
[infobot.git] / scripts / processlog.example
1 #!/bin/sh
2
3 # copy or link this to processlog to make it run when logs are rotated
4
5 if [ -z "$1" ] ; then
6  echo "Syntax: $0 <file>"
7  exit -1
8 elif [ ! -r $file ] ; then
9  echo $file does not exist
10  exit -1
11 fi
12
13 file="`readlink -fm "$1"`"
14 irclog2html=`readlink -fm scripts/irclog2html.pl`
15 htmlcalidx=`readlink -fm scripts/htmlcalidx.sh`
16 # pull date out of path
17 date=`echo "${file}"|sed -e 's~.*\([0-9]\{4\}\)/\([0-9]\{4\}\)$~\1\2~'`
18 web=$HOME/web
19
20 # delete old web pages if present (to allow re-running)
21 rm -f $web/$date.html $web/*/$date.html $web/$date.html.gz $web/*/$date.html.gz
22 # create new ones
23 (cd $web;${irclog2html} ${date} < $file)
24 # set the date to the log date
25 touch -r $file $web/$date.html $web/*/$date.html
26 # compress them
27 gzip -f -9 $web/$date.html $web/*/$date.html
28
29 #don't run stats if not yesterdays log
30 if [ "$date" != "`date -u -d '1 day ago' +'%Y%m%d'`" ] ; then
31  NOSTATS=1
32  NOIDX=1
33 fi
34
35 # only do stats if NOSTATS not set
36 if [ -z "$NOSTATS" ] ; then
37  cd $web/stats
38  [ -r .log ] && rm .log
39  ln -s $file .log
40  nice -n 20 pisg
41  rm .log *gz
42  gzip -9 *html
43 fi
44
45 if [ -z "$NOSTATS" ] ; then
46  for a in `find $web -type d|sort` ; do
47   (cd $a ; ${htmlcalidx} > HEADER.html)
48  done
49  rm $web/stats/HEADER.html
50 fi
51
52 if [ -z "$NOCOMPRESS" ] ; then
53  bzip2 -9 $file
54 fi