#! /bin/sh
# expireiflow minmegabytes [ expireoptions ]
# run doexpire -r if things are getting tight
# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/etc/news/bin/config}

case "$#" in
0)	echo "Usage: $0 minmegabytes [ expireoptions ]" >&2
	exit 2
	;;
esac

minimum=$1
shift

PATH=$NEWSCTL/bin:$NEWSBIN/expire:$NEWSBIN:$NEWSPATH ; export PATH
umask $NEWSUMASK

lock="$NEWSCTL/LOCKexpire"

if test " `spacefor 1024000 articles`" -lt $minimum -a ! -f $lock
then
	echo "space getting low in $NEWSARTS; running doexpire -r" |
					report "space low in $NEWSARTS"
	exec doexpire -r $*
fi
