v07i113: Bootstrap News (bsnews) v1.1

Brandon S. Allbery - comp.sources.misc allbery at uunet.UU.NET
Sun Aug 6 12:05:07 AEST 1989


Posting-number: Volume 7, Issue 113
Submitted-by: ron at mlfarm.UUCP (Ronald Florence)
Archive-name: bsnews1.1

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	Readme
#	Makefile
#	checknews.c
#	rnews.c
#	uurec.proto
#	pn.proto
#	readnews.proto
# This archive created: Sun Jul 30 16:04:22 1989
# By:	Ronald Florence (Maple Lawn Farm, Stonington, CT)
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'Readme'" '(2094 characters)'
if test -f 'Readme'
then
	echo shar: "will not over-write existing file 'Readme'"
else
sed 's/^X//' << \SHAR_EOF > 'Readme'
X	bsnews - Bootstrap News
X	copyright 1989 Ronald Florence
X
X	Bootstrap News is a collection of programs which enable a
X	leaf node to take a news feed without installing a full news
X	package.  News articles are accumulated in a Unix-mail type
X	spool file, where they can be read with a mail reader such
X	as Mail or elm.
X
X	The Makefile builds the following programs and files:
X
X		rnews  -    run by "uux - yoursys!rnews" from a
X			    remote system to read single articles, 
X			    batched, or batched and compressed 
X			    news into the news spool.
X
X		uurec -     reads articles which arrive as mail 
X			    via "sendnews" into the news spool.
X
X		pn -	    a simple news poster.
X
X		checknews - monitors whether new news has arrived.
X
X		readnews -  invokes the mail reader.
X
X		/usr/lib/news/seq - last outgoing article number.
X
X		/usr/spool/news/bsnews - the mail spool.
X
X	To build bootstrap news, make any changes needed in the
X	Makefile, and run make.  For a uux feed, add rnews to
X	/usr/lib/uucp/L.cmds or the equivalent uucp permissions
X	file.  You will need /usr/bin/compress for compressed feeds.
X	For a sendnews feed, create a sendmail alias for rnews: 
X        "|/usr/bin/uurec", or use cron to run uurec periodically 
X	with /usr/spool/mail/rnews as input.  Adding checknews to 
X	your .login or .profile file will give you notification of 
X	new news when you log in.
X
X	You may need to customize "pn":
X	     If your echo uses -n to suppress newlines,
X	     If logname does not give the user's name,
X	     If "uuname -l" does not give the system's uucp name,
X	     To use an editor other than vi to compose outgoing news,
X	     To proof outgoing articles with a pager other than more,
X	     Or to post news by mail.
X
X	Permission is hereby granted for unlimited non-commercial
X	use of these programs, on condition that the copyright
X	notices are left intact and any modifications to the source
X	code are noted as such.  No warranty of any kind is implied
X	or granted for this material.
X
X	Ronald Florence			
X	Maple Lawn Farm, Stonington, CT	
X	ron at mlfarm.uucp  
X	...{hsi!aati,rayssd}!mlfarm!ron
SHAR_EOF
if test 2094 -ne "`wc -c < 'Readme'`"
then
	echo shar: "error transmitting 'Readme'" '(should have been 2094 characters)'
fi
fi
echo shar: "extracting 'Makefile'" '(1946 characters)'
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X# Makefile for bootstrap news
X# copyright 1989 Ronald Florence  (ron at mlfarm, 7/30/89)
X#
X# To build bootstrap news:
X#   1. Change READER to your favorite mail reader with the option flag
X#      used to specify a spool file.
X#   2. Change HOST to the name of your news feed.  If you get news
X#      from more than one host, select the one to which you feed news,
X#      and change FEEDER to something like Usenet_news.
X#   3. Run make.  
X#
X
XREADER = Mail -f
XHOST = mlfarm
XFEEDER = news@$(HOST).UUCP
X
XSPOOL = /usr/spool/news
XNEWSSPOOL = $(SPOOL)/bsnews
XNEWSDIR = /usr/lib/news
XSEQFILE = $(NEWSDIR)/seq
XBINDIR = /usr/bin
XCOMPRESS = $(BINDIR)/compress
XCFLAGS = -O -s -DFeeder='"$(FEEDER)"' -DNewsspool='"$(NEWSSPOOL)"'
XPGMS = uurec pn checknews rnews readnews
XFILES = spoolfile seqfile
XSRCS = checknews.c rnews.c uurec.proto pn.proto readnews.proto
XSHELL = /bin/sh
X
Xbsnews:  install
X
Xinstall: $(PGMS) $(FILES)
X	 cp $(PGMS) $(BINDIR)
X	 cd $(BINDIR)
X	 chgrp bin $(PGMS)
X	 chown bin $(PGMS)
X	 @echo
X	 @echo "Add \"rnews\" to /usr/lib/uucp/L.cmds or the equivalent for a"
X	 @echo "uux feed.  For a mail feed, create a sendmail alias for rnews:"
X	 @echo "|/usr/bin/uurec or run \"uurec\" periodically from cron with"
X	 @echo "/usr/spool/mail/rnews as input."
X	 @ [ -x $(COMPRESS) ] || { echo "You need $(COMPRESS) for compressed feeds."; }
X
Xspoolfile:
X	[ -d $(SPOOL) ] || mkdir $(SPOOL)
X	[ -f $(NEWSSPOOL) ] || > $(NEWSSPOOL)
X	chmod 666 $(NEWSSPOOL)
X
Xseqfile:
X	[ -f $(SEQFILE) ] || { mkdir $(NEWSDIR); echo "1" > $(SEQFILE); }
X	chmod 666 $(SEQFILE)
X
Xuurec:	uurec.proto
X	sed "s|/usr/spool/news/bsnews|$(NEWSSPOOL)|" uurec.proto > uurec
X	chmod +x uurec
X
Xpn:	pn.proto
X	sed  "s/BigNode/$(HOST)/" pn.proto > pn
X	chmod +x pn
X
Xreadnews: readnews.proto
X	sed "s|Mail -f /usr/spool/news/bsnews|$(READER) $(NEWSSPOOL)|" readnews.proto > readnews
X	chmod +x readnews
X
Xshar:	Readme Makefile $(SRCS)
X	shar -a Readme Makefile $(SRCS) > bsnews.shar
X
Xclean:
X	rm -f $(PGMS) 
SHAR_EOF
if test 1946 -ne "`wc -c < 'Makefile'`"
then
	echo shar: "error transmitting 'Makefile'" '(should have been 1946 characters)'
fi
fi
echo shar: "extracting 'checknews.c'" '(707 characters)'
if test -f 'checknews.c'
then
	echo shar: "will not over-write existing file 'checknews.c'"
else
sed 's/^X//' << \SHAR_EOF > 'checknews.c'
X/*
X * checknews.c - checks for bootstrap news
X * copyright 1989 Ronald Florence (ron at mlfarm, 7/30/89)
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#ifndef Newsspool
X#define Newsspool  "/usr/spool/news/bsnews"
X#endif
X#define bye(s)	   puts(s), exit(1)
X
Xmain()
X{
X  struct stat nt, lt;
X  char newsmarker[80], *getenv();
X
X  if (!strcpy(newsmarker, getenv("HOME")))
X    bye("checknews: cannot find $HOME.");
X  strcat(newsmarker, "/.lastnews");
X  if (stat(newsmarker, &lt) == -1)
X    lt.st_mtime = 0;
X  if (stat(Newsspool, &nt) == -1)
X    bye("checknews: cannot find Newsspool.");
X  puts(nt.st_mtime < lt.st_mtime ? "No news is good news.":\
X       "New news has arrived.");
X  exit(0);
X}
SHAR_EOF
if test 707 -ne "`wc -c < 'checknews.c'`"
then
	echo shar: "error transmitting 'checknews.c'" '(should have been 707 characters)'
fi
fi
echo shar: "extracting 'rnews.c'" '(1918 characters)'
if test -f 'rnews.c'
then
	echo shar: "will not over-write existing file 'rnews.c'"
else
sed 's/^X//' << \SHAR_EOF > 'rnews.c'
X/*
X * rnews.c - uux command for bootstrap news
X * copyright 1989 Ronald Florence (ron at mlfarm 7/30/89)
X */
X
X#include <stdio.h>
X#include <time.h>
X
X#ifndef Newsspool
X#define Newsspool    "/usr/spool/news/bsnews"
X#endif
X#ifndef Feeder
X#define Feeder	     "Usenet"
X#endif
X
X#define Compress     "/usr/bin/compress -dc > "
X
Xchar  	*mktemp(),
X        dcomp[40] = Compress;
X
Xmain()
X{
X  FILE	*nf, *cf;
X  char  buf[BUFSIZ],
X        *tmpnews = mktemp("newsart.XXXXXX");
X  register  c;
X  int	new = 1, n;
X
X  if (!(nf = fopen(Newsspool, "a")))
X    {
X      fprintf(stderr, "rnews: can't write to %s\n", Newsspool);
X      exit(1);
X    }
X
X  while (fgets(buf, BUFSIZ, stdin) != NULL)
X    {
X				/* batched? */
X      if (!strncmp(buf, "#! ", 3))
X	{
X				/* compressed? */
X	  if (!strncmp(buf+3, "cunbatch", 8))
X	    {
X	      strcat(dcomp, tmpnews);
X	      if (!(cf = popen(dcomp, "w")))
X		{
X		  timestamp(nf);
X		  fprintf(nf, "\nNews lost!  Can't uncompress (rnews).\n\n");
X		  exit(1);
X		}
X				/* uncompress */
X	      while ((c = getchar()) != EOF)
X		putc(c, cf);
X	      pclose(cf);
X				/* and loop around to unbatch */
X	      cf = freopen(tmpnews, "r", stdin);
X	      continue;
X	    }
X				/* unpack the batch */
X	  else if (sscanf(buf+3, "rnews %d", &n) == 1)  
X	    {
X	      timestamp(nf);
X	      for (c = 0; c < n; c += strlen(buf))
X		{
X		  if (fgets(buf, BUFSIZ, stdin) == NULL)
X		    break;
X		  if (!strncmp(buf, "From ", 5))
X		    putc('>', nf);
X		  fputs(buf, nf);
X		}
X	      putc('\n', nf);
X	      continue;
X	    }
X	}
X				/* it must be unbatched */
X      else	
X	{
X	  if (new)
X	    {
X	      timestamp(nf);
X	      new = 0;
X	    }
X	  if (!strncmp(buf, "From ", 5))
X	    putc('>', nf);
X	  fputs(buf, nf);
X	}
X    }
X  if (!new)
X    putc('\n', nf);
X  unlink(tmpnews);
X  exit(0);
X}
X
X
Xtimestamp(newsfile)
XFILE  *newsfile;
X{
X  long	clock, time();
X  char	*ctime();
X
X  time(&clock);
X  fprintf(newsfile, "From %s %s", Feeder, ctime(&clock));
X}
SHAR_EOF
if test 1918 -ne "`wc -c < 'rnews.c'`"
then
	echo shar: "error transmitting 'rnews.c'" '(should have been 1918 characters)'
fi
fi
echo shar: "extracting 'uurec.proto'" '(317 characters)'
if test -f 'uurec.proto'
then
	echo shar: "will not over-write existing file 'uurec.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'uurec.proto'
X:
X#! /bin/sh
X# uurec - bootstrap news by mail 
X# copyright 1989 Ronald Florence  (ron at mlfarm, 7/6/89)
X
XNewsspool=/usr/spool/news/bsnews
X
Xsed	'/^Received: .*/d
X	/^	id .*/d
X	/^Subject: .*/d
X	/^To: .*/d
X	/^Message-Id: .*/d
X	/^Date: .*/d
X	/^From: .*/d
X	s/^NFrom />From /
X	s/^N//'  >> $Newsspool
Xecho "\n" >> $Newsspool
X
X
SHAR_EOF
if test 317 -ne "`wc -c < 'uurec.proto'`"
then
	echo shar: "error transmitting 'uurec.proto'" '(should have been 317 characters)'
fi
chmod +x 'uurec.proto'
fi
echo shar: "extracting 'pn.proto'" '(928 characters)'
if test -f 'pn.proto'
then
	echo shar: "will not over-write existing file 'pn.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'pn.proto'
X:
X#! /bin/sh
X# pn - news poster for bootstrap news 
X# Copyright 1989 Ronald Florence (ron at mlfarm, 7/30/89)
X#
X
XHostname=BigNode
XSeqfile=/usr/lib/news/seq
Xset `date`
XDatestr="$3 $2 `expr $6 % 100` $4 $5"
XID=`cat $Seqfile`
XSys=`uuname -l`
XUser=`logname`
X
Xecho "Newsgroups: \c"
Xread Groups rest
Xecho "Subject: \c"
Xread Subject rest
X
XTmpart=/tmp/newsart.$$
X
Xcat > $Tmpart <<EOH
XPath: $Sys!$User
XFrom: $User@$Sys.UUCP
XNewsgroups: $Groups
XSubject: $Subject
XMessage-ID: <$ID@$Sys.UUCP>
XDate: $Datestr
XFollowup-To: 
XDistribution:
XKeywords: 
XOrganization:
XLines: 
X
X
XEOH
X
Xvi +13 $Tmpart
X
Xcls
Xmore $Tmpart
Xecho "----------"
Xecho "\nPost this article to all of usenet? \c"
Xwhile read yn
X  do case $yn in
X    y*|Y*) uux - -r $Hostname!rnews < $Tmpart ; 
X	   echo `expr $ID + 1` > $Seqfile ;
X	   echo "Posted!" ;
X	   break ;;
X    n*|N*) echo "Article cancelled!" ;
X	   break ;;
X        *) echo "Yes or no? \c" ;;
X    esac
X  done
Xrm -f $Tmpart
SHAR_EOF
if test 928 -ne "`wc -c < 'pn.proto'`"
then
	echo shar: "error transmitting 'pn.proto'" '(should have been 928 characters)'
fi
fi
echo shar: "extracting 'readnews.proto'" '(166 characters)'
if test -f 'readnews.proto'
then
	echo shar: "will not over-write existing file 'readnews.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'readnews.proto'
X:
X#! /bin/sh
X# readnews - news reader for bootstrap news
X# copyright 1989 Ronald Florence (ron at mlfarm, 7/30/89)
X
XMail -f /usr/spool/news/bsnews
Xtouch $HOME/.lastnews
SHAR_EOF
if test 166 -ne "`wc -c < 'readnews.proto'`"
then
	echo shar: "error transmitting 'readnews.proto'" '(should have been 166 characters)'
fi
fi
exit 0
#	End of shell archive
-- 

Ronald Florence
...{hsi!aati,rayssd}!mlfarm!ron



More information about the Comp.sources.misc mailing list