summaryrefslogtreecommitdiff
path: root/localgpgexpandkeyring
blob: fc8a79fd4f10805d28e9792538023784c29bfe01 (plain)
  1. #!/bin/sh
  2. # fetch missing keys signed by local keys
  3. set -e
  4. # set e.g. GPG=gpg2 in environment to override binary to use
  5. GPG=${GPG:-gpg}
  6. # my keys are those with a corresponding secret key
  7. mykeys=$($GPG --batch --list-secret-keys --with-colons | grep '^sec' | cut -d: -f5)
  8. if [ -z "$mykeys" ]; then
  9. # exit if no key string
  10. echo "Can't get user's key ID"
  11. exit 1
  12. fi
  13. # all of the people without key locally who have signed my key
  14. mysigners=$(LC_ALL=C $GPG --batch --list-sigs --with-colons $mykeys | grep '^sig.*User ID not found' | cut -d: -f5 | sort -u)
  15. if [ -z "$mysigners" ]; then
  16. echo "# Nothing to fetch!"
  17. else
  18. $GPG --batch --keyserver-options no-auto-key-retrieve "$@" --recv-keys $mysigners
  19. fi