[net.sources] uuhosts - USENET news and UUCP mail information

jsq@ut-sally.UUCP (John Quarterman) (06/05/84)

The rest of this article following this paragraph is a shar archive
containing a Bourne shell script (and its manual entry) which can be
used as a command to interpret the USENET news map information posted
to net.news.map by cbosgd!map as well as to show the route to a site
chosen by certain kinds of UUCP mail routing software.  When called
by inews according to a line in news/sys, the same shell script can
be used (with the appropriate option) to automatically update the
local copy of the map when new articles come in from cbosgd!map.
Though this command is used here under 4.2BSD, I do not believe there
is anything in it that will not work under System V, System III, or even
Version 7.  Whether it will work with news software prior to B news 2.10,
I have no idea.


: This is a shar archive.  Extract with sh, not csh.
echo x - uuhosts
cat > uuhosts << '!Funky!Stuff!'
#!/bin/sh
# '@(#) uuhosts.sh 1.13 84/05/12'

LIB=/usr/local/lib

# Routing information produced by pathalias.
paths=$LIB/nmail.paths

# This directory should contain the information from newsgroup net.news.map
# that is posted about once a month from cbosgd!map, extracted by a line
# like this in $LIB/news/sys:
#	newsmap:net.news.map:B:/usr/local/uuhosts -x
# Locally-known information should go in $LIB/news/net.news.map/Local.
cd $LIB/news/net.news.map

# If this variable is non-null, map updates will only be accepted from here.
mapfrom=
#mapfrom="map@cbosgd.UUCP"

case $1 in
	-x)
		# extract a new map piece into the map directory
		temphead=/tmp/newsmaphead.$$
		temptext=/tmp/newsmaptext.$$
		echo '
Automatic update of USENET news map:
' > $temptext
		awk '
BEGIN	{
	mapfrom = "'$mapfrom'"; temphead = "'$temphead'";
	shead = 0; secho = 1; stext = 2; state = shead;
}
state == shead && /^From: /	{
	from = $2;
	if (mapfrom != "" && from != mapfrom) {
		print "Subject:  spurious news map update " $0 > temphead;
		exit 1
	}
}
state == shead && /^Subject: /	{ print $0 > temphead; }
state == shead && /^$/		{ state = secho; }
state == secho && /^echo /	{ state = stext; }
state == stext			{ print | "/bin/sh"; }
' >> $temptext 2>&1
#		if test $? != 0
#		then
#			rm -f $temphead $temptext
#			exit 1
#		fi
		cat $temphead $temptext | /bin/mail usenet
		rm -f $temphead $temptext
		exit 0
	;;
	-g)
		# by geographical region
		shift
		if test $# -eq 0
		then
			exec ls
			exit 1
		fi
		exec cat $*
		exit 1
	;;
	-k)
		# by keyword
		shift
		exec awk '
BEGIN		{ inside = 1; outside = 0; state = outside; }
/^Name:/	{ state = inside; count = 0; useit = 0; }
state == inside	{ block[count++] = $0; }
/'"$*"'/	{ useit = 1; }
/^$/ && state == inside	{
	if (useit == 1) {
		for (i = 0; i < count; i++) {
			print block[i];
		}
	}
	state = outside;
}
' *
		exit 1
	;;
	-*)
		# unknown option
	;;
	"")
		# no arguments
	;;
	*)
		# by site name
		for arg in $*
		do
			echo 'UUCP mail path:'
			grep '^'${arg} $paths
			echo '
USENET news site information:'
			sed -n -e "/^Name:[ 	]*${arg}/,/^$/p" *
		done
		exit 0
	;;
esac

echo 'Usage:	'uuhosts' hostname ...
for information about a particular UUCP or USENET host or hosts, or

	'uuhosts' -g geographical-region
for information about USENET news sites in a geographical region, or

	'uuhosts' -g
for a list of known USENET geographical-regions.
'
exit 1
!Funky!Stuff!
echo x - uuhosts.1
cat > uuhosts.1 << '!Funky!Stuff!'
.TH UUHOSTS 1L 84/05/12
.SH NAME
uuhosts \- USENET news and UUCP mail information.
.SH SYNOPSIS
.B
uuhosts
hostname ...
.br
.B
uuhosts
-g geographical-region
.br
.B
uuhosts
-k keyword
.br
.B
uuhosts
-g
.br
.B
uuhosts
-x
.SH DESCRIPTION
The \fIuuhosts\fP command is used to look up information about
the configuration of the UUCP mail network and USENET news network
configurations.
.TP
uuhosts \fIhostname\fP ...
for information about a particular UUCP or USENET host or hosts.
The UUCP mail path is given first, followed by the USENET news site information.
Any hosts with names for which the argument is a prefix are shown, e.g.:
.TP
uuhosts ut
gets information about all hosts whose names start with ``ut''.
.TP
uuhosts -g \fIgeographical-region\fP
for information about USENET news hosts in a geographical region.
.TP
uuhosts -g README
gets an introduction to the USENET news map.
.TP
uuhosts -g Local
gets USENET news information known only locally.
.TP
uuhosts -g
for a list of known USENET geographical-regions.
.TP
uuhosts -k \fIkeyword\fP
for a list of known USENET sites whose entries contain the word \fIkeyword\fP.
.TP
uuhosts
with no arguments gets a short usage message.
.SH MAINTENANCE
In addition to the options mentioned above, there is
.TP
uuhosts -x
extracts pieces of the USENET map from a net.news.map article.
.PP
This should be called automatically by a line in \fB/usr/local/lib/news/sys\fP
like
.IP
newsmap:net.news.map:B:/usr/local/uuhosts -x
.SH FILES
.TP
/usr/local/lib/nmail.paths
UUCP mail path database as produced by \fIpathalias\fP and used by \fInmail\fP
(which is called automatically from \fIsendmail\fP on \fIut\-sally\fP)
.TP
/usr/local/lib/news/net.news.map
USENET news site information taken from newsgroup \fBnet.news.map\fP
(thanks to \fBcbosgd!map\fP).
.TP
/usr/local/lib/news/sys
Contains arrangements to call uuhosts -x to extract USENET map information.
.TP
/usr/local/lib/pairs
Raw UUCP mail connection map from \fBparsec!kolstad\fP (thanks again).
.TP
/usr/local/lib/pairs.local
Locally known mail connections.
.SH SEE ALSO
vnews(1), readnews(1), mail(1), sendmail(8)
!Funky!Stuff!
-- 
John Quarterman, CS Dept., University of Texas, Austin, Texas 78712 USA
jsq@ut-sally.ARPA, jsq@ut-sally.UUCP, {ihnp4,seismo,ctvax}!ut-sally!jsq