home *** CD-ROM | disk | FTP | other *** search
- From decwrl!ucbvax!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!allbery Thu Aug 3 08:51:06 PDT 1989
- Article 991 of comp.sources.misc:
- Path: decwrl!ucbvax!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!allbery
- From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
- Newsgroups: comp.sources.misc
- Subject: v07i099: bsnews - Bootstrap News
- Message-ID: <61162@uunet.UU.NET>
- Date: 22 Jul 89 01:19:08 GMT
- Sender: allbery@uunet.UU.NET
- Reply-To: ron@mlfarm.UUCP (Ronald Florence)
- Organization: Maple Lawn Farm, Stonington, CT
- Lines: 397
- Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 7, Issue 99
- Submitted-by: ron@mlfarm.UUCP (Ronald Florence)
- Archive-name: bsnews
-
- [[A patch for this arrived before this went out; I applied it, so this
- is effectively at patclevel 1. ++bsa]]
- [[This cleans out the c.s.m queue, except for one program (indexor) which
- needs to be split to avoid message length limits. ++bsa]]
-
- Bootstrap News is a collection of programs which enable a leaf node to
- take a news feed without installing a full news package. News
- articles are accumulated in a Unix-mail type spool file, where they
- can be read with a mail reader such as `Mail' or `elm'.
-
- #--------------------------------CUT HERE-------------------------------------
- #! /bin/sh
- #
- # This is a shell archive. Save this into a file, edit it
- # and delete all lines above this comment. Then give this
- # file to sh by executing the command "sh file". The files
- # will be extracted into the current directory owned by
- # you with default permissions.
- #
- # The files contained herein are:
- #
- # -rw-r--r-- 1 allbery 1987 Jul 21 21:14 Readme
- # -rw-r--r-- 1 allbery 1759 Jul 21 21:14 Makefile
- # -rw-r--r-- 1 allbery 1890 Jul 21 21:14 rnews.c
- # -rw-r--r-- 1 allbery 409 Jul 21 21:14 checknews.c
- # -rw-r--r-- 1 allbery 306 Jul 21 21:14 uurec.proto
- # -rw-r--r-- 1 allbery 987 Jul 21 21:11 pn.proto
- #
- echo 'x - Readme'
- if test -f Readme; then echo 'shar: not overwriting Readme'; else
- sed 's/^X//' << '________This_Is_The_END________' > Readme
- Xbsnews - Bootstrap News
- Xcopyright 1989 Ronald Florence
- X
- XBootstrap News is a collection of programs which enable a leaf node to
- Xtake a news feed without installing a full news package. News
- Xarticles are accumulated in a Unix-mail type spool file, where they
- Xcan be read with a mail reader such as `Mail' or `elm'.
- X
- XThe Makefile builds the following programs and files:
- X
- X rnews - run by a `uux - yoursys!rnews' command to
- X read single articles, batched, or batched
- X and compressed news into the news spool.
- X
- X uurec - posts 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
- XTo build bootstrap news, make any changes needed in `Makefile', and
- Xrun `make'. For a `uux' feed, add `rnews' to /usr/lib/uucp/L.cmds or
- Xthe equivalent. For a `sendnews' feed, create a sendmail alias for
- Xrnews: "|/usr/bin/uurec", or use cron to run `uurec' periodically with
- X/usr/spool/mail/rnews as input. Adding the command `checknews' to
- Xyour `.login' or `.profile' file will give you notification of new
- Xnews when you log in.
- X
- XYou may need to change `pn.proto':
- X If your `echo' uses `-n' instead of `\c' to suppress the newline,
- 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, or
- X To proof outgoing articles with a pager other than `more'.
- X
- XPermission is hereby granted for unlimited non-commercial use of these
- Xprograms, on condition that the copyright notices are left intact and
- Xany modifications to the source code are noted as such. No warranty
- Xof any kind is implied or granted for this material.
- X
- X
- XRonald Florence
- XMaple Lawn Farm, Stonington, CT
- Xron@mlfarm
- X...{hsi!aati,rayssd}!mlfarm!ron
- ________This_Is_The_END________
- if test `wc -c < Readme` -ne 1987; then
- echo 'shar: Readme was damaged during transit (should have been 1987 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'x - Makefile'
- if test -f Makefile; then echo 'shar: not overwriting Makefile'; else
- sed 's/^X//' << '________This_Is_The_END________' > Makefile
- X# Makefile for bootstrap news
- X# copyright 1989 Ronald Florence (ron@mlfarm, 7/11/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
- XSHELL = /bin/sh
- X
- Xbsnews: install
- X @ [ -x $(COMPRESS) ] || { echo "You need $(COMPRESS) for batched & compressed feeds."; }
- 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 for a uux feed, or create a"
- X @echo "sendmail alias for rnews: \"|/usr/bin/uurec\" for a mail feed."
- 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:
- X echo "$(READER) $(NEWSSPOOL)" > readnews
- X chmod +x readnews
- X
- Xshar: Readme Makefile $(SRCS)
- X shar -a Readme Makefile $(SRCS) > bsnews.shar
- X
- Xclean:
- X rm $(PGMS)
- ________This_Is_The_END________
- if test `wc -c < Makefile` -ne 1759; then
- echo 'shar: Makefile was damaged during transit (should have been 1759 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'x - rnews.c'
- if test -f rnews.c; then echo 'shar: not overwriting rnews.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > rnews.c
- X/*
- X * rnews.c - uux command for bootstrap news
- X * copyright 1989 Ronald Florence (ron@mlfarm 7/9/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();
- 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 fgets(buf, BUFSIZ, stdin);
- 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}
- ________This_Is_The_END________
- if test `wc -c < rnews.c` -ne 1890; then
- echo 'shar: rnews.c was damaged during transit (should have been 1890 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'x - checknews.c'
- if test -f checknews.c; then echo 'shar: not overwriting checknews.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > checknews.c
- X/*
- X * checknews.c - checks for bootstrap news
- X * copyright 1989 Ronald Florence (ron@mlfarm, 7/7/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
- Xmain()
- X{
- X struct stat st;
- X
- X if (stat(Newsspool, &st) == -1)
- X st.st_size = 0;
- X if (st.st_size && (st.st_atime < st.st_mtime))
- X puts("New news has arrived.");
- X}
- ________This_Is_The_END________
- if test `wc -c < checknews.c` -ne 409; then
- echo 'shar: checknews.c was damaged during transit (should have been 409 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'x - uurec.proto'
- if test -f uurec.proto; then echo 'shar: not overwriting uurec.proto'; else
- sed 's/^X//' << '________This_Is_The_END________' > uurec.proto
- X:
- X# uurec - bootstrap news by mail
- X# copyright 1989 Ronald Florence (ron@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
- ________This_Is_The_END________
- if test `wc -c < uurec.proto` -ne 306; then
- echo 'shar: uurec.proto was damaged during transit (should have been 306 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'x - pn.proto'
- if test -f pn.proto; then echo 'shar: not overwriting pn.proto'; else
- sed 's/^X//' << '________This_Is_The_END________' > pn.proto
- X:
- X# pn - news poster for bootstrap news
- X# Copyright 1989 Ronald Florence (ron@mlfarm, 7/7/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|yes|Yes|YES) uux - -r $Hostname!rnews < $Tmpart ;
- X echo `expr $ID + 1` > $Seqfile ;
- X echo "Posted!" ;
- X break ;;
- X n|N|no|No|NO) echo "Article cancelled!" ;
- X break ;;
- X *) echo "Yes or no? \c" ;;
- X esac
- X done
- Xrm -f $Tmpart
- ________This_Is_The_END________
- if test `wc -c < pn.proto` -ne 987; then
- echo 'shar: pn.proto was damaged during transit (should have been 987 bytes)'
- fi
- fi ; : end of overwriting check
- exit 0
- --
- Ronald Florence ...{hsi!aati,rayssd}!mlfarm!ron
-
-
-