don’t open key if already opened

This commit is contained in:
alterNERDtive 2022-07-19 14:03:44 +02:00
parent 356d1cdb7a
commit 4451000fef
Signed by: alterNERDtive
GPG key ID: 547787A4FE6533F1

11
gpgtool
View file

@ -156,9 +156,14 @@ open () {
key=$(ls ${keypath}/${id}/*.key) key=$(ls ${keypath}/${id}/*.key)
[[ $? != 0 ]] && \ [[ $? != 0 ]] && \
echo "${id} does not seem to be a valid key folder, aborting …" && exit 1 echo "${id} does not seem to be a valid key folder, aborting …" && exit 1
gpg --homedir "${tempdir}/gpghome" --import-options keep-ownertrust \ if [[ -f "${tempdir}/gpghome/private-keys-v1.d/$(basename ${key})" ]]
--import "${keypath}/${id}/${id}.private.asc" then
[[ $? == 0 ]] && ln -sf ${key} ${tempdir}/gpghome/private-keys-v1.d/ 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 done
} }