git-lfs/docker/preload_key.bsh

22 lines
647 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
#Meant to be sourced, but can also just be called too
#set -eu
#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
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)
fi
#Precache signing key
gpg2 -o /dev/null -s /dev/null