#!/bin/sh
##  Remove articles listed by expire -z.
##  Remove all files specified in the input file.

. /usr/lib/news/lib/innshellvars

MAIL="${MAILCMD} -s 'Problem removing expired files' ${NEWSMASTER}"

#RMPROC="xargs rm"
RMPROC="fastrm -e -u -s ${SPOOL}"

if [ -z "$1" ] ; then
    SAPI=`innconfval storageapi 2>/dev/null | tr ${AZ} ${az}`
    if [ X${SAPI} != X"true" -a X${SAPI} != X"yes" -a X${SAPI} != X"on" ]; then
	echo "Expire called with zero list of files on `hostname`" \
      | eval ${MAIL}
	exit 0
    fi
fi
if [ ! -f $1 ] ; then
    echo "Expire called with no files to expire on `hostname`" \
  | eval ${MAIL}
    exit 0
fi

eval "cd ${SPOOL} \
    && ${RMPROC} <$1 \
    && mv $1 ${MOST_LOGS}/expire.list"
if [ -f $1 ] ; then
    echo "Expire had problems removing articles on `hostname`" \
	| eval ${MAIL}
    exit 1
fi
