home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / doc / HOWTO / mini / Tiny-News < prev    next >
Text File  |  1995-06-03  |  8KB  |  201 lines

  1. ******************submisson for "Tiny-News-HOWTO"**************************
  2. *********************NOTE UPDATED PERMISSION*******************************
  3.  
  4. Copyright (c) May 25, 1995 Kent Lewis (Kenneth M. Lewis, Jr.)
  5.  
  6. If this document is accepted by the Linux Documentation project, permission
  7. is granted to make it distributable in accordance with the LDP HOWTO 
  8. distribution policy, with the stipulation that the author would like to
  9. review it in its final form before LDP releases it.
  10.  
  11.                              ************
  12.  
  13. I am a Linux user whose net access consists of a ppp link which is not up
  14. all the time.  My internet service provider is in another town, so I have
  15. to pay phone tolls while I'm online.  This can quickly add up, so I've been
  16. working on ways to keep costs down but still make the most of my net access.
  17.  
  18. Until recently, I've had to stay online to read Usenet news remotely from
  19. the provider's NNTP server.  This burned up a lot of online time.  I went
  20. looking for a solution, and found one that suits me.  Hopefully it can help
  21. others, too.  I respectfully submit this "Tiny-News-HOWTO."  It describes
  22. how to use INN to make a small news spool that contains only the newsgroups
  23. you're interested in.  Articles are pulled and replies are posted in one
  24. compact online session via a simple perl script.  All this is of course
  25. "alpha."  If something comes up that's not covered here, you'll have
  26. to fix it yourself.
  27.  
  28. You need access to an NNTP server.  Telnet to port 119 of the machine you
  29. want to use, to make sure it allows reading and posting.  You should get
  30. a message which will indicate whether or not this is allowed.  If not,
  31. then iron out your access problems before going any further.  If you're
  32. already using the machine to read/post remotely, then you know you have
  33. the necessary access.
  34.  
  35. You need enough disk to hold your news spool.  I have a Linux partition that
  36. is about 300M, and two days' worth of news for about 15 newsgroups only takes
  37. up one or two percent of disk as listed by 'df'.  I recommend starting with a
  38. small number of newsgroups and working your way up, just to be safe.
  39.  
  40. You need perl and INN.  If you don't have them, you can get them by anonymous
  41. ftp from sunsite.unc.edu (or mirror sites).  Last time I checked, perl was
  42. in /pub/Linux/devel/perl and INN was in /pub/Linux/system/Mail/news. 
  43.  
  44. Install INN and perl, if you haven't done so already.  I got INN from the
  45. Slackware 2.2 distribution, and it included good documentation.  Follow the
  46. steps in the docs and you'll be fine.  As for perl, I'm using the precompiled
  47. perl 4.0pl36 that came with Slackware 2.2.  If you don't have access to an
  48. out-of-the-box perl binary, then you're on your own as far as compilation/
  49. installation goes.
  50.  
  51. Be sure you have the "junk" and "control" groups, or innd won't start.
  52. You'll have to put these in manually, before you ever start innd, since
  53. 'ctlinnd' assumes innd is already running.  After that, use INN's
  54. 'ctlinnd newgroup ... ... ' to make the empty news spool.  See the man
  55. page for 'ctlinnd.'
  56.  
  57. Set up a newsfeed to the NNTP server you will be using.  You won't actually
  58. be doing a newsfeed in the intended sense, but this will make INN create
  59. a file in /usr/spool/news/out.going that the perl script below uses to find
  60. and post articles you've composed offline.  Instructions for setting up the
  61. feed are in the INN docs.  See the man page for 'newsfeeds.'  IMPORTANT:
  62. You will need to set up your newsfeeds file so that the first field in the
  63. file /usr/spool/news/out.going contains the full pathnames of the articles
  64. you'll be sending out.  If the first field in the
  65. /usr/spool/news/out.going/xxx file does not contain the articles' full
  66. pathnames, then the perl script will attempt to post whatever appears in
  67. that first field, which will probably produce undesirable results.
  68.  
  69. Be sure to configure your control.ctl file to keep new newsgroups from
  70. automagically appearing in your spool and active file.  If you don't do
  71. this, when control messages for new newsgroups come in, the load on your
  72. system will go way up as the new groups are added, and things will slow down
  73. considerably, which is contrary to the whole point of this HOWTO.
  74.  
  75. Change to the directory of your choice, and do a 'touch -t $YESTERDAY lastget'.
  76. Replace $YESTERDAY with the time string for 24 hours ago.  See the man page
  77. for 'touch'.
  78.  
  79. Now put the following perl script in the same directory, and
  80. make it executable.  Replace $NEWSPATH with whatever directory the INN
  81. package resides in (/usr/lib/news on my box).  Replace $SCRIPTPATH with
  82. the path to the directory where the perl script will reside (the same one
  83. where 'lastget' is--- /usr/local/news on my box).  Replace $PROVIDER with
  84. the address of your NNTP server.  Replace $NEWSFEED with whatever you named
  85. your news feed when you installed INN.  See the man pages for 'nntpsend' and
  86. 'inews' to see what this script does.
  87.  
  88.  
  89. -----------------------------------------------------------------------------
  90.  
  91. #!/usr/bin/perl
  92.  
  93. ##
  94. ## retrieve new articles
  95. ##
  96.  
  97. open(LIST, "$NEWSPATH/active")
  98.     || die "could not open list of active newsgroups";
  99.  
  100. while (<LIST>) {
  101.   @newsgroup = split(' ', $_);  ## splits next line of the active file on
  102.                 ## whitespace, assigns pieces to array 
  103.                 ## @newsgroup. @newsgroup[0] now holds the
  104.                 ## holds the name of the newsgroup
  105.  
  106.   system "$NEWSPATH/bin/nntpget -f $SCRIPTPATH/lastget -n @newsgroup[0] -o -v $PROVIDER"
  107.     || print "could not pull articles for @newsgroup[0]\n";
  108.   }
  109.  
  110. close(LIST);
  111.  
  112. system "touch $SCRIPTPATH/lastget";
  113.  
  114.  
  115. ##
  116. ## strip the "NNTP-Posting-Host: " header out of my local posts, which are
  117. ## about to be sent
  118. ##
  119.  
  120. open(LIST, "/usr/spool/news/out.going/$NEWSFEED")
  121.     || die "could not open list of articles to be stripped";
  122.  
  123. while (<LIST>) {
  124.   if (@article = split(' ', $_)) {
  125.     $article = @article[0];    
  126.     rename("$article", "$article" . '.bak');
  127.     $backup = "$article.bak";
  128.     open(OUTPUT, ">> $article");
  129.     open(INPUT, "$backup");
  130.     select(OUTPUT);
  131.     while (<INPUT>) {
  132.       print unless ?^NNTP-Posting-Host.*\n?
  133.       }
  134.     close(OUTPUT);
  135.     close(INPUT);
  136.     unlink("$backup");
  137.     reset;
  138.   }
  139. }
  140. select(STDOUT);
  141.  
  142. close(LIST);
  143.  
  144. ##
  145. ## send the articles
  146. ##
  147.  
  148. $ENV{'NNTPSERVER'} = "$PROVIDER";
  149.  
  150. open(LIST, '/usr/spool/news/out.going/$NEWSFEED')
  151.     || die "could not open list of outgoing articles";
  152.  
  153. while (<LIST>) {
  154.   if (@article = split(' ', $_)) {
  155.     $article = @article[0];
  156.     system "inews -h $article";
  157.     }
  158.   }
  159.  
  160. close(LIST);
  161.  
  162. ------------------------------------------------------------------------------
  163.  
  164.  
  165. That should do it.  Assuming you've named the perl script 'foonews,' then
  166. next time you're online, type '$SCRIPTPATH/foonews' and hit return.  If
  167. you see message ID's start to march down your screen, then you're in
  168. business.  Note that things don't happen instantaneously.  You may have to
  169. wait a few seconds before the first message ID appears.  When you're done,
  170. you should have all the articles that have been posted since
  171. $SCRIPTPATH/lastget was last modified, and all your locally posted articles
  172. should have been posted to your NNTP server, which will pass them on
  173. downstream.  $SCRIPTPATH/lastget should now have today's timestamp, so that
  174. when you do 'foonews' tomorrow, you get all the articles that have been
  175. posted between now and tomorrow's newsrun.
  176.  
  177. You'll have to wipe the /usr/local/news/out.going/$NEWSFEED file manually.
  178. I purposely left this step out of the script for debugging reasons, and
  179. haven't gotten around to fixing it yet.  The first time I tried all this
  180. out, I verified that the articles had been posted to the remote server
  181. before I wiped their entries.  You might want to do the same.
  182.  
  183. If you've configured INN correctly, then $NEWSPATH/bin/news.daily takes care
  184. of maintenance quite nicely.  Right now I'm doing everything manually; you
  185. might want to automate things with some crontab entries.
  186.  
  187. One last note:  I don't pretend that my script is elegant, or that this
  188. method is foolproof or fail-safe.  But it is working for me, so I wanted
  189. to share it.
  190.  
  191.  
  192. Thanks to everyone who has made Linux the ton of fun that it is.
  193.  
  194.  
  195. ****************************************************************************
  196.  
  197. Kent Lewis
  198. klewis@inst.com
  199.  
  200.  
  201.