# this file is used by other scripts as  ". start-ssh-agent"
ssh_vers=1

if [ -f /usr/pkg/bin/ssh-agent$ssh_vers ]; then
	if ssh-add$ssh_vers -l >/dev/null 2>&1; then
		: using SSH_AUTH_SOCK variable
	else
		for i in /tmp/ssh-${USER=`whoami`}/*; do
			if SSH_AUTH_SOCK="$i" ssh-add$ssh_vers -l >/dev/null 2>&1; then
				: "using ssh socket $i"
				break
			else
				i=
			fi
		done

		case "$i" in
		'')	eval `ssh-agent$ssh_vers -s 2>/dev/null`;;
		*)	SSH_AUTH_SOCK="$i"
			export SSH_AUTH_SOCK;;
		esac
	fi
fi
