summaryrefslogtreecommitdiff
path: root/src/kiki-export-stdout
blob: 76b315d2fa85134a03adea5c8338b3bafd6ae79b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
tempd=$(mktemp -d) || exit
: ${sudo:=sudo}

if [ "$USE_KIKI" ]
then
  USE_GPG=
else
  USE_GPG=y
fi

touch "$tempd"/ring.gpg
key=$($sudo kiki | sed -n -e 's/^master-key \([A-Fa-f0-9]*\) -/\1/p')

if [ "$USE_GPG" ]
then
  $sudo gpg2 --export "$key"
else
  $sudo kiki merge \
    --flow=spill,match="$key"  \
    --home \
    --flow=fill \
    --type=keyring --access=public \
    "$tempd"/ring.gpg
fi
r=$?

if [ $r = 0 ]
then
  cat "$tempd"/ring.gpg || r=$?
fi

rm -rf "$tempd"
exit $r