| 1 | 1 | 
                    new file mode 100644  | 
            
| ... | ... | 
                    @@ -0,0 +1,26 @@  | 
            
| 0 | 
                    +# Based on ssh-agent code  | 
            |
| 1 | 
                    +  | 
            |
| 2 | 
                    +local GPG_ENV=$HOME/.gnupg/gpg-agent.env  | 
            |
| 3 | 
                    +  | 
            |
| 4 | 
                    +function start_agent {
                 | 
            |
| 5 | 
                    +  /usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file ${GPG_ENV} > /dev/null
                 | 
            |
| 6 | 
                    +  chmod 600 ${GPG_ENV}
                 | 
            |
| 7 | 
                    +  . ${GPG_ENV} > /dev/null
                 | 
            |
| 8 | 
                    +}  | 
            |
| 9 | 
                    +  | 
            |
| 10 | 
                    +# Source GPG agent settings, if applicable  | 
            |
| 11 | 
                    +if [ -f "${GPG_ENV}" ]; then
                 | 
            |
| 12 | 
                    +  . ${GPG_ENV} > /dev/null
                 | 
            |
| 13 | 
                    +  ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
                 | 
            |
| 14 | 
                    + start_agent;  | 
            |
| 15 | 
                    + }  | 
            |
| 16 | 
                    +else  | 
            |
| 17 | 
                    + start_agent;  | 
            |
| 18 | 
                    +fi  | 
            |
| 19 | 
                    +  | 
            |
| 20 | 
                    +export GPG_AGENT_INFO  | 
            |
| 21 | 
                    +export SSH_AUTH_SOCK  | 
            |
| 22 | 
                    +export SSH_AGENT_PID  | 
            |
| 23 | 
                    +  | 
            |
| 24 | 
                    +GPG_TTY=$(tty)  | 
            |
| 25 | 
                    +export GPG_TTY  |