#!/bin/sh
#
#  @(#)update_netdocs	2.2 5/9/91
#
#  Author: Kent Landfield
#
# This script is called by rkive to keep current all the periodic postings
# that I save. 
#
# called as:
#    update_netdocs filename-to-archive modes owner group [users to notify..] 
#
PATH=/bin:/etc:/usr/ucb:/usr/bin

#set -x  # Exterminator flag

ARTICLE=/usr/local/bin/article

approved=NOCHECK
from=NOCHECK

basedir=/usr/doc/news

if [ $# -lt 4 ]
then
	echo "usage: $0 FileToSave modes owner group [ user to notify ... ]"
	exit 1
fi

fl_to_archive=$1
modes=$2
owner=$3
group=$4

shift; shift; shift; shift

SUB=`$ARTICLE -f "%T" $fl_to_archive`
case $SUB in
	# 
	# comp.misc
	#
	"Anonymous FTP list")
		filename=$basedir/'anonymous.ftp' 
		from="odin@pilot.njin.net (Jon Granrose)"
		;;
	# 
	# comp.mail.misc
	#
	"Inter-Network Mail Guide")
		filename=$basedir/'mail.quide' 
		;;
	# 
	# comp.std.unix
	#
	"Access to UNIX-Related Standards")
		filename=$basedir/'unix.standards' 
		approved="sef@uunet.uu.net (Moderator, Sean Eric Fagan - comp.std.unix)"
		;;
	"Calendar of UNIX-related Events")
		filename=$basedir/'unix.events' 
		approved="sef@uunet.uu.net (Moderator, Sean Eric Fagan - comp.std.unix)"
		;;
	"Access to UNIX User Groups")
		filename=$basedir/'user.groups' 
		approved="sef@uunet.uu.net (Moderator, Sean Eric Fagan - comp.std.unix)"
		;;
	"Access to UNIX-Related Publications")
		filename=$basedir/'unix.pubs' 
		approved="sef@uunet.uu.net (Moderator, Sean Eric Fagan - comp.std.unix)"
		;;
	# 
	# News.admin
	#
	"Checkgroups message (without INET groups)")
		filename=$basedir/admin/'checkgroups' 
		from="spaf@cs.purdue.EDU (Gene Spafford)"
		;;
	"Checkgroups message (with INET groups)")
		filename=$basedir/admin/'checkgroups' 
		from="spaf@cs.purdue.EDU (Gene Spafford)"
		;;
        "How to Create a New Trial Newsgroup")
		filename=$basedir/admin/'trial.create' 
		approved="spaf@cs.purdue.EDU"
		;;
	"How to Construct the Mailpaths File")
		filename=$basedir/admin/'mailpaths' 
		from="spaf@cs.purdue.EDU (Gene Spafford)"
		;;
	# 
	# News.announce.newusers
	#
        "How to Get Information about Networks")
		filename=$basedir/'network.info' 
		approved="spaf@cs.purdue.EDU"
		;;
        "USENET Software: History and Sources")
		filename=$basedir/'usenet.history' 
		approved="spaf@cs.purdue.EDU"
		;;
        "A Primer on How to Work With the Usenet Community")
		filename=$basedir/'usenet.primer' 
		approved="spaf@cs.purdue.EDU"
		;;
        "Answers to Frequently Asked Questions")
		filename=$basedir/'questions' 
		approved="spaf@cs.purdue.EDU"
		;;
        "Emily Postnews Answers Your Questions on Netiquette")
		filename=$basedir/'netiquette' 
		approved="spaf@cs.purdue.EDU"
		;;
        "Hints on writing style for Usenet")
		filename=$basedir/'hints.style' 
		approved="spaf@cs.purdue.EDU"
		;;
	"Regional Newsgroup Hierarchies")
		filename=$basedir/'regionals' 
		approved="spaf@cs.purdue.EDU"
		;;
        "Rules for posting to Usenet")
		filename=$basedir/'posting.rules' 
		approved="spaf@cs.purdue.EDU"
		;;
	"How to Create a New Newsgroup")
		filename=$basedir/'create.group' 
		approved="spaf@cs.purdue.EDU"
		;;
	"List of Periodic Informational Postings")
		filename=$basedir/'info.postings' 
		approved="spaf@cs.purdue.EDU"
		;;
	"List of Active Newsgroups")
		filename=$basedir/'active.groups' 
		approved="spaf@cs.purdue.EDU"
		;;
	"Alternative Newsgroup Hierarchies")
		filename=$basedir/'alt.groups' 
		approved="spaf@cs.purdue.EDU"
		;;
	"List of Moderators")
		filename=$basedir/'moderators' 
		approved="spaf@cs.purdue.EDU"
		;;
	"Publicly Accessible Mailing Lists")
		filename=$basedir/'mail.lists' 
		approved="spaf@cs.purdue.EDU"
		;;
	#
	#################################################
	# Frequently Asked Questions - various newsgroups
	#################################################
	# 
	# comp.windows.x
	#
	"Frequently Asked Questions about X with Answers 1/4 [long monthly posting]")
		filename=$basedir/'X.questions.1' 
		from="xug@lta.com (X User's Group)"
		;;
	"Frequently Asked Questions about X with Answers 2/4 [long monthly posting]")
		filename=$basedir/'X.questions.2' 
		from="xug@lta.com (X User's Group)"
		;;
	"Frequently Asked Questions about X with Answers 3/4 [long monthly posting]")
		filename=$basedir/'X.questions.3' 
		from="xug@lta.com (X User's Group)"
		;;
	"Frequently Asked Questions about X with Answers 4/4 [long monthly posting]")
		filename=$basedir/'X.questions.4' 
		from="xug@lta.com (X User's Group)"
		;;
	# 
	# comp.unix.questions
	#
	"Welcome to comp.unix.questions [Monthly posting]")
		filename=$basedir/'unix.questions' 
		from="sahayman@iuvax.cs.indiana.edu (Steve Hayman)"
		;;
       "Frequently Asked Questions about Unix - with Answers [Monthly posting]")
		filename=$basedir/'unix.faq' 
		from="sahayman@iuvax.cs.indiana.edu (Steve Hayman)"
		;;
	# 
	# comp.lang.perl
	#
       "Frequently Asked Questions about Perl - with Answers [Monthly posting]")
		filename=$basedir/'perl.faq' 
                from="tchrist@convex.com (Tom Christiansen)"
		;;
	# 
	# comp.compilers
	#
	"comp.compilers monthly message")
		filename=$basedir/'compilers.faq' 
		approved="compilers@iecc.cambridge.ma.us"
		;;
	# 
	# comp.os.vms
	#
	"Monthly info posting: What is VMSnet?")
		filename=$basedir/'vmsnet.info' 
		approved="tp@mccall.com"
		;;
	"Monthly info posting: VMSnet on Bitnet")
		filename=$basedir/'bitnet.vmsnet' 
		approved="tp@mccall.com"
		;;
	"Monthly info posting: vmsnet.sources archive sites")
		filename=$basedir/'vmsnet.archives' 
		approved="tp@mccall.com"
		;;
	"Info-VAX Monthly Posting, Part 1 of 3")
		filename=$basedir/'Info-VAX.1' 
		approved="tp@mccall.com"
		;;
	"Info-VAX Monthly Posting, Part 2 of 3")
		filename=$basedir/'Info-VAX.2' 
		approved="tp@mccall.com"
		;;
	"Info-VAX Monthly Posting, Part 3 of 3")
		filename=$basedir/'Info-VAX.3' 
		approved="tp@mccall.com"
		;;
	"Monthly checkgroups posting")
		filename=$basedir/'vmsnet.checkgroups' 
		approved="tp@mccall.com"
		;;
	
	*) echo "Specified filename error. please update $0"
		exit 1 ;;
esac 

#
# Now lets see if the file has an approved submitter
#
if [ "$approved" != "NOCHECK" ]
then
	f_ap=`$ARTICLE -f"%A" $fl_to_archive`
	if [ "$f_ap" != "$approved" ]
	then
		echo 
		echo "Invalid approval found in $fl_to_archive."
		echo "Please check to assure that $0 is current..."
		echo 
		exit 1 
	fi
elif [ "$from" != "NOCHECK" ]
then
	f_ap=`$ARTICLE -f"%F" $fl_to_archive`
	if [ "$f_ap" != "$from" ]
	then
		echo 
		echo "Invalid from found in $fl_to_archive."
		echo "Please check to assure that $0 is current..."
		echo 
		exit 1 
	fi
fi
	
#
# At this point the file found has been validated as being sent
# by the appropriate person. Now it is time to save it off.
#

#if [ -f $filename ]
#then
#	mv -f $filename $filename.old
#fi

cp $fl_to_archive $filename
chmod $modes $filename
chown $owner $filename
chgrp $group $filename

while [ $1 ]
do
	echo "$filename Updated - `date`" | Mail -s "$filename Updated" $1
	shift
done
exit 0
