Need help with updating active file

Dennis P. Bednar dennis at virtech.UUCP
Thu Aug 17 17:26:09 AEST 1989


In article <26 at dynasys.UUCP>, root at dynasys.UUCP (Super user) writes:
> I'm new to using news and I need some help.  I am running Xenix and received
> their version of netnews.  The active file was old (still had mod in it).
> I need to update it completely but I don't know how I should do this.  Can
> anyone help me out?

I recently installed netnews here, and ran into the same problem
you speak of.  What I did was to uucp the latest newsgroups file
from a neighboring UUCP site, then I ran a shell script, addgroups.sh,
that read the latest newsgroups file, extracted only the newsgroup
name, and then searched the active file to see if the newsgroup
was already there.  If not, it runs "inews -C newsgroup </dev/null"
to create the new group.

After I did that, I ran another shell script diffac.sh (stands for
"diff active file vs newsgroups" that compares the newsgroups listed
in active to those listed in newsgroups.

Each day you should look in your /usr/spool/news/junk directory for
new articles that could not be put into the proper directory.  Simply
'grep Newsgroup:" to find such names.  Those groups you will also
need to be added to your active and newsgroups file.

There is a checkgroups script that is distributed with b-news too,
but I didn't bother to run it (I tried, and it was deleting lines
from my newsgroups files, and I didn't bother to read the F manual,
which is why I wrote addgroups.sh and diffac.sh).

Below are the two shell scripts.  Note that the script is written to
assume that the exit code of grep determines if a string has been
found.  Hindsight says I should have made it more portable so that
it works on systems whose exit code cannot be trusted.  Oh well!

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	addgroup.sh
#	diffac.sh
# This archive created: Thu Aug 17 07:23:16 1989
cat << \SHAR_EOF > addgroup.sh
# /bin/sh
# addgroup.sh
# read the current newsgroups file and generate newsgroups if the name in
# column one is a new newsgroup, that is, the name is not already
# in the active file

# This procedure was used to generate the newsgroups based on latest
# information from rlgvax on Aug 4 89.  dennis

tmpfile=/tmp/news$$
trap "rm -f $tmpfile" 0 1 2 15

# copy to temp file  that we can edit
# keep only column 1 which are the newsgroup names
cp newsgroups $tmpfile
ed $tmpfile <<EOF 2>/dev/null >/dev/null
1,\$s/ .*//
1,\$s/	.*//
w
q
EOF

cat $tmpfile |
while read group
do
	grep $group active >/dev/null
	if [ $? -eq 0 ]
	then
		:	# found it
	else
		echo Adding newsgroup $group
		/usr/lib/news/inews -C $group </dev/null # not found
	fi
done
SHAR_EOF
cat << \SHAR_EOF > diffac.sh
# diff the active vs the newsgroup file
# this is useful for making sure that both files are in sync with one another

# temporary files, removed upon exit
tmpfilex=/tmp/$$xx	# /tmp/$$xx
tmpfiley=/tmp/$$yy	# /tmp/$$yy
act_not_news=/tmp/$$act_not_news	# in active file but not in newsgroups
news_not_act=/tmp/$$news_not_act	# in newsgroups file but not in active
trap "rm -f $tmpfilex $tmpfiley $act_not_news $news_not_act" 0 1 2 15

# copy to temp file  that we can edit
# keep only column 1 which are the newsgroup names
sort newsgroups | sed -e 's/ .*//' -e 's/	.*//' | uniq >$tmpfiley
#ed $tmpfiley <<EOF 2>/dev/null >/dev/null
#1,\$s/ .*//
#1,\$s/	.*//
#w
#q
#EOF


sort active  | sed -e 's/ .*//' | uniq >$tmpfilex


comm -23 $tmpfilex $tmpfiley >$act_not_news

comm -13 $tmpfilex $tmpfiley >$news_not_act

if [ -s $act_not_news ]
then
	echo "The following are in active file but not in newsgroups:"
	cat $act_not_news
fi

if [ -s $news_not_act ]
then
	echo "The following are in newsgroups file but not in active file:"
	cat $news_not_act
fi
SHAR_EOF
#	End of shell archive
exit 0



More information about the Comp.unix.xenix mailing list