Skip to content

Instantly share code, notes, and snippets.

@neagix
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neagix/e7b6edd6756f20e290fe to your computer and use it in GitHub Desktop.
Save neagix/e7b6edd6756f20e290fe to your computer and use it in GitHub Desktop.
gpg-agent Xsession script to cleanup the Ubuntu mess
## http://neagix.blogspot.nl/2014/09/setup-gpg-smartcard-reader-in-ubuntu-14.html
##
##
## NOTE: this script is sourced via dash
##
: ${GNUPGHOME=$HOME/.gnupg}
## customize this entry if you have a binary diversion
GPGAGENT=/usr/bin/gpg-agent
PID_FILE="$GNUPGHOME/gpg-agent-info-$(hostname)"
# start gpg-agent only if use-agent is specified and not already correctly running & configured for current user
if grep -qs '^[[:space:]]*use-agent' "$GNUPGHOME/gpg.conf" "$GNUPGHOME/options" &&
test -x $GPGAGENT &&
{ test -z "$GPG_AGENT_INFO" || ! $GPGAGENT 2>/dev/null; }; then
# Invoking gpg-agent with no arguments exits successfully if the agent
# is already running as pointed by $GPG_AGENT_INFO
STARTUP="$GPGAGENT --daemon --sh --write-env-file=$PID_FILE $STARTUP"
fi
unset PID_FILE
unset GPGAGENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment