#!/bin/sh

set -e

# test for config files
test -f /etc/noffle/conf || exit 0
test -f /etc/noffle/conf.debian || exit 0

# read user-settable stuff
. /etc/noffle/conf.debian

# test whether perhaps noffle has been removed (but not purged)
test -x $NOFFLE || exit 0

: ${NOFFLE_EXPIRELOGS:=4}

cd /var/spool/noffle

savelog -c $NOFFLE_EXPIRELOGS -p /var/log/noffle-expire >/dev/null
exec > /var/log/noffle-expire 2>&1

/bin/su news -c "$NOFFLE --expire"
chgrp -R news /var/spool/noffle
umask 0
chmod -R g+w  /var/spool/noffle

exit 0
