4
TOP_DIR=$(cd "$(dirname "${0}")"/.. && pwd)
5
GPG_DIR=${GPG_DIR:-${TOP_DIR}/gnupg}
6
PUBKEY=${PUBKEY:-${TOP_DIR}/examples/keys/example.pub}
7
SECKEY=${SECKEY:-${TOP_DIR}/examples/keys/example.sec}
9
if [ "$1" = "-h" -o "$1" = "--help" ]; then
12
create gnupghome dir $GPG_DIR.
13
Populate with public keys.
17
if [ -f "$GPG_DIR"/README ]; then
21
export GNUPGHOME="$GPG_DIR"
22
if [ ! -d "$GPG_DIR" ]; then
23
( umask 077 ; mkdir -p "$GPG_DIR" )
31
echo "creating GNUPGHOME dir in $GPG_DIR."
32
echo " pubkey '$PUBKEY'"
33
echo " secret '$SECKEY'"
37
if [ ! -f "$PUBKEY" -o ! -f "$SECKEY" ]; then
38
mkdir -p "$(dirname "$PUBKEY")"
39
out=$("${TOP_DIR}"/tools/gen-example-key "$PUBKEY" "$SECKEY") ||
40
{ echo "Failed to generate keys: $out"; exit 2; }
41
echo "created pubkey $pubkey and secret key $seckey" 1>&2
44
out=$(gpg --import "$SECKEY" 2>&1) ||
45
{ echo "Failed to import seckey: $out"; exit 2; }
46
echo "imported secret key $SECKEY" 1>&2
49
out=$("${TOP_DIR}"/tools/gpg-trust-pubkey "$k") ||
50
{ echo "Failed to import pubkey '$k': $out"; exit 2; }
51
echo "imported pubkey $k" 1>&2
54
echo "this is used by \$TENV as the gpg directory" > "$GPG_DIR"/README