]> Pileus Git - ~andy/fetchmail/blob - contrib/gotmail
Merge branch 'legacy_63'
[~andy/fetchmail] / contrib / gotmail
1 #------------------------------------------------------------------------------
2 #
3 #               GotMail - Statistics Printing Script for GetMail
4 #
5 #             1999 by Thomas Nesges <ThomaNesges@TNT-Computer.de>
6 #
7 #------------------------------------------------------------------------------
8
9 #------------------------------------------------------------------------------
10 # GotMail reads a GetMail logfile (/var/log/fetchmail.log) and prints
11 # statistics from all sessions logged in it, either as normal text on the
12 # Console, or as an html-file. The parsing is done with the awk-scripts
13 # gotmail.awk and gotmail.html.awk.
14 # You can configure its output with a file gotmail.conf either in your home,
15 # /etc, or in /usr/local/gotmail.
16 #
17 # GetMail has to be properly installed. For HTML output the htmllib has to be
18 # installed in /usr/local/htmllib.
19 #
20 # If you have any changes/corrections in the script, please send me email.
21 #------------------------------------------------------------------------------
22
23
24 #!/bin/sh
25
26 # Gotmail
27 # 1999 by Thomas Nesges <ThomasNesges@TNT-Computer.de>
28
29 # read the configuration
30 # the configuration can either be
31 #  ~/.gotmail.conf
32 #  /etc/gotmail.conf
33 #  /usr/local/gotmail/gotmail.conf
34 if { test -e ~/.gotmail.conf; };
35     then { source ~/.gotmail.conf; };
36     else { if { test -e /etc/gotmail.conf; }; 
37           then { source /etc/gotmail.conf; };
38           else { if { test -e /usr/local/gotmail/gotmail.conf; };
39           then { source /usr/local/gotmail/gotmail.conf; };
40                  else { echo 'Error: gotmail.conf could not be read';
41                         echo 'gotmail exits now..';
42                         exit; };
43                  fi; };
44           fi; };
45 fi;
46
47
48 # grep the fetchmail.log for relevant messages and save them in
49 # gotmails tempfile
50 cat /var/log/fetchmail.log | grep 'message' >> /tmp/gotmail.log.tmp
51 cat /var/log/fetchmail.log | grep 'Authorization' >> /tmp/gotmail.log.tmp
52 cat /var/log/fetchmail.log | grep 'fetchmail st' >> /tmp/gotmail.log.tmp
53
54
55 # parse the gotmail tempfile and prints a statistiks-screen
56 case "$1" in
57   html)
58     awk -f /usr/local/htmllib/htmllib.awk -f /usr/local/gotmail/gotmail.html.awk /tmp/gotmail.log.tmp > /dev/null
59     ;;
60   -v)
61     echo 'gotmail version: 0.0.1'
62     ;;
63   *)
64     awk -f /usr/local/gotmail/gotmail.awk /tmp/gotmail.log.tmp
65     ;;
66 esac
67
68 # remove the gotmail tempfile
69 rm /tmp/gotmail.log.tmp