#!/usr/bin/perl # # rpostarticle v1.1 # This is rpostarticle.pl # a helper to rpost articles from inn2.x with storage-api # # History # # 1999 02 19 v1.0 elmi@newsbone.org (Elmar K. Bins) # started hacking away :-) # # 1999 02 20 v1.1 elmi@newsbone.org (Elmar K. Bins) # includes date in log, uses innshellvars.pl # # Notes: # # If you use the inn2.x storage api, then set $STORAGEAPI to 1 # In this case, we will use the "sm" program to get access. # Ensure proper path in $sm and $perl. # # We expect [-m] (|) [] on the cmdline # # The optional "-m" will make us call rpost to issue "mode reader" # TOKEN or articlepath show us the way to the article # SERVERFQDN is the full FQDN (or IP address) of the server to post at # PORT may be specified if special port (aside from 119) is to be used # # NOTE: You must have rpost installed, which is part of the "suck" package. # This may be found at ftp://nethammer.qad.org/usenet/ # # The current version can be found via http://detebe.org/~news/software/ # # Do you use the storage api for groups being fed here? $STORAGEAPI = 1; # Version and copyright stuff $version = "1.1"; $date = "1999 02 20"; $authors = "elmi\@newsbone.org (Elmar K. Bins)"; $copyright = "-- \nrpostarticle.pl v$version $date $authors\n"; # System dependent stuff $grep = "/bin/grep"; $cat = "/bin/cat"; $date = "/bin/date"; $now = `$date "+%a %b %d %Y %T %z (%Z)"`; chomp($now); # Installation dependent stuff (pathnames) require "/usr/local/inn/lib/innshellvars.pl"; $sm = join("/",$inn::pathbin,"sm") if ($STORAGEAPI); $logfile = join("/",$inn::most_logs,"rpost.log"); $rpost = join("/",$inn::pathnews,"contrib/rpost"); # Configuration # usually, NNTP-Posting.* and the Xref:-Header should be filtered. # beware: This will filter lines beginning with these from the body too... $filterpatterns = "!^NNTP-Posting.*: #!^Xref: "; #----------------------------------# # 0. Get cmd line arguments # # 1. Get the article drop command # # 2. If desired, filter # # 3. Call rpost and feed article # #----------------------------------# #-------------------------- # 0. Get cmd line arguments $arg = shift @ARGV; if ($arg eq "-m") { $modereader = 1; $article = shift @ARGV; } else { $article = $arg; } $server = shift @ARGV; $port = shift @ARGV; exit 1 if (!$server); #-------------------------------- # 1. Get the article drop command if ($STORAGEAPI) { $getarticle = "$sm $article"; } else { exit 2 if (! -f $article); $getarticle = "$cat $article"; } #---------------------- # 2. If desired, filter $filterline = ""; if ($filterpatterns ne "") { @filter = split("#",$filterpatterns); foreach $pattern (@filter) { $no = ""; if ($pattern =~ m/^\!(.*)/) { $no = " -v"; $pattern = $1; } $filterline .= "|$grep -i $no '$pattern'"; } } $getarticle .= $filterline; #------------------------------- # 3. Call rpost and feed article $rpostflags = ""; $rpostflags .= " -N $port" if ($port); $rpostflags .= " -M" if ($modereader); open(LOG,">>$logfile"); print LOG "\nDATE [$now]\n"; print LOG "ARTICLE [$article]\n"; print LOG "RPOST TO [$server]\n"; print LOG "-----------------------------------------------------------------------\n"; $result = `($getarticle) | $rpost $rpostflags $server`; print LOG "$result\n"; print LOG "-----------------------------------------------------------------------\n"; close(LOG);