Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 8/1/84; site pesnta.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!petsd!pesnta!earlw
From: earlw@pesnta.UUCP (Earl Wallace)
Newsgroups: net.sources
Subject: synchist: Synchronizing the Netnews history/spool files
Message-ID: <2410@pesnta.UUCP>
Date: Fri, 10-Aug-84 01:51:10 EDT
Article-I.D.: pesnta.2410
Posted: Fri Aug 10 01:51:10 1984
Date-Received: Sat, 11-Aug-84 00:12:50 EDT
Distribution: net
Organization: Perkin-Elmer, Santa Clara, Calif.
Lines: 65



Here is a little script that may solve some your netnews spool directory
space problems.  I found that my expire program wasn't expiring all my 
news articles (imagine that?) and I didn't have the time to work on expire
and correct the bugs so I created a simple sh script to at least remove 
articles in the netnews spool directory that netnews no longer knows about
(those articles not in the history database files).  I got back some disk
space that made it quite worth the effort.  Don't run this buzzard unless
your news system is quiescent or you will run the risk of losing some
articles.  With the 2.10.2 expire program on its way, this script may not
be needed (save it for a rainy day... he-he-he...).


--------------- cut here -------------------
: ' synchist [pesnta!earlw]
    This sh script will delete files in the netnews spool directory that
    are missing from the history database file.
  '
LIB=/usr/lib/news	: ' netnews library '
SPL=/netnews		: ' netnews spool directory '
USR=usenet		: ' netnews admin user '
TMP=/tmp		: ' some place to put the temp files '
RM="rm -f"		: ' RM="echo" for chickens, RM="rm -f" for tough guys '

: ' history file articles are separated by newlines and sorted '
awk ' \
	BEGIN 	{ FS = "\t" } \
		{ if($3) printf "%s ", $3 } \
	END	{ printf "\n" } \
    ' ${LIB}/history | tr -s ' ' '\012' | sed "s/\./\//g" | \
sort -u > ${TMP}/history.sync

: ' find and sort all news articles found in the news spool directory '
(cd ${SPL}; \
find . -type f -print | sed "s/^\.\///" | sort -u > ${TMP}/netnews.sync)

: ' find articles in the news spool directory that are not in the history file '
comm -23 ${TMP}/netnews.sync ${TMP}/history.sync | \
sed s"/.*/${RM} \/netnews\/&/" > ${TMP}/delete.sync

: ' files found in the news spool directory but not in the history database
    are elected to face the remove command!  let the usenet person know
    whats going on (at least a little...)
  '
NUMBER=`wc -l ${TMP}/delete.sync | awk '{print $1}'`
if test ${NUMBER} != 0
then
(cd /netnews; /bin/sh ${TMP}/delete.sync)
mail ${USR} <