2015-07-19 22:59:14 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2015-07-22 03:47:01 +00:00
|
|
|
#Meant to be sourced, but can also just be called too
|
2015-07-19 22:59:14 +00:00
|
|
|
|
2015-07-22 03:47:01 +00:00
|
|
|
#set -eu
|
2015-07-19 22:59:14 +00:00
|
|
|
|
|
|
|
#If the env isn't set, try and load it
|
|
|
|
if [ "${GPG_AGENT_INFO-}" == "" ] || ! gpg-connect-agent /bye > /dev/null 2>&1; then
|
|
|
|
if [ -e "${HOME}/.gnupg/gpg-agent.env" ]; then
|
|
|
|
source ${HOME}/.gnupg/gpg-agent.env
|
|
|
|
export GPG_AGENT_INFO
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Test the agent, if fail, start a new one
|
|
|
|
if ! gpg-connect-agent /bye > /dev/null 2>&1; then
|
2015-07-20 05:40:24 +00:00
|
|
|
eval $(gpg-agent --daemon --default-cache-ttl=${GPG_DEFAULT_CACHE:-18000} --max-cache-ttl=${GPG_MAX_CACHE:-18000} --write-env-file=${HOME}/.gnupg/gpg-agent.env)
|
2015-07-19 22:59:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#Precache signing key
|
|
|
|
gpg2 -o /dev/null -s /dev/null
|