From d4327cf7d6e690cdc9a5262583266d82050489a6 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 16 Aug 2015 11:24:55 +0200 Subject: Set gpg if $GPG not set. --- localgpgcleankeyring | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/localgpgcleankeyring b/localgpgcleankeyring index b7fb205..96ee875 100755 --- a/localgpgcleankeyring +++ b/localgpgcleankeyring @@ -5,8 +5,11 @@ set -e +# set e.g. GPG=gpg2 in environment to override binary to use +GPG=${GPG:-gpg} + # my keys are those with a corresponding secret key -mykeys=$(gpg --batch --list-secret-keys --with-colons | grep '^sec' | cut -d: -f5) +mykeys=$($GPG --batch --list-secret-keys --with-colons | grep '^sec' | cut -d: -f5) if [ -z "$mykeys" ]; then # exit if no key string echo "Can't get user's key ID" @@ -14,7 +17,7 @@ if [ -z "$mykeys" ]; then fi # all of the people who have signed my key -mysigners=$(gpg --batch --list-sigs --with-colons $mykeys | grep '^sig' | cut -d: -f5 | sort -u) +mysigners=$($GPG --batch --list-sigs --with-colons $mykeys | grep '^sig' | cut -d: -f5 | sort -u) # keep all of the signers, plus my key (if I haven't self-signed) keepers=$(echo $mykeys $mysigners | tr ' ' '\012' | sort -u) @@ -23,10 +26,10 @@ keepers=$(echo $mykeys $mysigners | tr ' ' '\012' | sort -u) keepers_egrep=$(echo $keepers | sed 's/^/^(/; s/$/)/; s/ /|/g;') # everyone who isn't on the keepers list is deleted -deleters=$(gpg --batch --list-keys --with-colons | grep '^pub' | cut -d: -f5 | egrep -v ${keepers_egrep}) +deleters=$($GPG --batch --list-keys --with-colons | grep '^pub' | cut -d: -f5 | egrep -v ${keepers_egrep}) if [ -z "$deleters" ]; then echo "# Nothing to delete!" else - gpg --batch "$@" --delete-keys $deleters + $GPG --batch "$@" --delete-keys $deleters fi -- cgit v1.2.3