keep uucp out of expire's way [news.software.b,unix-pc.sources]

Elliot Dierksen elliot at alfred.UUCP
Tue Dec 19 10:20:41 AEST 1989


Archive-name: setxqts/dist
Original-posting-by: elliot at alfred.UUCP (Elliot Dierksen)
Original-subject: B news expire vs. incoming news patch
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)

[This is an experimental alt.sources re-posting from the newsgroup(s)
news.software.b,unix-pc.sources. Comments on this service to emv at math.lsa.umich.edu 
(Edward Vielmetti).]


This is a little utility I wrote to keep expire from butting heads with
incoming news. I wrote this program on an AT&T Unix-PC. This will not work
if you are not running some version of HoneyDanBer UUCP.  The basic premise
is the shell script which drives expire set the Maxuuxqts to 0, and waits
until all uuxqts have finished. It runs expire, and then resets Maxuuxqts.
This setup has been working just fine for me for a month or two now. It's
very simple so I can't  imagine what could go wrong with it!!  :-)

EBD

----------------CUT HERE---------------------------------------------
#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  setxqts.c
#	  expire.sh
#
sed 's/^X//' << 'SHAR_EOF' > setxqts.c &&
X#include <stdio.h>
X
Xmain(argc,argv,envp)
Xint argc;
Xchar **argv, **envp;
X{
Xint numxqts, euid;
XFILE *xqtfile;
X
X	if (argc < 2 || (numxqts = atoi(argv[1])) < 0 || numxqts > 9)
X	{
X		fprintf(stderr,"usage: %s [maximum uuxqts]\n",argv[0]);
X		exit(-1);
X	}
X
X	euid = geteuid();
X	if (euid == 0 || euid == 7)
X	{
X		setuid(0);
X		if ((xqtfile = fopen("/usr/lib/uucp/Maxuuxqts","r+")) != NULL)
X		{
X			putc('0' + numxqts,xqtfile);
X			fclose(xqtfile);
X		}
X		else
X			fprintf(stderr,"%s: could not open Maxuuxqts file\n",argv[0]);
X	}
X	else
X		fprintf(stderr,"you are not authorized to use %s\n",argv[0]);
X
X	exit(0);
X}
SHAR_EOF
chmod 0644 setxqts.c || echo "restore of setxqts.c fails"
sed 's/^X//' << 'SHAR_EOF' > expire.sh &&
X#	Script to runs news expire commands
X
X# news directory
XNEWS=/usr/local/lib/news
X# number of days worth of history to keep
XHISTDAYS=21
X# number of days before articles expire
XEXPDAYS=7
X# number of days before busy & noisy groups expire
XSHORTEXP=4
X# groups to expire quickly
XSHORTGROUPS="junk,news,gnu,comp.binaries.ibm.pc.d,rec.games,soc,talk,alt"
X# maximum number of uuxqts to allow after we finish expiring news
XMAXUUXQTS=1
X# number of seconds to wait between tests to see if uuxqt jobs are running
XPAUSETIME=120
X
X# decide if this is a backround job or not
Xtty -s
XISATTY=$?
X
X# if this is being run as a foreround job and EXPARGS are not set
Xif [ $ISATTY -eq 0 -a -z "$EXPARGS" ]
Xthen
X	EXPARGS="-v 2"	# show some debug output
Xfi
X
X# this section is to wait until all running uuxqt commands have finished
X$NEWS/setxqts 0
X
X# while a uuxqt is running
Xwhile [ `ps -e | grep uuxqt | wc -l` -gt 0 ]
Xdo
X	sleep $PAUSETIME	# pause for a while, and then check again
Xdone
X
X# this is an additional expire to control some very active groups
X$NEWS/expire $EXPARGS -e 1 -E $HISTDAYS -n $SHORTGROUPS
X
X# this is the main expire command that covers all groups
X$NEWS/expire $EXPARGS -e $EXPDAYS -E $HISTDAYS
X
X# this command cleans up the spool directories
Xcmd="$NEWS/spoolclean.sh"
Xif [ $ISATTY -eq 0 ]
Xthen
X	$cmd
Xelse
X	$cmd > /dev/null 2>&1
Xfi
X
X# turn the uuxqts back on now that we have finished our expire commands
X$NEWS/setxqts $MAXUUXQTS
SHAR_EOF
chmod 0775 expire.sh || echo "restore of expire.sh fails"
exit 0
-- 
Elliot Dierksen                 Home: {peora,ucf-cs,uunet}!tarpit!alfred!elliot
                                Work: {att,codas}!candi!ralph!ebd

"What's another word for Thesaurus??"  -- Steven Wright



More information about the Alt.sources mailing list