File: makeexpctl.in

package info (click to toggle)
inn2 2.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,720 kB
  • ctags: 8,983
  • sloc: ansic: 92,499; sh: 13,509; perl: 12,921; makefile: 2,985; yacc: 842; python: 342; lex: 255
file content (82 lines) | stat: -rw-r--r-- 2,713 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /usr/bin/perl -w
# fixscript will replace this line with code to load INN::Config

# Create expire.ctl script based on recently read articles.  Argument gives
# scale factor to use to adjust expires.

$readfile="$INN::Config::pathdb/readgroups";
$expirectl=$INN::Config::expirectl;

$curtime = time;
$oldtime = $curtime - 30 * 86400; # 30 days in the past

if (open(RDF, $readfile)) {
    while (<RDF>) {
	chop;
	@foo=split(/ /); # foo[0] should be group, foo[1] lastreadtime
	if ($foo[1] < $oldtime) {
	    next; # skip entries that are too old.
	}
	$groups{$foo[0]} = $foo[1];
    }
    close(RDF);
}

$scale = $ARGV[0];
if ($scale <= 0) {
    die "invalid scale parameter\n";
}

rename($expirectl, "$expirectl.OLD") || die "rename $expirectl failed!\n";
open(OUTFILE, ">$expirectl") || die "open $expirectl for write failed!\n";

print OUTFILE <<'EOF' ;
##  expire.ctl - expire control file
##  Format:
##	/remember/:<keep>
##	<patterns>:<modflag>:<keep>:<default>:<purge>
##  First line gives history retention; other lines specify expiration
##  for newsgroups.  Must have a "*:A:..." line which is the default.
##	<patterns>	Wildmat-style patterns for the newsgroups
##	<modflag>	Pick one of M U A -- modifies pattern to be only
##			moderated, unmoderated, or all groups
##	<keep>		Minimum number of days to keep article
##	<default>	Default number of days to keep the article
##	<purge>		Flush article after this many days
##  <keep>, <default>, and <purge> can be floating-point numbers or the
##  word "never".  Times are based on the arrival time for expire and expireover
##  (unless -p is used; see expire(8) and expireover(8)), and on the posting
##  time for history retention.
##
##  See the expire.ctl man page for more information.

# How long to remember old history entries for.
/remember/:11
#
EOF

# defaults for most groups.
printline("*", "A", 1);
printline("alt*,misc*,news*,rec*,sci*,soc*,talk*,vmsnet*","U",3);
printline("alt*,misc*,news*,rec*,sci*,soc*,talk*,vmsnet*","M",5);
printline("comp*,gnu*,info*,ok*,ecn*,uok*", "U", 5);
printline("comp*,gnu*,info*,ok*,ecn*,uok*", "M", 7);
# and now handle each group that's regularly read, 
# assinging them 3* normal max expire
foreach $i (keys %groups) {
    printline($i, "A", 21);
}
# and now put some overrides for groups which are too likely to fill spool if
# we let them go to autoexpire. 
printline("*binaries*,*pictures*", "A", 0.5);
printline("control*","A",1);
printline("control.cancel","A",0.5);
printline("news.lists.filters,alt.nocem.misc","A",1);

close(OUTFILE);
exit(1);

sub printline {
    local($grpstr, $mflag, $len) = @_;
    print OUTFILE $grpstr,":",$mflag,":",$len*$scale,":",$len*$scale,":",$len*$scale,"\n";
}