aboutsummaryrefslogtreecommitdiffstats
path: root/unix/gpg-agent.sh
blob: 751c2ac311c1a3c0abbb70a9b2f7fceada0aa8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh

# gpg-agent.sh
# autorun the gpg-agent

envfile="${HOME}/.gnupg/gpg-agent.env"
if test -f "$envfile" && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
    eval "$(cat "$envfile")"
else
    eval "$(gpg-agent --daemon --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO  # the env file does not contain the export statement