diff options
author | Jonas Smedegaard <dr@jones.dk> | 2015-08-16 11:24:55 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2015-08-16 11:24:55 +0200 |
commit | d4327cf7d6e690cdc9a5262583266d82050489a6 (patch) | |
tree | 9ddcc6150e61aba78707031df571d61653da307f /localgpgcleankeyring | |
parent | d64f93faa336fea2a523c185bcc05cf82b0db5d9 (diff) |
Set gpg if $GPG not set.
Diffstat (limited to 'localgpgcleankeyring')
-rwxr-xr-x | localgpgcleankeyring | 11 |
1 files 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 |