#!/bin/sh
#
# $Source: /afs/sipb/machine/charon3/src/RCS/internet-drafts.sh,v $
# $Id: internet-drafts.sh,v 1.9 2012/12/19 09:02:44 mitchb Exp $

# Note: this script should be run in a PAG of its own (it will clobber
# tokens).

KRBTKFILE=/tmp/tkt_root.$$ export KRBTKFILE
KRB5CCNAME=FILE:/tmp/krb5cc_root.$$ export KRB5CCNAME
KINIT=/usr/athena/bin/kinit
LINEBREAK="----------------------------------------------------"
MAILTO="jhawk@mit.edu raeburn@mit.edu"
PATH=/bin:/usr/bin:/usr/local/bin export PATH
STDOUT=/tmp/i-d.stdout.$$
STDERR=/tmp/i-d.stderr.$$

exec 5>&1 6>&2 1>$STDOUT 2>$STDERR

$KINIT -5 -l 60m -k -t FILE:/usr/local/etc/krb5.keytab daemon/`hostname`
/bin/athena/aklog -cell athena.mit.edu
/usr/athena/bin/kdestroy >/dev/null 2>&1		# HOKEY!

rsync -rlptzv --delete ftp.rfc-editor.org::internet-drafts/. /afs/.athena/reference/internet-drafts/.

/bin/athena/fs lq /afs/.athena/reference/internet-drafts
/bin/athena/unlog

exec 1>&5 2>&6
if [ -s $STDOUT -o -s $STDERR ]; then
  (echo "stdout:"; echo $LINEBREAK; cat $STDOUT; echo $LINEBREAK
   echo "stderr:"; echo $LINEBREAK; cat $STDERR
  ) | /usr/athena/bin/mhmail -s "Output from internet-drafts.sh" $MAILTO
fi

rm -f $STDOUT $STDERR

exit 0
