#!/bin/bash
# Global bashrc file for Debathena machines

export HOSTTYPE="`/bin/machtype`"
export ATHENA_SYS=`/bin/machtype -S`
export ATHENA_SYS_COMPAT=`/bin/machtype -C`
if [ -z "$ATHENA_SYS" ]; then
    export ATHENA_SYS=@sys
fi

renew () {
    principal=`klist -5 2>/dev/null | sed -n 's/^Default principal: // p'`
    KINIT_ARGS=""
    kinit -4 </dev/null &>/dev/null
    [ $? != 3 ] && KINIT_ARGS="-54"
    kinit $KINIT_ARGS "${principal:-$ATHENA_USER}" || return $?
    [ -e /afs/athena.mit.edu ] && {
	if [ "$DEBATHENA_HOME_TYPE" = afs ]; then
	    if [ -x /bin/fsid ]; then
		fsid -a
	    else
		aklog -p "$HOME"
	    fi
	fi
    } && aklog || {
	ret=$?
	echo >&2
	echo "Your AFS client does not seem to be working.  To troubleshoot this problem," >&2
	echo "visit http://debathena.mit.edu/troubleshooting#openafs-modules" >&2
	return $ret
    }
}

add_flags=
add () { eval "$( /bin/attach -Padd -b $add_flags "$@" )" ; }
