aboutsummaryrefslogtreecommitdiffstats
path: root/unix/gpg-agent.sh
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-01-19 19:19:24 +0800
committerAaron LI <aaronly.me@outlook.com>2017-01-19 19:19:24 +0800
commita1815079ad4ff8076eb33bbd3f6b50e5c1a66763 (patch)
tree6bb032fb65e39e307288163f3adc64c0b2ffbcf6 /unix/gpg-agent.sh
parent582e8827ad9fe6c7843d7f4ad86337b68270996f (diff)
downloadatoolbox-a1815079ad4ff8076eb33bbd3f6b50e5c1a66763.tar.bz2
Add various scripts
Diffstat (limited to 'unix/gpg-agent.sh')
-rwxr-xr-xunix/gpg-agent.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/unix/gpg-agent.sh b/unix/gpg-agent.sh
new file mode 100755
index 0000000..751c2ac
--- /dev/null
+++ b/unix/gpg-agent.sh
@@ -0,0 +1,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
+