chiark / gitweb /
xfoo => mfoo, rename
[inn-innduct.git] / contrib / makestorconf.in
1 #!/usr/local/bin/perl
2 # fixscript will replace this line with require innshellvars.pl
3
4 # Create storage.conf script based on recently read articles.
5
6 $readfile="$inn::pathdb/readgroups";
7
8 $outfile="$inn::pathdb/storage.conf";
9 outloop: 
10 for ($level=9 ; $level >= 2; --$level) {
11   # clear groups hash.
12   foreach $i (keys %groups) {
13     delete $groups{$i};
14   }
15   if (open(RDF, "sort $readfile|")) {
16     while (<RDF>) {
17       chop;
18       next if (/^group/);       # bogus 
19       @foo=split(/ /);          # foo[0] should be group, foo[1] lastreadtime
20       @bar=split(/\./,$foo[0]);
21       if ( $level >= scalar @bar) {
22         $grf = join(".", @bar);
23       } else {
24         $grf=join(".", @bar[0..($level-1)])  . ".*";
25       }
26       $groups{$grf} = 1;
27     }
28     close(RDF);
29   }
30   $grlist = join(",",keys(%groups));
31   last outloop if (length($grlist) < 2048);
32 }
33
34 open(OUT, ">$outfile") || die "cant open $outfile";
35 #open(OUT, ">/dev/tty");
36
37 print OUT <<"EOF" ;
38 method cnfs {
39         newsgroups: control,control.*
40         class: 1
41         options: MINI
42 }
43
44 method timecaf {
45         newsgroups: $grlist
46         class: 1
47 }
48
49 method cnfs {
50         newsgroups: *
51         options: MONGO
52         class: 0
53 }
54 EOF
55 close(OUT);
56 exit(0);