2005-12-01 19:53:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2006-06-22 16:02:58 +00:00
|
|
|
GPG_AGENT=/usr/bin/gpg-agent
|
2005-12-01 19:53:39 +00:00
|
|
|
## Run gpg-agent only if not already running, and available
|
|
|
|
if [ -z "${GPG_AGENT_INFO}" -a -x ${GPG_AGENT} ] ; then
|
2006-06-22 16:38:21 +00:00
|
|
|
|
|
|
|
# check validity of GPG_SOCKET (in case of session crash)
|
2005-12-01 19:53:39 +00:00
|
|
|
if [ -f ${HOME}/.gpg-agent-info ]; then
|
2006-06-22 16:38:21 +00:00
|
|
|
GPG_SOCKET=$(cat .gpg-agent-info |cut -f1 -d:)
|
|
|
|
if ! test -S ${GPG_SOCKET} -o ! test -O ${GPG_SOCKET} ; then
|
|
|
|
rm -f ${HOME}/.gpg-agent-info 2>&1 >/dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f ${HOME}/.gpg-agent-info ]; then
|
|
|
|
export GPG_AGENT_INFO=$(cat ${HOME}/.gpg-agent-info)
|
2005-12-01 19:53:39 +00:00
|
|
|
export GPG_TTY=$(tty)
|
|
|
|
else
|
|
|
|
eval "$(${GPG_AGENT} -s --daemon ${GPG_OPTIONS})"
|
2006-06-22 16:38:21 +00:00
|
|
|
echo ${GPG_AGENT_INFO} > ${HOME}/.gpg-agent-info
|
2005-12-01 19:53:39 +00:00
|
|
|
fi
|
2006-06-22 16:38:21 +00:00
|
|
|
|
2005-12-01 19:53:39 +00:00
|
|
|
fi
|