commit 6cb16f170a2e6afd2295295dcf371ab453f05a88
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2015-03-10T05:59:33Z |
| subject | gpg agent |
commit 6cb16f170a2e6afd2295295dcf371ab453f05a88
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2015-03-10T05:59:33Z
gpg agent
---
bash/bashrc/rbashrc | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc
index fa3a4a7..df02650 100644
--- a/bash/bashrc/rbashrc
+++ b/bash/bashrc/rbashrc
@@ -61,6 +61,25 @@ if ! shopt -oq posix; then
fi
fi
+if [ -x "/usr/bin/gpg-agent" ]; then
+ GPG_ENV="$HOME/.gnupg/environment"
+
+ function __start_agent {
+ gpg-agent --daemon > "${GPG_ENV}"
+ chmod 600 "${GPG_ENV}"
+ . "${GPG_ENV}" > /dev/null
+ }
+
+ if [ -f "${GPG_ENV}" ]; then
+ . "${GPG_ENV}" > /dev/null
+
+ gpg-agent > /dev/null 2>&1
+ [ "$?" -ne 0 ] && { __start_agent; }
+ else
+ __start_agent;
+ fi
+fi
+
BASHL_UUID="<UUID>"
export BASH_SDIR=/tmp/$BASHL_UUID
[ ! -d "$BASH_SDIR" ] && mkdir "$BASH_SDIR"