Changed packaging.
[usenet/yapfaq.git] / yapfaq.pl
... / ...
CommitLineData
1#! /usr/bin/perl -W
2#
3# yapfaq Version 0.8.1 by Thomas Hochstein
4# (Original author: Marc Brockschmidt)
5#
6# This script posts any project described in its config-file. Most people
7# will use it in combination with cron(8).
8#
9# Copyright (C) 2003 Marc Brockschmidt <marc@marcbrockschmidt.de>
10# Copyright (c) 2010 Thomas Hochstein <thh@inter.net>
11#
12# It can be redistributed and/or modified under the same terms under
13# which Perl itself is published.
14
15our $VERSION = "0.9-prelease";
16
17# Please do not change this setting!
18# You may override the default .rc file (.yapfaqrc) by using "-c .rc file"
19my $RCFile = '.yapfaqrc';
20# Valid configuration variables for use in a .rc file
21my @ValidConfVars = ('NNTPServer','NNTPUser','NNTPPass','Sender','ConfigFile','Program');
22
23################################### Defaults ###################################
24# Please do not change anything in here!
25# Use a runtime configuration file (.yapfaqrc by default) to override defaults.
26my %Config = (NNTPServer => "",
27 NNTPUser => "",
28 NNTPPass => "",
29 Sender => "",
30 ConfigFile => "yapfaq.cfg",
31 Program => "");
32
33################################# Main program #################################
34
35use strict;
36use Net::NNTP;
37use Net::Domain qw(hostfqdn);
38use Date::Calc qw(Add_Delta_YM Add_Delta_Days Delta_Days Today);
39use Fcntl ':flock'; # import LOCK_* constants
40use Getopt::Std;
41$Getopt::Std::STANDARD_HELP_VERSION = 1;
42my ($TDY, $TDM, $TDD) = Today(); #TD: Today's date
43
44# read commandline options
45my %Options;
46getopts('Vhvpdt:f:c:s:', \%Options);
47# -V: print version / copyright information
48if ($Options{'V'}) {
49 print "$0 v $VERSION\nCopyright (c) 2003 Marc Brockschmidt <marc\@marcbrockschmidt.de>\nCopyright (c) 2010 Thomas Hochstein <thh\@inter.net>\n";
50 print "This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.\n";
51 exit(0);
52}
53# -h: feed myself to perldoc
54if ($Options{'h'}) {
55 exec ('perldoc', $0);
56 exit(0);
57};
58# -f: set $Faq
59my ($Faq) = $Options{'f'} if ($Options{'f'});
60
61# read runtime configuration (configuration variables)
62$RCFile = $Options{'c'} if ($Options{'c'});
63if (-f $RCFile) {
64 readrc (\$RCFile,\%Config);
65} else {
66 warn "$0: W: .rc file $RCFile does not exist!\n";
67}
68
69$Options{'s'} = $Config{'Program'} if (defined($Config{'Program'}) && $Config{'Program'} && !defined($Options{'s'}));
70
71# read configuration (configured FAQs)
72my @Config;
73readconfig (\$Config{'ConfigFile'}, \@Config, \$Faq);
74
75# for each FAQ:
76# - parse configuration
77# - read status data
78# - if FAQ is due: call postfaq()
79foreach (@Config) {
80 my ($LPD,$LPM,$LPY) = (01, 01, 0001); #LP: Last posting-date
81 my ($NPY,$NPM,$NPD); #NP: Next posting-date
82 my $SupersedeMID;
83
84 my ($ActName,$File,$PFreq,$Expire) =($$_{'name'},$$_{'file'},$$_{'posting-frequency'},$$_{'expires'});
85 my ($From,$Subject,$NG,$Fup2)=($$_{'from'},$$_{'subject'},$$_{'ngs'},$$_{'fup2'});
86 my ($MIDF,$ReplyTo,$ExtHea)=($$_{'mid-format'},$$_{'reply-to'},$$_{'extraheader'});
87 my ($Supersede) =($$_{'supersede'});
88
89 # -f: loop if not FAQ to post
90 next if (defined($Faq) && $ActName ne $Faq);
91
92 # read status data
93 if (open (FH, "<$File.cfg")) {
94 while(<FH>){
95 if (/##;; Lastpost:\s*(\d{1,2})\.(\d{1,2})\.(\d{2}(\d{2})?)/){
96 ($LPD, $LPM, $LPY) = ($1, $2, $3);
97 } elsif (/^##;;\s*LastMID:\s*(<\S+@\S+>)\s*$/) {
98 $SupersedeMID = $1;
99 }
100 }
101 close FH;
102 } else {
103 warn "$0: W: Couldn't open $File.cfg: $!\n";
104 }
105
106 $SupersedeMID = "" unless $Supersede;
107
108 ($NPY,$NPM,$NPD) = calcdelta ($LPY,$LPM,$LPD,$PFreq);
109
110 # if FAQ is due: get it out
111 if (Delta_Days($NPY,$NPM,$NPD,$TDY,$TDM,$TDD) >= 0 or ($Options{'p'})) {
112 if($Options{'d'}) {
113 print "$ActName: Would be posted now (but running in simulation mode [$0 -d]).\n" if $Options{'v'};
114 } else {
115 postfaq(\$ActName,\$File,\$From,\$Subject,\$NG,\$Fup2,\$MIDF,\$ExtHea,\$Config{'Sender'},\$TDY,\$TDM,\$TDD,\$ReplyTo,\$SupersedeMID,\$Expire);
116 }
117 } elsif($Options{'v'}) {
118 print "$ActName: Nothing to do.\n";
119 }
120}
121
122exit;
123
124#################################### readrc ####################################
125# Takes a filename and the reference to an array which contains the valid options
126
127sub readrc{
128 my ($File, $Config) = @_;
129
130 print "Reading $$File.\n" if($Options{'v'});
131
132 open FH, "<$$File" or die "$0: Can't open $$File: $!";
133 while (<FH>) {
134 if (/^\s*(\S+)\s*=\s*'?(.*?)'?\s*(#.*$|$)/) {
135 if (grep(/$1/,@ValidConfVars)) {
136 $$Config{$1} = $2 if $2 ne '';
137 } else {
138 warn "$0: W: $1 is not a valid configuration variable (reading from $$File)\n";
139 }
140 }
141 }
142}
143
144################################## readconfig ##################################
145# Takes a filename, a reference to an array, which will hold hashes with
146# the data from $File, and - optionally - the name of the (single) FAQ to post
147
148sub readconfig{
149 my ($File, $Config, $Faq) = @_;
150 my ($LastEntry, $Error, $i) = ('','',0);
151
152 print "Reading configuration from $$File.\n" if($Options{'v'});
153
154 open FH, "<$$File" or die "$0: E: Can't open $$File: $!";
155 while (<FH>) {
156 next if (defined($$Faq) && !/^\s*=====\s*$/ && defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} ne $$Faq );
157 if (/^(\s*(\S+)\s*=\s*'?(.*?)'?\s*(#.*$|$)|^(.*?)'?\s*(#.*$|$))/ && not /^\s*$/) {
158 $LastEntry = lc($2) if $2;
159 $$Config[$i]{$LastEntry} .= $3 if $3;
160 $$Config[$i]{$LastEntry} .= "\n$5" if $5 && $5;
161 }
162 if (/^\s*=====\s*$/) {
163 $i++;
164 }
165 }
166 close FH;
167
168 #Check saved values:
169 for $i (0..$i){
170 next if (defined($$Faq) && defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} ne $$Faq );
171 unless(defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} =~ /^\S+$/) {
172 $Error .= "E: The name of your project \"$$Config[$i]{'name'}\" is not defined or contains whitespaces.\n"
173 }
174 unless(defined($$Config[$i]{'file'}) && -f $$Config[$i]{'file'}) {
175 $Error .= "E: The file to post for your project \"$$Config[$i]{'name'}\" is not defined or does not exist.\n"
176 }
177 unless(defined($$Config[$i]{'from'}) && $$Config[$i]{'from'} =~ /\S+\@(\S+\.)?\S{2,}\.\S{2,}/) {
178 $Error .= "E: The From header for your project \"$$Config[$i]{'name'}\" seems to be incorrect.\n"
179 }
180 unless(defined($$Config[$i]{'ngs'}) && $$Config[$i]{'ngs'} =~ /^\S+$/) {
181 $Error .= "E: The Newsgroups header for your project \"$$Config[$i]{'name'}\" is not defined or contains whitespaces.\n"
182 }
183 unless(defined($$Config[$i]{'subject'})) {
184 $Error .= "E: The Subject header for your project \"$$Config[$i]{'name'}\" is not defined.\n"
185 }
186 unless(!$$Config[$i]{'fup2'} || $$Config[$i]{'fup2'} =~ /^\S+$/) {
187 $Error .= "E: The Followup-To header for your project \"$$Config[$i]{'name'}\" contains whitespaces.\n"
188 }
189 unless(defined($$Config[$i]{'posting-frequency'}) && $$Config[$i]{'posting-frequency'} =~ /^\s*\d+\s*[dwmy]\s*$/) {
190 $Error .= "E: The Posting-frequency for your project \"$$Config[$i]{'name'}\" is invalid.\n"
191 }
192 unless(!$$Config[$i]{'expires'} || $$Config[$i]{'expires'} =~ /^\s*\d+\s*[dwmy]\s*$/) {
193 warn "$0: W: The Expires for your project \"$$Config[$i]{'name'}\" is invalid - set to 3 month.\n";
194 $$Config[$i]{'expires'} = '3m'; # set default (3 month) if expires is unset or invalid
195 }
196 unless(!$$Config[$i]{'mid-format'} || $$Config[$i]{'mid-format'} =~ /^<\S+\@(\S+\.)?\S{2,}\.\S{2,}>/) {
197 warn "$0: W: The Message-ID format for your project \"$$Config[$i]{'name'}\" seems to be invalid - set to default.\n";
198 $$Config[$i]{'mid-format'} = '<%n-%y-%m-%d@'.hostfqdn.'>'; # set default if mid-format is invalid
199 }
200 }
201 $Error .= "-" x 25 . 'program terminated' . "-" x 25 . "\n" if $Error;
202 die $Error if $Error;
203}
204
205################################# calcdelta #################################
206# Takes a date (year, month and day) and a time period (1d, 1w, 1m, 1y, ...)
207# and adds the latter to the former
208
209sub calcdelta {
210 my ($Year, $Month, $Day, $Period) = @_;
211 my ($NYear, $NMonth, $NDay);
212
213 if ($Period =~ /(\d+)\s*([dw])/) { # Is counted in days or weeks: Use Add_Delta_Days.
214 ($NYear, $NMonth, $NDay) = Add_Delta_Days($Year, $Month, $Day, (($2 eq "w")?$1 * 7: $1 * 1));
215 } elsif ($Period =~ /(\d+)\s*([my])/) { #Is counted in months or years: Use Add_Delta_YM
216 ($NYear, $NMonth, $NDay) = Add_Delta_YM($Year, $Month, $Day, (($2 eq "m")?(0,$1):($1,0)));
217 }
218 return ($NYear, $NMonth, $NDay);
219}
220
221################################ updatestatus ###############################
222# Takes a MID and a status file name
223# and writes status information to disk
224
225sub updatestatus {
226 my ($ActName, $File, $date, $MID) = @_;
227
228 print "$$ActName: Save status information.\n" if($Options{'v'});
229
230 open (FH, ">$$File.cfg") or die "$0: E: Can't open $$File.cfg: $!";
231 print FH "##;; Lastpost: $date\n";
232 print FH "##;; LastMID: $MID\n";
233 close FH;
234}
235
236################################## postfaq ##################################
237# Takes a filename and many other vars.
238#
239# It reads the data-file $File and then posts the article.
240
241sub postfaq {
242 my ($ActName,$File,$From,$Subject,$NG,$Fup2,$MIDF,$ExtraHeaders,$Sender,$TDY,$TDM,$TDD,$ReplyTo,$Supersedes,$Expire) = @_;
243 my (@Header,@Body,$MID,$InRealBody,$LastModified);
244
245 print "$$ActName: Preparing to post.\n" if($Options{'v'});
246
247 #Prepare MID:
248 $$TDM = ($$TDM < 10 && $$TDM !~ /^0/) ? "0" . $$TDM : $$TDM;
249 $$TDD = ($$TDD < 10 && $$TDD !~ /^0/) ? "0" . $$TDD : $$TDD;
250 my $Timestamp = time;
251
252 $MID = $$MIDF;
253 $MID = '<%n-%y-%m-%d@'.hostfqdn.'>' if !defined($MID); # set to default if unset
254 $MID =~ s/\%n/$$ActName/g;
255 $MID =~ s/\%d/$$TDD/g;
256 $MID =~ s/\%m/$$TDM/g;
257 $MID =~ s/\%y/$$TDY/g;
258 $MID =~ s/\%t/$Timestamp/g;
259
260 #Now get the body:
261 open (FH, "<$$File");
262 while (<FH>){
263 s/\r//;
264 push (@Body, $_), next if $InRealBody;
265 $InRealBody++ if /^$/;
266 $LastModified = $1 if /^Last-modified:\s*(\S+)\s*$/i;
267 push @Body, $_;
268 }
269 close FH;
270 push @Body, "\n" if ($Body[-1] ne "\n");
271
272 #Create Date- and Expires-Header:
273 my @time = localtime;
274 my $ss = ($time[0]<10) ? "0" . $time[0] : $time[0];
275 my $mm = ($time[1]<10) ? "0" . $time[1] : $time[1];
276 my $hh = ($time[2]<10) ? "0" . $time[2] : $time[2];
277 my $day = $time[3];
278 my $month = ($time[4]+1<10) ? "0" . ($time[4]+1) : $time[4]+1;
279 my $monthN = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$time[4]];
280 my $wday = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")[$time[6]];
281 my $year = (1900 + $time[5]);
282 my $tz = $time[8] ? " +0200" : " +0100";
283
284 $$Expire = '3m' if !$$Expire; # set default if unset: 3 month
285
286 my ($expY,$expM,$expD) = calcdelta ($year,$month,$day,$$Expire);
287 my $expmonthN = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$expM-1];
288
289 my $date = "$day $monthN $year " . $hh . ":" . $mm . ":" . $ss . $tz;
290 my $expdate = "$expD $expmonthN $expY $hh:$mm:$ss$tz";
291
292 #Replace %LM by the content of the news.answer-pseudo-header Last-modified:
293 if ($LastModified) {
294 $$Subject =~ s/\%LM/$LastModified/;
295 } else {
296 $$Subject =~ s/[<\[{\(]?\%LM[>\]}\)]?//;
297 }
298
299 # Test mode?
300 if($Options{'t'} and $Options{'t'} !~ /console/i) {
301 $$NG = $Options{'t'};
302 $MID =~ s/@/-$Timestamp-test@/g;
303 $$ExtraHeaders .= "\n" if $$ExtraHeaders;
304 $$ExtraHeaders .= "X-Supersedes: $$Supersedes\nX-yapfaq-Remark: This is only a test message.";
305 undef $$Supersedes;
306 }
307
308 #Now create the complete Header:
309 push @Header, "From: $$From\n";
310 push @Header, "Newsgroups: $$NG\n";
311 push @Header, "Followup-To: $$Fup2\n" if $$Fup2;
312 push @Header, "Subject: $$Subject\n";
313 push @Header, "Message-ID: $MID\n";
314 push @Header, "Supersedes: $$Supersedes\n" if $$Supersedes;
315 push @Header, "Date: $date\n";
316 push @Header, "Expires: $expdate\n";
317 push @Header, "Sender: $$Sender\n" if $$Sender;
318 push @Header, "Mime-Version: 1.0\n";
319 push @Header, "Reply-To: $$ReplyTo\n" if $$ReplyTo;
320 push @Header, "Content-Type: text/plain; charset=ISO-8859-15\n";
321 push @Header, "Content-Transfer-Encoding: 8bit\n";
322 push @Header, "User-Agent: yapfaq/$VERSION\n";
323 if ($$ExtraHeaders) {
324 push @Header, "$_\n" for (split /\n/, $$ExtraHeaders);
325 }
326
327 my @Article = (@Header, "\n", @Body);
328
329 # post article
330 print "$$ActName: Posting article ...\n" if($Options{'v'});
331 my $failure = post(\@Article);
332
333 if ($failure) {
334 print "$$ActName: Posting failed, ERROR.dat may have more information.\n" if($Options{'v'} && (!defined($Options{'t'}) || $Options{'t'} !~ /console/i));
335 } else {
336 updatestatus($ActName, $File, "$day.$month.$year", $MID) if !defined($Options{'t'});
337 }
338}
339
340################################## post ##################################
341# Takes a complete article (Header and Body).
342#
343# It opens a connection to $NNTPServer and posts the message.
344
345sub post {
346 my ($ArticleR) = @_;
347 my ($failure) = -1;
348
349 # test mode - print article to console
350 if(defined($Options{'t'}) and $Options{'t'} =~ /console/i) {
351 print "-----BEGIN--------------------------------------------------\n";
352 print @$ArticleR;
353 print "------END---------------------------------------------------\n";
354 # pipe article to script
355 } elsif(defined($Options{'s'})) {
356 open (POST, "| $Options{'s'}") or die "$0: E: Cannot fork $Options{'s'}: $!\n";
357 print POST @$ArticleR;
358 close POST;
359 if ($? == 0) {
360 $failure = 0;
361 } else {
362 warn "$0: W: $Options{'s'} exited with status ", ($? >> 8), "\n";
363 $failure = $?;
364 }
365 # post article
366 } else {
367 my $NewsConnection = Net::NNTP->new($Config{'NNTPServer'}, Reader => 1) or die "$0: E: Can't connect to news server '$Config{'NNTPServer'}'!\n";
368 $NewsConnection->authinfo ($Config{'NNTPUser'}, $Config{'NNTPPass'}) if (defined($Config{'NNTPUser'}));
369 $NewsConnection->post();
370 $NewsConnection->datasend (@$ArticleR);
371 $NewsConnection->dataend();
372
373 if ($NewsConnection->ok()) {
374 $failure = 0;
375 # Posting failed? Save to ERROR.dat
376 } else {
377 warn "$0: W: Posting failed!\n";
378 open FH, ">>ERROR.dat";
379 print FH "\nPosting failed! Saving to ERROR.dat. Response from news server:\n";
380 print FH $NewsConnection->code();
381 print FH $NewsConnection->message();
382 print FH "\n";
383 print FH @$ArticleR;
384 print FH "-" x 80, "\n";
385 close FH;
386 }
387 $NewsConnection->quit();
388 }
389 return $failure;
390}
391
392__END__
393
394################################ Documentation #################################
395
396=head1 NAME
397
398yapfaq - Post Usenet FAQs I<(yet another postfaq)>
399
400=head1 SYNOPSIS
401
402B<yapfaq> [B<-Vhvpd>] [B<-t> I<newsgroups> | CONSOLE] [B<-f> I<project name>] [B<-s> I<program>] [B<-c> I<.rc file>]
403
404=head1 REQUIREMENTS
405
406=over 2
407
408=item -
409
410Perl 5.8 or later
411
412=item -
413
414Net::NNTP
415
416=item -
417
418Date::Calc
419
420=item -
421
422Getopt::Std
423
424=back
425
426Furthermore you need access to a news server to actually post FAQs.
427
428=head1 DESCRIPTION
429
430B<yapfaq> posts (one or more) FAQs to Usenet with a certain posting
431frequency (every n days, weeks, months or years), adding all necessary
432headers as defined in its config file (by default F<yapfaq.cfg>).
433
434=head2 Configuration
435
436F<yapfaq.cfg> consists of one or more blocks, separated by C<=====> on
437a single line, each containing the configuration for one FAQ as a set
438of definitions in the form of I<param = value>. Everything after a "#"
439sign is ignored so you may comment your configuration file.
440
441=over 4
442
443=item B<Name> = I<project name>
444
445A name referring to your FAQ, also used for generation of a Message-ID.
446
447This value must be set.
448
449=item B<File> = I<file name>
450
451A file containing the message body of your FAQ and all pseudo headers
452(subheaders in the news.answers style).
453
454This value must be set.
455
456=item B<Posting-frequency> = I<time period>
457
458The posting frequency defines how often your FAQ will be posted.
459B<yapfaq> will only post your FAQ if this period of time has passed
460since the last posting.
461
462You can declare that time period either in I<B<d>ays> or I<B<w>weeks>
463or I<B<m>onths> or I<B<y>ears>.
464
465This value must be set.
466
467=item B<Expires> = I<time period> (optional)
468
469The period of time after which your message will expire. An Expires
470header will be calculated adding this time period to today's date.
471
472You can declare this time period either in I<B<d>ays> or I<B<w>weeks>
473or I<B<m>onths> or I<B<y>ears>.
474
475This setting is optional; the default is 3 months.
476
477=item B<From> = I<author>
478
479The author of your FAQ as it will appear in the From header of the
480message.
481
482This value must be set.
483
484=item B<Subject> = I<subject>
485
486The title of your FAQ as it will appear in the Subject header of the
487message.
488
489You may use the special string C<%LM> which will be replaced with
490the contents of the Last-Modified subheader in your I<File>.
491
492This value must be set.
493
494=item B<NGs> = I<newsgroups>
495
496A comma-separated list of newsgroup(s) to post your FAQ to as it will
497appear in the Newsgroups header of the message.
498
499This value must be set.
500
501=item B<Fup2> = I<newsgroup | poster> (optional)
502
503A comma-separated list of newsgroup(s) or the special string I<poster>
504as it will appear in the Followup-To header of the message.
505
506This setting is optional.
507
508=item B<MID-Format> = I<pattern> (optional)
509
510A pattern from which the message ID is generated as it will appear in
511the Message-ID header of the message.
512
513You may use the special strings C<%n> for the I<Name> of your project,
514C<%d> for the date the message is posted, C<%m> for the month, C<%y>
515for the year and C<%t> for a time stamp (number of seconds since the
516epoch), respectively.
517
518This setting is optional; the default is '<%n-%y-%m-%d@I<YOURHOST>>'
519where I<YOURHOST> is the fully qualified domain name (FQDN) of the
520host B<yapfaq> is running on. Obviously that will only work if you
521have defined a reasonable hostname that the hostfqdn() function of
522Net::Domain can return.
523
524=item B<Supersede> = I<yes> (optional)
525
526Add Supersedes header to the message containing the Message-ID header
527of the last posting.
528
529This setting is optional; you should set it to yes or leave it out.
530
531=item B<ExtraHeader> = I<additional headers> (optional)
532
533The contents of I<ExtraHeader> is added verbatim to the headers of
534your message so you can add custom headers like Approved.
535
536This setting is optional.
537
538=back
539
540=head3 Example configuration file
541
542 # name of your project
543 Name = 'testpost'
544
545 # file to post (complete body and pseudo-headers)
546 # ($File.cfg contains data on last posting and last MID)
547 File = 'test.txt'
548
549 # how often your project should be posted
550 # use (d)ay OR (w)eek OR (m)onth OR (y)ear
551 Posting-frequency = '1d'
552
553 # time period after which the posting should expire
554 # use (d)ay OR (w)eek OR (m)onth OR (y)ear
555 # Expires = '3m'
556
557 # header "From:"
558 From = 'test@domain.invalid'
559
560 # header "Subject:"
561 # (may contain "%LM" which will be replaced by the contents of the
562 # Last-Modified pseudo header).
563 Subject = 'test noreply ignore'
564
565 # comma-separated list of newsgroup(s) to post to
566 # (header "Newsgroups:")
567 NGs = 'de.test'
568
569 # header "Followup-To:"
570 # Fup2 = 'poster'
571
572 # Message-ID ("%n" is $Name)
573 # MID-Format = '<%n-%d.%m.%y@domain.invalid>'
574
575 # Supersede last posting?
576 Supersede = yes
577
578 # extra headers (appended verbatim)
579 # use this for custom headers like "Approved:"
580 ExtraHeader = 'Approved: moderator@domain.invalid
581 X-Header: Some text'
582
583 # other projects may follow separated with "====="
584 =====
585
586 Name = 'othertest'
587 File = 'test.txt'
588 Posting-frequency = '2m'
589 From = 'My Name <my.name@domain.invalid>'
590 Subject = 'Test of yapfag <%LM>'
591 NGs = 'de.test,de.alt.test'
592 Fup2 = 'de.test'
593 MID-Format = '<%n-%m.%y@domain.invalid>'
594 Supersede = yes
595
596=head3 Status Information
597
598Information about the last post and about how to form message IDs for
599posts is stored in a file named F<I<project name>.cfg> which will be
600generated if it does not exist. Each of those status files will
601contain two lines, the first being the date of the last time the FAQ
602was posted and the second being the message ID of that incarnation.
603
604=head2 Runtime Configuration
605
606Apart from configuring which FAQ(s) to post you may (re)set some
607runtime configuration variables via the .rcfile (by default
608F<.yapfaqrc>). F<.yapfaqrc> must contain one definition in the form of
609I<param = value> on each line; everything after a "#" sign is ignored.
610
611If you omit some settings they will be set to default values hardcoded
612in F<yapfaq.pl>.
613
614B<Please note that all parameter names are case-sensitive!>
615
616=over 4
617
618=item B<NNTPServer> = I<NNTP server> (mandatory)
619
620Host name of the NNTP server to post to. Must be set (or omitted; the
621default is "localhost"); if set to en empty string, B<yapfaq> falls
622back to Perl's build-in defaults (contents of environment variables
623NNTPSERVER and NEWSHOST; if not set, default from Net::Config; if not
624set, "news" is used).
625
626=item B<NNTPUser> = I<user name> (optional)
627
628User name used for authentication with the NNTP server (I<AUTHINFO
629USER>).
630
631This setting is optional; if it is not set, I<NNTPPass> is ignored and
632no authentication is tried.
633
634=item B<NNTPPass> = I<password> (optional)
635
636Password used for authentication with the NNTP server (I<AUTHINFO
637PASS>).
638
639This setting is optional; it must be set if I<NNTPUser> is present.
640
641=item B<Sender> = I<Sender header> (optional)
642
643The Sender header that will be added to every posted message.
644
645This setting is optional.
646
647=item B<ConfigFile> = I<configuration file> (mandatory)
648
649The configuration file defining the FAQ(s) to post. Must be set (or
650omitted; the default is "yapfaq.cfg").
651
652=item B<Program> = I<file name> (optional)
653
654A program the article is piped to instead of posting it to Usenet.
655See option "-f" below (which takes preference).
656
657This setting is optional.
658
659=back
660
661=head3 Example runtime configuration file
662
663 NNTPServer = 'localhost'
664 NNTPUser = ''
665 NNTPPass = ''
666 Sender = ''
667 ConfigFile = 'yapfaq.cfg'
668 Program = ''
669
670=head3 Using more than one runtime configuration
671
672You may use more than one runtime configuration file with the B<-c>
673option (see below).
674
675=head1 OPTIONS
676
677=over 3
678
679=item B<-V> (version)
680
681Print out version and copyright information on B<yapfaq> and exit.
682
683=item B<-h> (help)
684
685Print this man page and exit.
686
687=item B<-v> (verbose)
688
689Print out status information while running to STDOUT.
690
691=item B<-p> (post unconditionally)
692
693Post (all) FAQs unconditionally ignoring the posting frequency setting.
694
695You may want to use this with the B<-f> option (see below).
696
697=item B<-d> (dry run)
698
699Start B<yapfaq> in simulation mode, i.e. don't post anything and don't
700update any status information.
701
702=item B<-t> I<newsgroup(s) | CONSOLE> (test)
703
704Don't post to the newsgroups defined in F<yqpfaq.cfg>, but to the
705(test) newsgroup(s) given after B<-t> as a comma-separated list or
706print the FAQs to STDOUT separated by lines of dashes if the special
707string C<CONSOLE> is given. This can be used to preview what
708B<yapfaq> would do without embarassing yourself on Usenet.
709
710The status files are not updated when this option is given.
711
712When this option is used to post to some other newsgroup(s), a(nother)
713timestamp is added to the Message-ID header and the Supersedes header
714is replaced by a special X-Supersedes header.
715
716You may want to use this with the B<-f> option (see below).
717
718=item B<-f> I<project name>
719
720Just deal with one FAQ only.
721
722By default B<yapfaq> will work on all FAQs that are defined in
723F<yapfaq.cfg>, check whether they are due for posting and - if they
724are - post them. Consequently when the B<-p> option is set all FAQs
725will be posted unconditionally. That may not be what you want to
726achieve, so you can limit the operation of B<yapfaq> to the named FAQ
727only.
728
729=item B<-s> I<program> (pipe to script)
730
731Instead of posting the article(s) to Usenet pipe them to the external
732I<program> on STDIN (which may post the article(s) then). A return
733value of 0 will be considered success.
734
735For example, you may want to use the I<inews> utility from the INN package
736or the much more powerful replacement I<tinews.pl> from
737I<ftp://ftp.tin.org/tin/tools/tinews.pl> which is able to sign postings.
738
739If I<Program> is also defined in the runtime configuration file (by default
740F<.yapfaqrc>), B<-s> takes preference.
741
742=item B<-c> I<.rc file>
743
744Load another runtime configuration file (.rc file) than F<.yaofaq.rc>.
745
746You may for example define another usenet server to post your FAQ(s)
747to or load another configuration file defining (an)other FAQ(s).
748
749=back
750
751=head1 INSTALLATION
752
753Just copy the contents of the tarball in some directory and get started.
754
755You can post your first test with
756
757 yapfaq -c .yapfaqrc.sample
758
759or copy F<.yapfaqrc.sample> to F<.yapfaqrc> and F<yapfaq.cfg.sample>
760to F<yapfaq.cfg>, edit those files and get really started!
761
762=back
763
764=head1 EXAMPLES
765
766Post all FAQs that are due for posting:
767
768 yapfaq
769
770Do a dry run, showing which FAQs would be posted:
771
772 yapfaq -dv
773
774Do a test run and print on STDOUT what the FAQ I<myfaq> would look
775like when posted, regardless whether it is due for posting or not:
776
777 yapfaq -pt CONSOLE -f myfaq
778
779Do a "real" test run and post the FAQ I<myfaq> to I<de.test>, but only
780if it is due:
781
782 yapfaq -t de.test -f myfaq
783
784Post all FAQs (that are due for posting) using inews from INN:
785
786 yapfaq -s inews
787
788Do a dry run using a runtime configuration from .alternaterc, showing
789which FAQs would be posted:
790
791 yapfaq -dvc .alternaterc
792
793=head1 ENVIRONMENT
794
795=over 4
796
797=item NNTPSERVER
798
799The default NNTP server to post to, used by the Net::NNTP module. You
800can also specify the server using the runtime configuration file (by
801default F<.yapfaqrc>).
802
803=back
804
805=head1 FILES
806
807=over 4
808
809=item F<yapfaq.pl>
810
811The script itself.
812
813=item F<.yapfaqrc>
814
815Runtime configuration file for B<yapfaq>.
816
817=item F<yapfaq.cfg>
818
819Configuration file for B<yapfaq>.
820
821=item F<*.cfg>
822
823Status data on FAQs.
824
825The status files will be created on successful posting if they don't
826already exist. The first line of the file will be the date of the last
827time the FAQ was posted and the second line will be the message ID of
828the last post of that FAQ.
829
830=back
831
832=head1 BUGS
833
834Please report any bugs or feature request to the author or use the
835bug tracker at L<http://bugs.th-h.de/>!
836
837=head1 SEE ALSO
838
839L<http://th-h.de/download/scripts.php> will have the current
840version of this program.
841
842This program is maintained using the Git version control system. You
843may clone L<git://code.th-h.de/usenet/yapfaq.git> to check out the
844current development tree or browse it on the web via
845L<http://code.th-h.de/?p=usenet/yapfaq.git>.
846
847=head1 AUTHOR
848
849Thomas Hochstein <thh@inter.net>
850
851Original author (up to version 0.5b, dating from 2003):
852Marc Brockschmidt <marc@marcbrockschmidt.de>
853
854=head1 COPYRIGHT AND LICENSE
855
856Copyright (c) 2003 Marc Brockschmidt <marc@marcbrockschmidt.de>
857
858Copyright (c) 2010 Thomas Hochstein <thh@inter.net>
859
860This program is free software; you may redistribute it and/or modify it
861under the same terms as Perl itself.
862
863=cut
This page took 0.013365 seconds and 4 git commands to generate.