#!/bin/sh
#
# oa
#
# A script for starting the local afs client of a macosx workstation.
# After startup, the current user will be logged in. Kerberos principal
# is defined in the first line of ~/.k5login .
#
# -- Frank Burkhardt <burk@cbs.mpg.de>  Sat, 13 Feb 2010 15:47:14 +0100

if ! df | grep -q /afs; then
	echo "I: Openafs is not running - trying to start it." >&2
	echo "I: You may have to enter your *local* password." >&2
        sudo /Library/StartupItems/OpenAFS/OpenAFS start
fi
echo "I: Kerberos login. You have to enter your *Kerberos* password now." >&2
if kinit `head -n 1 ~/.k5login`; then
	echo "I: converting kerberos ticket to FS token now..." >&2
	if aklog; then
		echo "I: all done." >&2
	else
		echo "E: Unable to make AFS token. You may want to try restarting your computer." >&2
	fi
else
	echo "E: That didn't work. Maybe your password was wrong." >&2
	echo "I: Try running 'oa' again." >&2
fi


