aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ak-gpg4
-rwxr-xr-xlib/_ak_gpg24
2 files changed, 28 insertions, 0 deletions
diff --git a/bin/ak-gpg b/bin/ak-gpg
index fa48a18..3ab0045 100755
--- a/bin/ak-gpg
+++ b/bin/ak-gpg
@@ -36,6 +36,9 @@
##
## -d, --delete-key Delete GPG keys from your keyring
##
+## -ds, --delete-secret-key <fingerprint>
+## Delete GPG keys from your keyring
+##
fullprogrampath="$(realpath $0)"
PROGRAM=$(basename $0)
descriptionString="GPG cli tool"
@@ -65,6 +68,7 @@ if [ ! -z $1 ]; then
--create-key | -c) shift; _ak_gpg_create_key $1; exit;;
--select-key | -s) _ak_gpg_select_key; exit;;
--delete-key | -d) _ak_gpg_delete_key; exit;;
+ --delete-secret-key | -ds) shift; _ak_gpg_delete_secret_key $1; exit;;
* ) _ak_usage;;
esac
else _ak_usage
diff --git a/lib/_ak_gpg b/lib/_ak_gpg
index a214965..e83b87d 100755
--- a/lib/_ak_gpg
+++ b/lib/_ak_gpg
@@ -2,6 +2,7 @@
source $AK_LIBDIR/_ak_log
source $AK_LIBDIR/_ak_ipfs
source $AK_LIBDIR/_ak_config
+source $AK_LIBDIR/_ak_settings
_ak_gpg(){
gpg2 --homedir $AK_GPGHOME $*
@@ -235,3 +236,26 @@ _ak_gpg_delete_key(){
fi
done
}
+
+_ak_gpg_delete_secret_key(){
+ if [ ! -z $1 ]
+ then
+ x="$1"
+ if [ -n "$x" ]
+ then
+ _ak_log_info "$x was selected"
+ _ak_gpg --delete-secret-keys $x
+ if [ $? -ne 0 ]
+ then
+ _ak_log_error "Some error occured while removing $x"
+ exit 1
+ else
+ _ak_log_info "Key $x was deleted"
+ fi
+ exit
+ else
+ _ak_log_warning "You didn't select a key"
+ exit 1
+ fi
+ fi
+}