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