You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
642 B
32 lines
642 B
14 years ago
|
# Based on ssh-agent code.
|
||
14 years ago
|
|
||
14 years ago
|
local GPG_ENV="$HOME/.gnupg/gpg-agent.env"
|
||
14 years ago
|
|
||
14 years ago
|
if (( ! $+commands[gpg-agent] )); then
|
||
|
return
|
||
|
fi
|
||
|
|
||
|
function _gpg-agent-start() {
|
||
|
/usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file "${GPG_ENV}" > /dev/null
|
||
|
chmod 600 "${GPG_ENV}"
|
||
|
source "${GPG_ENV}" > /dev/null
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
# Source GPG agent settings, if applicable.
|
||
|
if [[ -f "${GPG_ENV}" ]]; then
|
||
|
source "${GPG_ENV}" > /dev/null
|
||
|
ps -ef | grep "${SSH_AGENT_PID}" | grep gpg-agent > /dev/null || {
|
||
|
_gpg-agent-start;
|
||
14 years ago
|
}
|
||
|
else
|
||
14 years ago
|
_gpg-agent-start;
|
||
14 years ago
|
fi
|
||
|
|
||
|
export GPG_AGENT_INFO
|
||
|
export SSH_AUTH_SOCK
|
||
|
export SSH_AGENT_PID
|
||
|
|
||
|
GPG_TTY=$(tty)
|
||
|
export GPG_TTY
|
||
14 years ago
|
|