2 # Copyright (C) 2013 g10 Code GmbH
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved. This file is
7 # distributed in the hope that it will be useful, but WITHOUT ANY
8 # WARRANTY, to the extent permitted by law; without even the implied
9 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 if [ -z "$(command -v gpg-connect-agent)" ]; then
12 echo "gpg-agent not installed and thus not started" >&2
19 token=$(echo "gpgme-$(pwd)" | tr ' ' '_')
21 if [ "$1" = "--stop" ]; then
22 if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
24 echo "gpg-agent not running" >&2
27 echo "stopping gpg-agent " >&2
28 gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1
32 if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
34 echo "gpg-agent already running" >&2
38 echo "starting gpg-agent " >&2
39 gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1
40 if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
42 echo "error starting gpg-agent" >&2