From 4451000fefed2147c29cad222acbdf7528b22445 Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Tue, 19 Jul 2022 14:03:44 +0200 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20`open`=20key=20if=20already=20o?= =?UTF-8?q?pened?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gpgtool | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gpgtool b/gpgtool index 62a3948..b95a3da 100755 --- a/gpgtool +++ b/gpgtool @@ -156,9 +156,14 @@ open () { key=$(ls ${keypath}/${id}/*.key) [[ $? != 0 ]] && \ echo "${id} does not seem to be a valid key folder, aborting …" && exit 1 - gpg --homedir "${tempdir}/gpghome" --import-options keep-ownertrust \ - --import "${keypath}/${id}/${id}.private.asc" - [[ $? == 0 ]] && ln -sf ${key} ${tempdir}/gpghome/private-keys-v1.d/ + if [[ -f "${tempdir}/gpghome/private-keys-v1.d/$(basename ${key})" ]] + then + echo "Key ${id} already opened." + else + gpg --homedir "${tempdir}/gpghome" --import-options keep-ownertrust \ + --import "${keypath}/${id}/${id}.private.asc" + [[ $? == 0 ]] && ln -sf ${key} ${tempdir}/gpghome/private-keys-v1.d/ + fi done }