3 # yapfaq Version 0.6 by Thomas Hochstein
4 # (Original author: Marc Brockschmidt)
6 # This script posts any project described in its config-file. Most people
7 # will use it in combination with cron(8).
9 # Copyright (C) 2003 Marc Brockschmidt <marc@marcbrockschmidt.de>
10 # Copyright (c) 2010 Thomas Hochstein <thh@inter.net>
12 # It can be redistributed and/or modified under the same terms under
13 # which Perl itself is published.
15 my $Version = "0.6.2";
17 my $NNTPServer = "localhost";
21 my $ConfigFile = "yapfaq.cfg";
24 ################################## PGP-Config #################################
26 my $pgp = '/usr/bin/pgp'; # path to pgp
27 my $PGPVersion = '2'; # Use 2 for 2.X, 5 for PGP > 2.X and GPG for GPG
29 my $PGPSigner = ''; # sign as who?
30 my $PGPPass = ''; # pgp2 only
31 my $PathtoPGPPass = ''; # pgp2, pgp5 and gpg
34 my $pgpbegin ='-----BEGIN PGP SIGNATURE-----';# Begin of PGP-Signature
35 my $pgpend ='-----END PGP SIGNATURE-----'; # End of PGP-Signature
36 my $pgptmpf ='pgptmp'; # temporary file for PGP.
37 my $pgpheader ='X-PGP-Sig';
39 my @PGPSignHeaders = ('From', 'Newsgroups', 'Subject', 'Control',
40 'Supersedes', 'Followup-To', 'Date', 'Sender', 'Approved',
41 'Message-ID', 'Reply-To', 'Cancel-Lock', 'Cancel-Key',
42 'Also-Control', 'Distribution');
44 my @PGPorderheaders = ('from', 'newsgroups', 'subject', 'control',
45 'supersedes', 'followup-To', 'date', 'organization', 'lines',
46 'sender', 'approved', 'distribution', 'message-id',
47 'references', 'reply-to', 'mime-version', 'content-type',
48 'content-transfer-encoding', 'summary', 'keywords', 'cancel-lock',
49 'cancel-key', 'also-control', 'x-pgp', 'user-agent');
51 ############################# End of Configuration #############################
55 use Net::Domain qw(hostfqdn);
56 use Date::Calc qw(Add_Delta_YM Add_Delta_Days Delta_Days Today);
57 use Fcntl ':flock'; # import LOCK_* constants
59 my ($TDY, $TDM, $TDD) = Today(); #TD: Today's date
61 # read commandline options
63 getopts('Vhvpdt:f:', \%Options);
64 # -V: print version / copyright information
66 print "$0 v $Version\nCopyright (c) 2003 Marc Brockschmidt <marc\@marcbrockschmidt.de>\nCopyright (c) 2010 Thomas Hochstein <thh\@inter.net>\n";
67 print "This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.\n";
70 # -h: feed myself to perldoc
76 my ($Faq) = $Options{'f'} if ($Options{'f'});
78 # read configuration (configured FAQs)
80 readconfig (\$ConfigFile, \@Config, \$Faq);
83 # - parse configuration
85 # - if FAQ is due: call postfaq()
87 my ($LPD,$LPM,$LPY) = (01, 01, 0001); #LP: Last posting-date
88 my ($NPY,$NPM,$NPD); #NP: Next posting-date
91 my ($ActName,$File,$PFreq,$Expire) =($$_{'name'},$$_{'file'},$$_{'posting-frequency'},$$_{'expires'});
92 my ($From,$Subject,$NG,$Fup2)=($$_{'from'},$$_{'subject'},$$_{'ngs'},$$_{'fup2'});
93 my ($MIDF,$ReplyTo,$ExtHea)=($$_{'mid-format'},$$_{'reply-to'},$$_{'extraheader'});
94 my ($Supersede) =($$_{'supersede'});
96 # -f: loop if not FAQ to post
97 next if (defined($Faq) && $ActName ne $Faq);
100 if (open (FH, "<$File.cfg")) {
102 if (/##;; Lastpost:\s*(\d{1,2})\.(\d{1,2})\.(\d{2}(\d{2})?)/){
103 ($LPD, $LPM, $LPY) = ($1, $2, $3);
104 } elsif (/^##;;\s*LastMID:\s*(<\S+@\S+>)\s*$/) {
110 warn "$0: W: Couldn't open $File.cfg: $!\n";
113 $SupersedeMID = "" unless $Supersede;
115 ($NPY,$NPM,$NPD) = calcdelta ($LPY,$LPM,$LPD,$PFreq);
117 # if FAQ is due: get it out
118 if (Delta_Days($NPY,$NPM,$NPD,$TDY,$TDM,$TDD) >= 0 or ($Options{'p'})) {
120 print "$ActName: Would be posted now (but running in simulation mode [$0 -d]).\n" if $Options{'v'};
122 postfaq(\$ActName,\$File,\$From,\$Subject,\$NG,\$Fup2,\$MIDF,\$ExtHea,\$Sender,\$TDY,\$TDM,\$TDD,\$ReplyTo,\$SupersedeMID,\$Expire);
124 } elsif($Options{'v'}) {
125 print "$ActName: Nothing to do.\n";
131 ################################## readconfig ##################################
132 # Takes a filename, a reference to an array, which will hold hashes with
133 # the data from $File, and - optionally - the name of the (single) FAQ to post
136 my ($File, $Config, $Faq) = @_;
137 my ($LastEntry, $Error, $i) = ('','',0);
139 print "Reading configuration.\n" if($Options{'v'});
141 open FH, "<$$File" or die "$0: E: Can't open $$File: $!";
143 next if (defined($$Faq) && !/^\s*=====\s*$/ && defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} ne $$Faq );
144 if (/^(\s*(\S+)\s*=\s*'?(.*?)'?\s*(#.*$|$)|^(.*?)'?\s*(#.*$|$))/ && not /^\s*$/) {
145 $LastEntry = lc($2) if $2;
146 $$Config[$i]{$LastEntry} .= $3 if $3;
147 $$Config[$i]{$LastEntry} .= "\n$5" if $5 && $5;
149 if (/^\s*=====\s*$/) {
157 next if (defined($$Faq) && defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} ne $$Faq );
158 unless(defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} =~ /^\S+$/) {
159 $Error .= "E: The name of your project \"$$Config[$i]{'name'}\" is not defined or contains whitespaces.\n"
161 unless(defined($$Config[$i]{'file'}) && -f $$Config[$i]{'file'}) {
162 $Error .= "E: The file to post for your project \"$$Config[$i]{'name'}\" is not defined or does not exist.\n"
164 unless(defined($$Config[$i]{'from'}) && $$Config[$i]{'from'} =~ /\S+\@(\S+\.)?\S{2,}\.\S{2,}/) {
165 $Error .= "E: The From header for your project \"$$Config[$i]{'name'}\" seems to be incorrect.\n"
167 unless(defined($$Config[$i]{'ngs'}) && $$Config[$i]{'ngs'} =~ /^\S+$/) {
168 $Error .= "E: The Newsgroups header for your project \"$$Config[$i]{'name'}\" is not defined or contains whitespaces.\n"
170 unless(defined($$Config[$i]{'subject'})) {
171 $Error .= "E: The Subject header for your project \"$$Config[$i]{'name'}\" is not defined.\n"
173 unless(!$$Config[$i]{'fup2'} || $$Config[$i]{'fup2'} =~ /^\S+$/) {
174 $Error .= "E: The Followup-To header for your project \"$$Config[$i]{'name'}\" contains whitespaces.\n"
176 unless(defined($$Config[$i]{'posting-frequency'}) && $$Config[$i]{'posting-frequency'} =~ /^\s*\d+\s*[dwmy]\s*$/) {
177 $Error .= "E: The Posting-frequency for your project \"$$Config[$i]{'name'}\" is invalid.\n"
179 unless(!$$Config[$i]{'expires'} || $$Config[$i]{'expires'} =~ /^\s*\d+\s*[dwmy]\s*$/) {
180 warn "$0: W: The Expires for your project \"$$Config[$i]{'name'}\" is invalid - set to 3 month.\n";
182 unless(defined($$Config[$i]{'mid-format'}) && $$Config[$i]{'mid-format'} =~ /^<\S+\@\S{2,}\.\S{2,}>$/) {
183 warn "$0: W: The Expires for your project \"$$Config[$i]{'name'}\" seems to be invalid - set to default.\n";
186 $Error .= "-" x 25 . 'program terminated' . "-" x 25 . "\n" if $Error;
187 die $Error if $Error;
190 ################################# calcdelta #################################
191 # Takes a date (year, month and day) and a time period (1d, 1w, 1m, 1y, ...)
192 # and adds the latter to the former
195 my ($Year, $Month, $Day, $Period) = @_;
196 my ($NYear, $NMonth, $NDay);
198 if ($Period =~ /(\d+)\s*([dw])/) { # Is counted in days or weeks: Use Add_Delta_Days.
199 ($NYear, $NMonth, $NDay) = Add_Delta_Days($Year, $Month, $Day, (($2 eq "w")?$1 * 7: $1 * 1));
200 } elsif ($Period =~ /(\d+)\s*([my])/) { #Is counted in months or years: Use Add_Delta_YM
201 ($NYear, $NMonth, $NDay) = Add_Delta_YM($Year, $Month, $Day, (($2 eq "m")?(0,$1):($1,0)));
203 return ($NYear, $NMonth, $NDay);
206 ################################## postfaq ##################################
207 # Takes a filename and many other vars.
209 # It reads the data-file $File and then posts the article.
212 my ($ActName,$File,$From,$Subject,$NG,$Fup2,$MIDF,$ExtraHeaders,$Sender,$TDY,$TDM,$TDD,$ReplyTo,$Supersedes,$Expire) = @_;
213 my (@Header,@Body,$MID,$InRealBody,$LastModified);
215 print "$$ActName: Preparing to post.\n" if($Options{'v'});
218 $$TDM = ($$TDM < 10 && $$TDM !~ /^0/) ? "0" . $$TDM : $$TDM;
219 $$TDD = ($$TDD < 10 && $$TDD !~ /^0/) ? "0" . $$TDD : $$TDD;
222 $MID = '<%n-%d.%m.%y@'.hostfqdn.'>' if !defined($MID);
223 $MID =~ s/\%n/$$ActName/g;
224 $MID =~ s/\%d/$$TDD/g;
225 $MID =~ s/\%m/$$TDM/g;
226 $MID =~ s/\%y/$$TDY/g;
229 open (FH, "<$$File");
232 push (@Body, $_), next if $InRealBody;
233 $InRealBody++ if /^$/;
234 $LastModified = $1 if /^Last-modified: (\S+)$/i;
238 push @Body, "\n" if ($Body[-1] ne "\n");
240 #Create Date- and Expires-Header:
241 my @time = localtime;
242 my $ss = ($time[0]<10) ? "0" . $time[0] : $time[0];
243 my $mm = ($time[1]<10) ? "0" . $time[1] : $time[1];
244 my $hh = ($time[2]<10) ? "0" . $time[2] : $time[2];
246 my $month = ($time[4]+1<10) ? "0" . ($time[4]+1) : $time[4]+1;
247 my $monthN = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$time[4]];
248 my $wday = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")[$time[6]];
249 my $year = (1900 + $time[5]);
250 my $tz = $time[8] ? " +0200" : " +0100";
252 $$Expire = '3m' if !$$Expire; # set default if unset: 3 month
254 my ($expY,$expM,$expD) = calcdelta ($year,$month,$day,$$Expire);
255 my $expmonthN = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$expM-1];
257 my $date = "$day $monthN $year " . $hh . ":" . $mm . ":" . $ss . $tz;
258 my $expdate = "$expD $expmonthN $expY $hh:$mm:$ss$tz";
260 #Replace %LM by the content of the news.answer-pseudo-header Last-modified:
262 $$Subject =~ s/\%LM/$LastModified/;
266 if($Options{'t'} and $Options{'t'} !~ /console/i) {
267 $$NG = $Options{'t'};
270 #Now create the complete Header:
271 push @Header, "From: $$From\n";
272 push @Header, "Newsgroups: $$NG\n";
273 push @Header, "Followup-To: $$Fup2\n" if $$Fup2;
274 push @Header, "Subject: $$Subject\n";
275 push @Header, "Message-ID: $MID\n";
276 push @Header, "Supersedes: $$Supersedes\n" if $$Supersedes;
277 push @Header, "Date: $date\n";
278 push @Header, "Expires: $expdate\n";
279 push @Header, "Sender: $$Sender\n" if $$Sender;
280 push @Header, "Mime-Version: 1.0\n";
281 push @Header, "Reply-To: $$ReplyTo\n" if $$ReplyTo;
282 push @Header, "Content-Type: text/plain; charset=ISO-8859-15\n";
283 push @Header, "Content-Transfer-Encoding: 8bit\n";
284 push @Header, "User-Agent: yapfaq/$Version\n";
285 if ($$ExtraHeaders) {
286 push @Header, "$_\n" for (split /\n/, $$ExtraHeaders);
289 # sign article if $UsePGP is true
290 my @Article = ($UsePGP)?@{signpgp(\@Header, \@Body)}:(@Header, "\n", @Body);
293 print "$$ActName: Posting article ...\n" if($Options{'v'});
297 return if($Options{'t'});
299 # otherwise: update status data
300 print "$$ActName: Save status information.\n" if($Options{'v'});
302 open (FH, ">$$File.cfg") or die "$0: E: Can't open $$File.cfg: $!";
303 print FH "##;; Lastpost: $day.$month.$year\n";
304 print FH "##;; LastMID: $MID\n";
308 ################################## post ##################################
309 # Takes a complete article (Header and Body).
311 # It opens a connection to $NNTPServer and posts the message.
317 if(defined($Options{'t'}) and $Options{'t'} =~ /console/i) {
318 print "-----BEGIN--------------------------------------------------\n";
320 print "------END---------------------------------------------------\n";
324 my $NewsConnection = Net::NNTP->new($NNTPServer, Reader => 1)
325 or die "$0: E: Can't connect to news server '$NNTPServer'!\n";
327 $NewsConnection->authinfo ($NNTPUser, $NNTPPass) if (defined($NNTPUser));
328 $NewsConnection->post();
329 $NewsConnection->datasend (@$ArticleR);
330 $NewsConnection->dataend();
332 # Posting failed? Save to ERROR.dat
333 if (!$NewsConnection->ok()) {
334 open FH, ">>ERROR.dat";
335 print FH "\nPosting failed! Saving to ERROR.dat. Response from news server:\n";
336 print FH $NewsConnection->code();
337 print FH $NewsConnection->message();
340 print FH "-" x 80, "\n";
344 $NewsConnection->quit();
347 #-------- sub getpgpcommand
348 # getpgpcommand generates the command to sign the message and returns it.
351 # - $PGPVersion: A scalar holding the PGPVersion
353 my ($PGPVersion) = @_;
356 if ($PGPVersion eq '2') {
357 if ($PathtoPGPPass && !$PGPPass) {
358 open (PGPPW, $PathtoPGPPass) or die "$0: E: Can't open $PathtoPGPPass: $!";
364 $PGPCommand = "PGPPASS=\"".$PGPPass."\" ".$pgp." -u \"".$PGPSigner."\" +verbose=0 language='en' -saft <".$pgptmpf.".txt >".$pgptmpf.".txt.asc";
366 die "$0: E: PGP-Passphrase is unknown!\n";
368 } elsif ($PGPVersion eq '5') {
369 if ($PathtoPGPPass) {
370 $PGPCommand = "PGPPASSFD=2 ".$pgp."s -u \"".$PGPSigner."\" -t --armor -o ".$pgptmpf.".txt.asc -z -f < ".$pgptmpf.".txt 2<".$PathtoPGPPass;
372 die "$0: E: PGP-Passphrase is unknown!\n";
374 } elsif ($PGPVersion =~ m/GPG/io) {
375 if ($PathtoPGPPass) {
376 $PGPCommand = $pgp." --digest-algo MD5 -a -u \"".$PGPSigner."\" -o ".$pgptmpf.".txt.asc --no-tty --batch --passphrase-fd 2 2<".$PathtoPGPPass." --clearsign ".$pgptmpf.".txt";
378 die "$0: E: Passphrase is unknown!\n";
381 die "$0: E: Unknown PGP-Version $PGPVersion!";
387 #-------- sub signarticle
388 # signarticle signs an articel and returns a reference to an array
389 # containing the whole signed Message.
392 # - $HeaderAR: A reference to a array containing the articles headers.
393 # - $BodyR: A reference to an array containing the body.
396 # - $MessageRef: A reference to an array containing the whole message.
398 my ($HeaderAR, $BodyR) = @_;
399 my (@pgphead, @pgpbody, $pgphead, $pgpbody, $header, $signheaders, @signheaders, $currentheader, $HeaderR, $line);
401 foreach my $line (@$HeaderAR) {
402 if ($line =~ /^(\S+):\s+(.*)$/s) {
404 $$HeaderR{lc($currentheader)} = "$1: $2";
406 $$HeaderR{lc($currentheader)} .= $line;
410 foreach (@PGPSignHeaders) {
411 if (defined($$HeaderR{lc($_)}) && $$HeaderR{lc($_)} =~ m/^[^\s:]+: .+/o) {
412 push @signheaders, $_;
416 $pgpbody = join ("", @$BodyR);
418 # Delete and create the temporary pgp-Files
419 unlink "$pgptmpf.txt";
420 unlink "$pgptmpf.txt.asc";
421 $signheaders = join(",", @signheaders);
423 $pgphead = "X-Signed-Headers: $signheaders\n";
424 foreach $header (@signheaders) {
425 if ($$HeaderR{lc($header)} =~ m/^[^\s:]+: (.+?)\n?$/so) {
426 $pgphead .= $header.": ".$1."\n";
430 open(FH, ">" . $pgptmpf . ".txt") or die "$0: E: can't open $pgptmpf: $!\n";
431 print FH $pgphead, "\n", $pgpbody;
432 print FH "\n" if ($PGPVersion =~ m/GPG/io); # workaround a pgp/gpg incompatibility - should IMHO be fixed in pgpverify
433 close(FH) or warn "$0: W: Couldn't close TMP: $!\n";
435 # Start PGP, then read the signature;
436 my $PGPCommand = getpgpcommand($PGPVersion);
439 open (FH, "<" . $pgptmpf . ".txt.asc") or die "$0: E: can't open ".$pgptmpf.".txt.asc: $!\n";
442 unless (m/\Q$pgpbegin\E$/o) {
443 # unlink $pgptmpf . ".txt";
444 # unlink $pgptmpf . ".txt.asc";
445 die "$0: E: $pgpbegin not found in ".$pgptmpf.".txt.asc\n"
447 unlink($pgptmpf . ".txt") or warn "$0: W: Couldn't unlink $pgptmpf.txt: $!\n";
451 unless (m/^Version: (\S+)(?:\s(\S+))?/o) {
452 unlink $pgptmpf . ".txt";
453 unlink $pgptmpf . ".txt.asc";
454 die "$0: E: didn't find PGP Version line where expected.\n";
458 $$HeaderR{$pgpheader} = $1."-".$2." ".$signheaders;
460 $$HeaderR{$pgpheader} = $1." ".$signheaders;
463 do { # skip other pgp headers like
464 $_ = <FH>; # "charset:"||"comment:" until empty line
469 last if /^\Q$pgpend\E$/;
470 $$HeaderR{$pgpheader} .= "\n\t$_";
473 $$HeaderR{$pgpheader} .= "\n" unless ($$HeaderR{$pgpheader} =~ /\n$/s);
477 unlink $pgptmpf . ".txt";
478 unlink $pgptmpf . ".txt.asc";
479 die "$0: E: unexpected data following $pgpend\n";
482 unlink "$pgptmpf.txt.asc";
484 my $tmppgpheader = $pgpheader . ": " . $$HeaderR{$pgpheader};
485 delete $$HeaderR{$pgpheader};
488 foreach $header (@PGPorderheaders) {
489 if ($$HeaderR{$header} && $$HeaderR{$header} ne "\n") {
490 push(@pgphead, "$$HeaderR{$header}");
491 delete $$HeaderR{$header};
495 foreach $header (keys %$HeaderR) {
496 if ($$HeaderR{$header} && $$HeaderR{$header} ne "\n") {
497 push(@pgphead, "$$HeaderR{$header}");
498 delete $$HeaderR{$header};
502 push @pgphead, ("X-PGP-Key: " . $PGPSigner . "\n"), $tmppgpheader;
505 @pgpbody = split /$/m, $pgpbody;
506 my @pgpmessage = (@pgphead, "\n", @pgpbody);
512 ################################ Documentation #################################
516 yapfaq - Post Usenet FAQs I<(yet another postfaq)>
520 B<yapfaq> [B<-hvpd>] [B<-t> I<newsgroups> | CONSOLE] [B<-f> I<project name>]
544 Furthermore you need access to a news server to actually post FAQs.
548 B<yapfaq> posts (one or more) FAQs to Usenet with a certain posting
549 frequency (every n days, weeks, months or years), adding all necessary
550 headers as defined in its config file (by default F<yapfaq.cfg>).
554 F<yapfaq.cfg> consists of one or more blocks, separated by C<=====> on
555 a single line, each containing the configuration for one FAQ as a set
556 of definitions in the form of I<param = value>.
560 =item B<Name> = I<project name>
562 A name referring to your FAQ, also used for generation of a Message-ID.
564 This value must be set.
566 =item B<File> = I<file name>
568 A file containing the message body of your FAQ and all pseudo headers
569 (subheaders in the news.answers style).
571 This value must be set.
573 =item B<Posting-frequency> = I<time period>
575 The posting frequency defines how often your FAQ will be posted.
576 B<yapfaq> will only post your FAQ if this period of time has passed
577 since the last posting.
579 You can declare that time period either in I<B<d>ays> or I<B<w>weeks>
580 or I<B<m>onths> or I<B<y>ears>.
582 This value must be set.
584 =item B<Expires> = I<time period>
586 The period of time after which your message will expire. An Expires
587 header will be calculated adding this time period to today's date.
589 You can declare this time period either in I<B<d>ays> or I<B<w>weeks>
590 or I<B<m>onths> or I<B<y>ears>.
592 This setting is optional; the default is 3 months.
594 =item B<From> = I<author>
596 The author of your FAQ as it will appear in the From header of the
599 This value must be set.
601 =item B<Subject> = I<subject>
603 The title of your FAQ as it will appear in the Subject header of the
606 You may use the special string C<%LM> which will be replaced with
607 the contents of the Last-Modified subheader in your I<File>.
609 This value must be set.
611 =item B<NGs> = I<newsgroups>
613 A comma-separated list of newsgroup(s) to post your FAQ to as it will
614 appear in the Newsgroups header of the message.
616 This value must be set.
618 =item B<Fup2> = I<newsgroup | poster>
620 A comma-separated list of newsgroup(s) or the special string I<poster>
621 as it will appear in the Followup-To header of the message.
623 This setting is optional.
625 =item B<MID-Format> = I<pattern>
627 A pattern from which the message ID is generated as it will appear in
628 the Message-ID header of the message.
630 You may use the special strings C<%n> for the I<Name> of your project,
631 C<%d> for the date the message is posted, C<%m> for the month and
632 C<%y> for the year, respectively.
634 This value must be set.
636 =item B<Supersede> = I<yes>
638 Add Supersedes header to the message containing the Message-ID header
641 This setting is optional; you should set it to yes or leave it out.
643 =item B<ExtraHeader> = I<additional headers>
645 The contents of I<ExtraHeader> is added verbatim to the headers of
646 your message so you can add custom headers like Approved.
648 This setting is optional.
652 =head2 Example configuration file
654 # name of your project
657 # file to post (complete body and pseudo-headers)
658 # ($File.cfg contains data on last posting and last MID)
661 # how often your project should be posted
662 # use (d)ay OR (w)eek OR (m)onth OR (y)ear
663 Posting-frequency = '1d'
665 # time period after which the posting should expire
666 # use (d)ay OR (w)eek OR (m)onth OR (y)ear
670 From = 'test@domain.invalid'
673 # (may contain "%LM" which will be replaced by the contents of the
674 # Last-Modified pseudo header).
675 Subject = 'test noreply ignore'
677 # comma-separated list of newsgroup(s) to post to
678 # (header "Newsgroups:")
681 # header "Followup-To:"
684 # Message-ID ("%n" is $Name)
685 MID-Format = '<%n-%d.%m.%y@domain.invalid>'
687 # Supersede last posting?
690 # extra headers (appended verbatim)
691 # use this for custom headers like "Approved:"
692 ExtraHeader = 'Approved: moderator@domain.invalid
695 # other projects may follow separated with "====="
700 Posting-frequency = '2m'
701 From = 'My Name <my.name@domain.invalid>'
702 Subject = 'Test of yapfag <%LM>'
703 NGs = 'de.test,de.alt.test'
705 MID-Format = '<%n-%m.%y@domain.invalid>'
708 Information about the last post and about how to form message IDs for
709 posts is stored in a file named F<I<project name>.cfg> which will be
710 generated if it does not exist. Each of those status files will
711 contain two lines, the first being the date of the last time the FAQ
712 was posted and the second being the message ID of that incarnation.
718 =item B<-V> (version)
720 Print out version and copyright information on B<yapfaq> and exit.
724 Print this man page and exit.
726 =item B<-v> (verbose)
728 Print out status information while running to STDOUT.
730 =item B<-p> (post unconditionally)
732 Post (all) FAQs unconditionally ignoring the posting frequency setting.
734 You may want to use this with the B<-f> option (see below).
736 =item B<-d> (dry run)
738 Start B<yapfaq> in simulation mode, i.e. don't post anything and don't
739 update any status information.
741 =item B<-t> I<newsgroup(s) | CONSOLE> (test)
743 Don't post to the newsgroups defined in F<yqpfaq.cfg>, but to the
744 newsgroups given after B<-t> as a comma-separated list or print the
745 FAQs to STDOUT separated by lines of dashes if the special string
746 C<CONSOLE> is given. This can be used to preview what B<yapfaq> would
747 do without embarassing yourself on Usenet. The status files are not
748 updated when this option is given.
750 You may want to use this with the B<-f> option (see below).
752 =item B<-f> I<project name>
754 Just deal with one FAQ only.
756 By default B<yapfaq> will work on all FAQs that are defined in
757 F<yapfaq.cfg>, check whether they are due for posting and - if they
758 are - post them. Consequently when the B<-p> option is set all FAQs
759 will be posted unconditionally. That may not be what you want to
760 achieve, so you can limit the operation of B<yapfaq> to the named FAQ
767 Post all FAQs that are due for posting:
771 Do a dry run, showing which FAQs would be posted:
775 Do a test run and print on STDOUT what the FAQ I<myfaq> would look
776 like when posted, regardless whether it is due for posting or not:
778 yapfaq -pt CONSOLE -f myfaq
780 Do a "real" test run and post the FAQ I<myfaq> to I<de.test>, but only
783 yapfaq -t de.test -f myfaq
787 There are no special environment variables used by B<yapfaq>.
799 Configuration file for B<yapfaq>.
805 The status files will be created on successful posting if they don't
806 already exist. The first line of the file will be the date of the last
807 time the FAQ was posted and the second line will be the message ID of
808 the last post of that FAQ.
818 L<http://th-h.de/download/scripts.php> will have the current
819 version of this program.
823 Thomas Hochstein <thh@inter.net>
825 Original author (until version 0.5b from 2003):
826 Marc Brockschmidt <marc@marcbrockschmidt.de>
829 =head1 COPYRIGHT AND LICENSE
831 Copyright (c) 2003 Marc Brockschmidt <marc@marcbrockschmidt.de>
833 Copyright (c) 2010 Thomas Hochstein <thh@inter.net>
835 This program is free software; you may redistribute it and/or modify it
836 under the same terms as Perl itself.