[news.software.b] variable expire

paul@frcs.UUCP (Paul Nash) (12/11/90)

Now that Christmas is almost upon up, and lots of people are going on 
holiday, leaving their machines unattended and not doing the news, I
thought that I would post my `variable' expire script.  This expires
news down to a preset level of disk-fullness.  If the disk is less
that [whatever] full, nothing happens.  If more, news is expired
with more and more severity until there is enough free disk.

This is very inefficient, and does lots and lots of recursive 
expires until the disk is free enough.  However, this is probably
not much of a problem on an unused machine (everyone is on holiday,
right?) at 2am or thereabouts.

I realise that this is not the world's best code.  In fact, it is
among the world's _worst_.  Please feel free to modify it in any
way whatsoever, or even nuke it.  Flames about code quality will
be ignored ...

	--------	cut here	--------
	
#!/bin/sh
#
#	expire all the news stuff
#
#	This is a clever version that recursively expires until the /u
#	partition is less than 85% full.  I use it when I go away (if
#	it actually works, that is)
#

days=14		# destroy stuff older than this anyway
fullness=85	# stop expiring

# you might need to change this, to check a different partition (my
# news is spooled in /u/spool/news), and adapt it for your version 
# of `df'.  This must return a number, which is checked against.

diskfull() {
	df -v | awk '/^\/u/ { print $6 }' | sed -e 's/%//'
}

echo "about to expire the news at \c"
date
df -v

if [ `diskfull` -gt $fullness ]
then

#  modify this for the stuff you don't want

	echo "expiring base junk ..."	
	/usr/local/lib/news/expire -n comp.dcom.telecom,comp.os.vms -e 4 -E 21
	while [ `diskfull` -gt $fullness ]
	do
	
# this is where to nuke stuff you sort-of might read (-ish)
	
		echo "expiring extended junk at $days days .."
		/usr/local/lib/news/expire -n comp.dcom,sci -e $days -E 21
		if [ `diskfull` -gt $fullness ]
		then
		
# this is where the rest gets nuked (sob)
		
			echo "expiring The Good Stuff (TM) ..."
			/usr/local/lib/news/expire -n all -e $days -E 21 
		fi
		days=`expr $days - 1`
	done
fi

# and tell nn about it, so it can expire its databane aswell.

/usr/local/bin/nnadmin EY

 ---=---=---=---=---=---=---=---=---=---=---=---=---=---=---=---=---=---
Paul Nash			    Flagship Wide Area Networks (Pty) Ltd
paul@frcs.UUCP				...!uunet!ddsw1!proxima!frcs!paul