From b165eece8b85b2532d53fed27fb6ca2573a79e70 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 23 Jul 2024 18:27:15 +0300 Subject: ak-gpg: new --delete-secret-key flag --- bin/ak-gpg | 4 ++++ lib/_ak_gpg | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) 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 +## 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 +} -- cgit v1.2.3