summaryrefslogtreecommitdiff
path: root/receive-key
blob: b20ba3d6fbf76515476424bb96d3b0964cde9871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

if [ ! -d "${0%/*}/gnupg" ]; then
  mkdir "${0%/*}/gnupg"
  chmod 700 "${0%/*}/gnupg"
fi

keyIDs="$(
  gpg --homedir "${0%/*}/gnupg" --batch --with-colons --search-keys "<$1>" 2> /dev/null | \
    grep '^pub:' | \
    cut -d: -f2
)"

if [ -n "${keyIDs}" ]; then
  gpg --homedir "${0%/*}/gnupg" --recv-keys ${keyIDs}
fi