Skip to content

Commit

Permalink
Don't allow agent reloads, if it's running already.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshPiper committed Jan 2, 2020
1 parent 5c787b0 commit 961df2f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions agent-start
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ mkdir -p "$STORE_PATH"

# Start the SSH agent if it isn't already.
if [ -z "$SSH_AGENT_PID" ]; then
eval "$(ssh-agent)" > /dev/null
echo "$SSH_AGENT_PID" > "$STORE_PATH"/id
echo "$SSH_AUTH_SOCK" > "$STORE_PATH"/sock
if [ -f "$STORE_PATH/id" ]; then
# Our auth agent is already running.
# Reload the vars, and export them.
SSH_AGENT_PID=$(cat "$STORE_PATH/id")
export SSH_AGENT_PID

SSH_AUTH_SOCK=$(cat "$STORE_PATH/sock")
export SSH_AUTH_SOCK
else
eval "$(ssh-agent)" > /dev/null
echo "$SSH_AGENT_PID" > "$STORE_PATH"/id
echo "$SSH_AUTH_SOCK" > "$STORE_PATH"/sock
fi
fi

0 comments on commit 961df2f

Please sign in to comment.