: #	@(#)ppremind	1.1	remind SA to rm Ouser files
# ppremind:
#	Called as last act of ppurge.  Schedules via 'at' a reminder for
#	the SA to pflush out purgatory of given Ouser's files.  As part
#	of the reminder ppremind provides a ppshow report of originals
#	still in place, since these would necessitate another run of
#	ppurge before final archiving and pflushing.
# Author:  Larry Bamford, AO, OAT, STD, SEB, ETC, 8/13/90

DEF_REMDELAY=15		# default reminder delay, in days
SA=${LOGNAME:-admin}	# notify whoever started this, else admin
PATH=/bin:/etc:/usr/bin:/adm export PATH	# for security
CMD=`basename $0`
USAGE="
Usage:  $CMD [-d numdays] Ouser

Schedule a reminder for the invoker (or admin if LOGNAME is not set)
to pflush the purgatory directories of Ouser's files.  As a courtesy
$CMD also has a ppshow report sent to the SA of all Ouser's files not
in purgatory.  If any show up, another run of ppurge will need to be
made before final archiving and pflushing.

This script is normally called automatically by ppurge itself as its
last act.  The reminder is scheduled for REMDAYS days from today, where
REMDAYS defaults to $DEF_REMDELAY, and may be set either by the -d
option or in the environment, and must be greater than 0.
"

set -- `getopt d:h\? $*`
if test $? != 0
then
	echo "$USAGE"
	exit 2
fi
for i in $*
do case $i in
	-d)	REMDAYS=$2; shift 2;;
	-[h\?])	echo "$USAGE"; exit 0;;
	--)	shift; break;;
	esac
done
OUSER=${1:?"no Ouser given
$USAGE"}
REMDAYS=${REMDAYS:-$DEF_REMDELAY}

# Mail reminder along with with a final report on Ouser's files.
JOBTEXT="
#nohup ppshow -o $OUSER 2>&1 | mailx -s \"ppshow report\" $SA 
#sleep 10	# hack to prevent mailbox multiplexing
nohup ppshow -o $OUSER 
echo \"Time to pflush $OUSER's files.
Please see accompanying ppshow originals report.\" | \
mailx -s \"ppremind\" $SA
"
echo "$JOBTEXT" |
at 3 am today + $REMDAYS days	# produces routine output on stderr
