summaryrefslogtreecommitdiff
path: root/localgpgexpandkeyring
blob: 0e3e02728dacce5165e2d1760c8ceb807acf2a8b (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 --no-auto-check-trustdb --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 --no-auto-check-trustdb --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 --no-auto-check-trustdb --keyserver-options no-auto-key-retrieve "$@" --recv-keys $mysigners
  19. $GPG --batch --check-trustdb
  20. fi