jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

gnupg-mass-recv (1117B)


      1 #!/usr/bin/env zsh
      2 
      3 # uncomment to really download keys and modify the pub keyring
      4 # DRYRUN=1
      5 
      6 zmodload zsh/pcre
      7 
      8 command -v jaro > /dev/null 2>/dev/null
      9 [[ $? = 0 ]] || {
     10    print "Error: jaro not found in path. Install Jaro Mail."
     11    return 1
     12 }
     13 
     14 print "Import all keys found in public keyring signatures"
     15 
     16 if [[ -r gnupg-mass-recv.cache ]]; then
     17     print "gathering signatures from cache file..."
     18     _addrs=`cat gnupg-mass-recv.cache`
     19 else
     20     print "gathering all signatures in public keyring..."
     21     _addrs=`gpg --batch --with-colons --list-sigs | awk -F: '{print $5 " " $10}'| tee gnupg-mass-recv.cache`
     22     
     23 fi
     24 print "parsing the signatures for unkown IDs..."
     25 typeset -A received
     26 received=()
     27 for i in ${(f)_addrs}; do
     28     [[ "$i" =~ "User ID not found" ]] && {
     29         nid=${i[(w)1]}
     30         [[ "$received[$nid]" = 1 ]] && {
     31             print "$nid - duplicate"
     32             continue
     33         }
     34         received+=($nid 1)
     35         print "$nid - receiving"
     36         [[ $DRYRUN = 1 ]] || {
     37             gpg --recv-key ${nid}
     38         }
     39         continue
     40     }
     41     print $i
     42 done
     43 print "Received ${#received} new keys"
     44