chiark / gitweb /
break out allow_connect_start
[inn-innduct.git] / contrib / findreadgroups.in
1 #!/usr/local/bin/perl
2 # fixscript will replace this line with require innshellvars.pl
3
4 # Keep track of which groups are currently being read.  Takes logfile input
5 # on stdin.
6 $readfile="$inn::newsetc/readgroups";
7
8 $curtime = time;
9 $oldtime = $curtime - 30 * 86400; # 30 days in the past
10
11 if (open(RDF, $readfile)) {
12     while (<RDF>) {
13         chop;
14         @foo=split(/ /); # foo[0] should be group, foo[1] lastreadtime
15         if ($foo[1] < $oldtime) {
16             next; # skip entries that are too old.
17         }
18         $groups{$foo[0]} = $foo[1];
19     }
20     close(RDF);
21 }
22
23 # read input logs.
24 while (<>) {
25     next unless /nnrpd/;
26     next unless / group /;
27     chop;
28     @foo = split(/ +/);
29     # group name is in the 8th field.
30     $groups{$foo[7]} = $curtime;
31 }
32
33 open(WRF, ">$readfile") || die "cannot open $readfile for write.\n";
34 foreach $i (keys %groups) {
35     print WRF $i, " ", $groups{$i}, "\n";
36 }
37
38 exit(0);