home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / popularity-contest / examples / popcon-process.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2005-11-08  |  1.2 KB  |  47 lines

  1. #!/bin/sh
  2.  
  3. BASEDIR=/org/popcon.debian.org/popcon-mail
  4. MAILDIR=../Mail
  5. WEBDIR=../www
  6. LOGDIR=$BASEDIR/../logs
  7. BINDIR=$BASEDIR/../bin
  8. DATADIR=$BASEDIR/popcon-entries
  9. SUMMARYDIR=$BASEDIR/all-popcon-results
  10.  
  11. # set to 'true' if email submissions should be processed
  12. READMAIL=true
  13.  
  14. # Remove entries older than # number of days
  15. DAYLIMIT=20
  16.  
  17. set -e
  18. cd $BASEDIR
  19. umask 0002
  20.  
  21. # rotate incoming mail spool files
  22. if [ true = "$READMAIL" ] ; then
  23.     mv $MAILDIR/survey new-popcon-entries
  24.     touch $MAILDIR/survey
  25.     chmod go-rwx $MAILDIR/survey
  26.  
  27.     # process entries, splitting them into individual reports
  28.     $BINDIR/prepop.pl <new-popcon-entries >$LOGDIR/prepop.out 2>&1
  29. fi
  30.  
  31. # delete outdated entries
  32. rm -f results
  33. find $DATADIR -type f -mtime +$DAYLIMIT -print0 | xargs -0 rm -f --
  34.  
  35. # Generate statistics
  36. find $DATADIR -type f | xargs cat \
  37.         | nice -15 $BINDIR/popanal.py >$LOGDIR/popanal.out 2>&1
  38. cp results $WEBDIR/all-popcon-results.txt
  39. gzip -f $WEBDIR/all-popcon-results.txt
  40. cp $WEBDIR/all-popcon-results.txt.gz $SUMMARYDIR/popcon-`date +"%Y-%m-%d"`.gz
  41.  
  42. cd ../popcon-stat
  43. find $SUMMARYDIR -type f -print | sort | $BINDIR/popcon-stat.pl
  44.  
  45. cd ../popcon-web
  46. $BINDIR/popcon.pl >$LOGDIR/popcon.log
  47.