You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			27 lines
		
	
	
		
			593 B
		
	
	
	
		
			Bash
		
	
			
		
		
	
	
			27 lines
		
	
	
		
			593 B
		
	
	
	
		
			Bash
		
	
#!/usr/bin/env bash
 | 
						|
 | 
						|
function tmp-if-needed {
 | 
						|
  tmpdir=/tmp/ssh-env-$(whoami)
 | 
						|
  [[ -d $tmpdir ]] || mkdir $tmpdir
 | 
						|
  chmod 700 "$tmpdir"
 | 
						|
  chown $(whoami) "$tmpdir"
 | 
						|
  echo $tmpdir
 | 
						|
}
 | 
						|
 | 
						|
ENVFILE="${XDG_RUNTIME_DIR:-$(tmp-if-needed)}/ssh-agent.env"
 | 
						|
 | 
						|
if [ -f $ENVFILE ] ; then
 | 
						|
    . $ENVFILE > /dev/null
 | 
						|
    if ! kill -0 $SSH_AGENT_PID > /dev/null 2>&1; then
 | 
						|
        eval $(ssh-agent | tee $ENVFILE)
 | 
						|
        chmod 600 "$ENVFILE"
 | 
						|
        chown $(whoami) "$ENVFILE"
 | 
						|
        ssh-add
 | 
						|
    fi
 | 
						|
else
 | 
						|
    eval $(ssh-agent | tee $ENVFILE)
 | 
						|
    chmod 600 "$ENVFILE"
 | 
						|
    chown $(whoami) "$ENVFILE"
 | 
						|
    ssh-add
 | 
						|
fi
 |