Last active
August 29, 2015 14:14
-
-
Save neagix/e7b6edd6756f20e290fe to your computer and use it in GitHub Desktop.
gpg-agent Xsession script to cleanup the Ubuntu mess
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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