#! /bin/sh
# $Header: /global/src/etc/cron/RCS/cl-check-tgt-fresh,v 1.12 2018/04/30 20:34:04 pb22 Exp $
# Ensure that /etc/krb5cc_<n> exists - if not ln to <n>_kt0
MAILTO=cl-check-tgt-fresh+fc-root-mail@cl.cam.ac.uk
# This is called from cron.hourly, i.e. every 60 mins.
# Look for TGTs over 1 cycle old hours old -- 1 hour + 10 mins triggers email
# HOWEVER 'krenew' refreshes (i.e. creates new cache files) even if it gains
# nothing so also look for TGT server generated files which cannot refresh
# (in case the TGT server isn't generating new TGTs as it should)
last=true
for p in /tmp/krb5cc*_kt? /tmp/krb5cc*_kt?_?? /tmp/krb5cc*_kt?-??-??-??; do case "$p" in *"?"*) : SKIP;; *) find $p -mmin +70 -ls | grep . && last=false;; esac; done
cl-krenew --status --refresh 2>&1 | grep _kt | grep -v 'refresh for' | grep -v 'is a symbolic link to' | grep -v 'Ticket cache: FILE' | grep -v '_kt.-b ' && last=false
$last
