2018-04-22 04:26:36 +08:00
|
|
|
# Enable gpg-agent if it is not running-
|
|
|
|
# --use-standard-socket will work from version 2 upwards
|
|
|
|
|
2018-04-27 23:56:21 +08:00
|
|
|
AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
|
2018-04-22 04:26:36 +08:00
|
|
|
|
2018-04-27 23:56:21 +08:00
|
|
|
if [[ ! -S $AGENT_SOCK ]]; then
|
|
|
|
gpg-agent --daemon --use-standard-socket &>/dev/null
|
2017-11-08 00:04:38 +08:00
|
|
|
fi
|
2018-04-27 23:56:21 +08:00
|
|
|
export GPG_TTY=$TTY
|
2010-10-15 22:50:39 +08:00
|
|
|
|
2018-04-22 04:26:36 +08:00
|
|
|
# Set SSH to use gpg-agent if it's enabled
|
2018-04-27 23:56:21 +08:00
|
|
|
GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
|
|
|
|
if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then
|
|
|
|
export SSH_AUTH_SOCK="$AGENT_SOCK.ssh"
|
2017-11-08 00:04:38 +08:00
|
|
|
unset SSH_AGENT_PID
|
2013-02-21 09:46:20 +08:00
|
|
|
fi
|