[comp.sources.misc] script to post news to an NFS-mounted news system

allbery@ncoast.UUCP (06/12/87)

#! /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 the files:
#	inews.sh
# This archive created: Fri Jun 12 01:12:30 1987
export PATH; PATH=/bin:$PATH
echo shar: extracting "'inews.sh'" '(2347 characters)'
if test -f 'inews.sh'
then
	echo shar: will not over-write existing file "'inews.sh'"
else
sed 's/^	X//' << \SHAR_EOF > 'inews.sh'
	X#!/bin/sh
	X# A common situation is for a machine to use NFS to mount /usr/spool/news
	X# remotely from another machine. This lets you read news via rn,
	X# but it does not let you post news, since you have no inews program for
	X# Pnews to call.
	X# 
	X# This shell will let you post mail by sendmailing it to another machine.
	X# It was written to run on Suns, but can probably be made to work on other machines.
	X#
	X# You will have to change the name "oopsvax" to the name of a machine you
	X# can send mail to that has rnews. (We use shasta, but you shouldn't unless you
	X# are at Stanford).
	X#
	X# You will need to create the file /usr/lib/news/counter
	X# (or wherever you decide to put it) to count message numbers.
	X# It should start out containing the number "1".
	X#
	X# A copy of your article will be left in your home directory, called "article".
	X#
	X# By Joe Dellinger
	X# further hacking by Conor Rafferty
	X#
	X
	X#initialization
	Xcounter=/usr/lib/news/counter
	Xuserart=$HOME/article
	Xoopsvax=???????
	Xitmp=/tmp/itmp$$
	Xtrap "rm -f /tmp/itmp*" 0 1 2 3 13 15
	X
	X#host and user name. Try the password file, then the yellow pages muck.
	Xif test "$hostname" = "" ; then hostname=`hostname`; fi
	Xpassline=`grep :$USER: /etc/passwd` ||
	Xpassline=`ypmatch $USER passwd.byname` ||
	Xpassline=dummy:dummy:dummy:dummy:$USER
	Xexport passline
	Xfullname="`(IFS=:;set $passline; echo $5)`"
	X
	X# Grab stdin
	Xcat > $userart
	Xif \[ -f $HOME/.signature \] ; then
	Xcat $HOME/.signature >> $userart
	Xfi
	X
	X# Increment the message ID number for this system
	Xnumber=`cat $counter`
	Xnumber=`expr $number + 1`
	Xecho $number > $counter
	X
	X# simulate inews header
	X# remote rnews does a lot of the work itself (date reformat, Lines)
	Xecho "Subject: network news posting"            > $itmp
	Xecho "To: rnews@$oopsvax"                      >> $itmp
	Xecho ""                                        >> $itmp
	Xecho "NPath: $hostname!$USER"                  >> $itmp  #path back to you
	Xecho "NFrom: $USER@$hostname.UUCP ($fullname)" >> $itmp  #want the full name
	Xecho "NMessage-ID: <$number@$hostname.UUCP>"   >> $itmp  #rnews junks it otherwise
	Xecho "NDate: `date`"                           >> $itmp  #ditto
	X
	X#stuff in the user input
	Xsed 's/^/N/' $userart                          >> $itmp
	X
	X
	X# Send it off to $oopsvax to be posted
	X/usr/lib/sendmail -i rnews@$oopsvax < $itmp
	X
	X# That's it. The article is left in your home directory.
SHAR_EOF
if test 2347 -ne "`wc -c < 'inews.sh'`"
then
	echo shar: error transmitting "'inews.sh'" '(should have been 2347 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0