1 if [ ! -z "$SSH_CLIENT" ]; then
2 # Set display if we aren't already forwarding X11
3 if [ "$DISPLAY" = "" ]; then
4 export DISPLAY="$(echo $SSH_CLIENT | cut -s -d ' ' -f 1):0"
8 # Try to hook up with already running ssh-agent.
9 if [ $UID -gt 0 ]; then
10 RUNNING_AGENT="$(ps waux | grep -- ^$USER\ .\*ssh-agent\ -s | grep -v grep | awk '{ print $2 }' | head -n 1)"
11 if [ -z "$SSH_AGENT_PID" -o ! "$SSH_AGENT_PID" = "$RUNNING_AGENT" ]; then
12 export SSH_AGENT_PID="$RUNNING_AGENT"
13 if [ "$SSH_AGENT_PID" = "" ]; then
16 # Start ssh-agent up then.
17 eval $(/usr/bin/ssh-agent -s)
18 trap "kill $SSH_AGENT_PID" 0
21 export SSH_AUTH_SOCK="/$(lsof -p $SSH_AGENT_PID | grep 'agent.[0-9]*$' | cut -s -d / -f 2-)"