]> git.pld-linux.org Git - packages/gnupg2.git/blob - gnupg-agent.sh
- use readlink from coreutils instead of our own resolvesymlink; handle "gpg-agent...
[packages/gnupg2.git] / gnupg-agent.sh
1 #!/bin/sh
2
3 if [ -r "${HOME}/.gnupg/gpg.conf" ]; then
4         CFG="${HOME}/.gnupg/gpg.conf"
5 else
6         CFG="${HOME}/.gnupg/options"
7 fi
8
9 seahorse=no
10 if [ -r "${HOME}/.gnupg/gpg-agent.conf" ]; then
11         grep -qE "^[[:blank:]]*pinentry-program[[:blank:]]*.*seahorse-agent" "${HOME}/.gnupg/gpg-agent.conf" && seahorse=yes
12 fi
13
14 if grep -q "^[[:blank:]]*use-agent" ${CFG} 2>/dev/null; then
15         if [ -f "${HOME}/.gnupg/GPG_AGENT_INFO" ] && \
16                         pid="$(cut -d: -f2 $HOME/.gnupg/GPG_AGENT_INFO)" && \
17                         agent="$(readlink -n "/proc/$pid/exe")" && agent=${agent%% *} && \
18                         [ "$agent" = "/usr/bin/gpg-agent" -o "$agent" = "/usr/bin/seahorse-agent" ]; then
19                 export GPG_AGENT_INFO="$(cat ${HOME}/.gnupg/GPG_AGENT_INFO)"
20         else
21                 if [ "$seahorse" = "no" ]; then
22                         eval "$(gpg-agent --daemon)"
23                 else
24                         eval "$(seahorse-agent --variables)"
25                 fi
26                 echo $GPG_AGENT_INFO > ~/.gnupg/GPG_AGENT_INFO
27                 export GPG_AGENT_INFO
28         fi
29 fi
30 unset agent
31 unset seahorse
32 unset CFG
33 unset pid
This page took 0.037606 seconds and 3 git commands to generate.