Move ssh_agent_is_started to its own function. Close #1.
This commit is contained in:
parent
5aa699d465
commit
ceeb86bbcc
|
@ -0,0 +1,12 @@
|
|||
function __ssh_agent_is_started -d "check if ssh agent is already started"
|
||||
if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
|
||||
source $SSH_ENV > /dev/null
|
||||
end
|
||||
|
||||
if test -z "$SSH_AGENT_PID"
|
||||
return 1
|
||||
end
|
||||
|
||||
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
|
||||
return $status
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
function __ssh_agent_start
|
||||
function __ssh_agent_start -d "start a new ssh agent"
|
||||
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
|
||||
chmod 600 $SSH_ENV
|
||||
source $SSH_ENV > /dev/null
|
||||
|
|
|
@ -2,12 +2,6 @@ if test -z "$SSH_ENV"
|
|||
setenv SSH_ENV $HOME/.ssh/environment
|
||||
end
|
||||
|
||||
if test -z "$SSH_AGENT_PID"
|
||||
if test -f $SSH_ENV
|
||||
source $SSH_ENV > /dev/null
|
||||
end
|
||||
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
|
||||
if test $status -ne 0
|
||||
if not __ssh_agent_is_started
|
||||
__ssh_agent_start
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue